OSDN Git Service

mm: rewrite wait_on_page_bit_common() logic
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 23 Jul 2020 17:16:49 +0000 (10:16 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 3 Aug 2020 03:39:44 +0000 (20:39 -0700)
commit2a9127fcf2296674d58024f83981f40b128fffea
tree3ca484e7a7e6a15a9ada066baae11c4ef12ed898
parentbcf876870b95592b52519ed4aafcf9d95999bc9c
mm: rewrite wait_on_page_bit_common() logic

It turns out that wait_on_page_bit_common() had several problems,
ranging from just unfair behavioe due to re-queueing at the end of the
wait queue when re-trying, and an outright bug that could result in
missed wakeups (but probably never happened in practice).

This rewrites the whole logic to avoid both issues, by simply moving the
logic to check (and possibly take) the bit lock into the wakeup path
instead.

That makes everything much more straightforward, and means that we never
need to re-queue the wait entry: if we get woken up, we'll be notified
through WQ_FLAG_WOKEN, and the wait queue entry will have been removed,
and everything will have been done for us.

Link: https://lore.kernel.org/lkml/CAHk-=wjJA2Z3kUFb-5s=6+n0qbTs8ELqKFt9B3pH85a8fGD73w@mail.gmail.com/
Link: https://lore.kernel.org/lkml/alpine.LSU.2.11.2007221359450.1017@eggly.anvils/
Reported-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Hugh Dickins <hughd@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/filemap.c