filemap: remove use of wait bookmarks
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 10 Oct 2023 03:58:28 +0000 (04:58 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 18 Oct 2023 21:34:18 +0000 (14:34 -0700)
The original problem of the overly long list of waiters on a locked page
was solved properly by commit 9a1ea439b16b ("mm:
put_and_wait_on_page_locked() while page is migrated").  In the meantime,
using bookmarks for the writeback bit can cause livelocks, so we need to
stop using them.

Link: https://lkml.kernel.org/r/20231010035829.544242-1-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Bin Lai <sclaibin@gmail.com>
Cc: Benjamin Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/filemap.c

index 48cd16c54e86f1e381c09dd3bcba7bffcf4ada36..9ef49255f1a5f522834faa3c79acb5c31acf99a9 100644 (file)
@@ -1133,32 +1133,13 @@ static void folio_wake_bit(struct folio *folio, int bit_nr)
        wait_queue_head_t *q = folio_waitqueue(folio);
        struct wait_page_key key;
        unsigned long flags;
-       wait_queue_entry_t bookmark;
 
        key.folio = folio;
        key.bit_nr = bit_nr;
        key.page_match = 0;
 
-       bookmark.flags = 0;
-       bookmark.private = NULL;
-       bookmark.func = NULL;
-       INIT_LIST_HEAD(&bookmark.entry);
-
        spin_lock_irqsave(&q->lock, flags);
-       __wake_up_locked_key_bookmark(q, TASK_NORMAL, &key, &bookmark);
-
-       while (bookmark.flags & WQ_FLAG_BOOKMARK) {
-               /*
-                * Take a breather from holding the lock,
-                * allow pages that finish wake up asynchronously
-                * to acquire the lock and remove themselves
-                * from wait queue
-                */
-               spin_unlock_irqrestore(&q->lock, flags);
-               cpu_relax();
-               spin_lock_irqsave(&q->lock, flags);
-               __wake_up_locked_key_bookmark(q, TASK_NORMAL, &key, &bookmark);
-       }
+       __wake_up_locked_key(q, TASK_NORMAL, &key);
 
        /*
         * It's possible to miss clearing waiters here, when we woke our page