A folio waiter queued behind an exclusive folio_lock() waiter on the same folio is skipped by folio_wake_bit()'s nr_exclusive=1 walk, so a shared/DROP sleeper (folio_put_wait_locked from do_read_cache_folio) never receives WQ_FLAG_WOKEN even though its wake ran: readers hang D-state in folio_wait_bit_common, fresh reads of the same page answer instantly, and the sleeper wakes only with each later lock/unlock of that address, one page at a time. Numbers from a queue-walk instrument: 363 skipped waiters per 10-minute run before the change, 0 after. https://lore.kernel.org/all/6a4763e3.9dc7bc9d.3d5df4.0007.GAE@google.com/T/ The same change cherry-picks clean onto v7.2.6 (mm/filemap.o builds). It only reorders the enqueue side: non-exclusive waiters use wait.h's default head-side insert, exclusive folio_lock waiters keep the tail, so wake-one fairness for lockers is unchanged. --- mm/filemap.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index d721986d5f46..48994aa81320 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1294,8 +1294,18 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr, */ spin_lock_irq(&q->lock); folio_set_waiters(folio); - if (!folio_trylock_flag(folio, bit_nr, wait)) - __add_wait_queue_entry_tail(q, wait); + if (!folio_trylock_flag(folio, bit_nr, wait)) { + /* + * A non-exclusive (shared/DROP) waiter must queue ahead of + * exclusive folio_lock waiters: the nr_exclusive=1 wake walk + * stops at the first exclusive match, so a non-exclusive + * waiter behind one is never visited and never woken. + */ + if (behavior == EXCLUSIVE) + __add_wait_queue_entry_tail(q, wait); + else + __add_wait_queue(q, wait); + } spin_unlock_irq(&q->lock); /* @@ -1429,7 +1439,7 @@ void softleaf_entry_wait_on_locked(softleaf_t entry, spinlock_t *ptl) spin_lock_irq(&q->lock); folio_set_waiters(folio); if (!folio_trylock_flag(folio, PG_locked, wait)) - __add_wait_queue_entry_tail(q, wait); + __add_wait_queue(q, wait); spin_unlock_irq(&q->lock); /*