Skip to content

Commit f62e00c

Browse files
kosakitorvalds
authored andcommitted
mm: introduce wait_on_page_locked_killable()
commit 2687a35 ("Add lock_page_killable") introduced killable lock_page(). Similarly this patch introdues killable wait_on_page_locked(). Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Reviewed-by: Minchan Kim <minchan.kim@gmail.com> Cc: Matthew Wilcox <willy@linux.intel.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent fa25c50 commit f62e00c

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎include/linux/pagemap.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ static inline int lock_page_or_retry(struct page *page, struct mm_struct *mm,
357357
*/
358358
extern void wait_on_page_bit(struct page *page, int bit_nr);
359359

360+
extern int wait_on_page_bit_killable(struct page *page, int bit_nr);
361+
362+
static inline int wait_on_page_locked_killable(struct page *page)
363+
{
364+
if (PageLocked(page))
365+
return wait_on_page_bit_killable(page, PG_locked);
366+
return 0;
367+
}
368+
360369
/*
361370
* Wait for a page to be unlocked.
362371
*

‎mm/filemap.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,17 @@ void wait_on_page_bit(struct page *page, int bit_nr)
562562
}
563563
EXPORT_SYMBOL(wait_on_page_bit);
564564

565+
int wait_on_page_bit_killable(struct page *page, int bit_nr)
566+
{
567+
DEFINE_WAIT_BIT(wait, &page->flags, bit_nr);
568+
569+
if (!test_bit(bit_nr, &page->flags))
570+
return 0;
571+
572+
return __wait_on_bit(page_waitqueue(page), &wait,
573+
sleep_on_page_killable, TASK_KILLABLE);
574+
}
575+
565576
/**
566577
* add_page_wait_queue - Add an arbitrary waiter to a page's wait queue
567578
* @page: Page defining the wait queue of interest

0 commit comments

Comments
 (0)