mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
mm: add support for async page locking
Normally waiting for a page to become unlocked, or locking the page, requires waiting for IO to complete. Add support for lock_page_async() and wait_on_page_locked_async(), which are callback based instead. This allows a caller to get notified when a page becomes unlocked, rather than wait for it. We add a new iocb field, ki_waitq, to pass in the necessary data for this to happen. We can unionize this with ki_cookie, since that is only used for polled IO. Polled IO can never co-exist with async callbacks, as it is (by definition) polled completions. struct wait_page_key is made public, and we define struct wait_page_async as the interface between the caller and the core. Acked-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
@@ -535,6 +535,7 @@ static inline int wake_page_match(struct wait_page_queue *wait_page,
|
||||
|
||||
extern void __lock_page(struct page *page);
|
||||
extern int __lock_page_killable(struct page *page);
|
||||
extern int __lock_page_async(struct page *page, struct wait_page_queue *wait);
|
||||
extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
|
||||
unsigned int flags);
|
||||
extern void unlock_page(struct page *page);
|
||||
@@ -571,6 +572,22 @@ static inline int lock_page_killable(struct page *page)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* lock_page_async - Lock the page, unless this would block. If the page
|
||||
* is already locked, then queue a callback when the page becomes unlocked.
|
||||
* This callback can then retry the operation.
|
||||
*
|
||||
* Returns 0 if the page is locked successfully, or -EIOCBQUEUED if the page
|
||||
* was already locked and the callback defined in 'wait' was queued.
|
||||
*/
|
||||
static inline int lock_page_async(struct page *page,
|
||||
struct wait_page_queue *wait)
|
||||
{
|
||||
if (!trylock_page(page))
|
||||
return __lock_page_async(page, wait);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* lock_page_or_retry - Lock the page, unless this would block and the
|
||||
* caller indicated that it can handle a retry.
|
||||
|
Reference in New Issue
Block a user