mm/filemap.c | 6 ++++-- mm/page-writeback.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 5c9d564317a5..031d19d0f4b2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1052,14 +1052,16 @@ static int wake_page_function(wait_queue_entry_t *wait, unsigned mode, int sync, if (!wake_page_match(wait_page, key)) return 0; + /* Stop walking if the bit was already taken */ + if (test_bit(key->bit_nr, &key->page->flags)) + return -1; + /* * If it's a lock handoff wait, we get the bit for it, and * stop walking (and do not wake it up) if we can't. */ flags = wait->flags; if (flags & WQ_FLAG_EXCLUSIVE) { - if (test_bit(key->bit_nr, &key->page->flags)) - return -1; if (flags & WQ_FLAG_CUSTOM) { if (test_and_set_bit(key->bit_nr, &key->page->flags)) return -1; diff --git a/mm/page-writeback.c b/mm/page-writeback.c index eb34d204d4ee..586042472ac9 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2826,7 +2826,7 @@ EXPORT_SYMBOL(__test_set_page_writeback); */ void wait_on_page_writeback(struct page *page) { - while (PageWriteback(page)) { + if (PageWriteback(page)) { trace_wait_on_page_writeback(page, page_mapping(page)); wait_on_page_bit(page, PG_writeback); }