]> git.baikalelectronics.ru Git - kernel.git/commit
locking/rwsem: Conditionally wake waiters in reader/writer slowpaths
authorWaiman Long <longman@redhat.com>
Tue, 22 Mar 2022 15:20:58 +0000 (11:20 -0400)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 5 Apr 2022 08:24:35 +0000 (10:24 +0200)
commitcde7bde995e3b4a05fd09811e0ca2fa4dca5e322
tree3611f9ad3f48204ed7581fd53597afade07eb21f
parent8bd3a8aaa61538d2d3b0b57d64ebb1d2e9b893c6
locking/rwsem: Conditionally wake waiters in reader/writer slowpaths

In an analysis of a recent vmcore, a reader-owned rwsem was found with
385 readers but no writer in the wait queue. That is kind of unusual
but it may be caused by some race conditions that we have not fully
understood yet. In such a case, all the readers in the wait queue should
join the other reader-owners and acquire the read lock.

In rwsem_down_write_slowpath(), an incoming writer will try to
wake up the front readers under such circumstance. That is not
the case for rwsem_down_read_slowpath(), add a new helper function
rwsem_cond_wake_waiter() to do wakeup and use it in both reader and
writer slowpaths to have a consistent and correct behavior.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220322152059.2182333-3-longman@redhat.com
kernel/locking/rwsem.c