locking/rwsem: Always try to wake waiters in out_nolock path
authorWaiman Long <longman@redhat.com>
Tue, 22 Mar 2022 15:20:59 +0000 (11:20 -0400)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 5 Apr 2022 08:24:35 +0000 (10:24 +0200)
commit1ee326196c66583006b0c95356a4b7dc51bf3531
treef9b36797a5eb085882caa15616daa89a81c09025
parent54c1ee4d614d52844cf24c46d8415bf1392021d0
locking/rwsem: Always try to wake waiters in out_nolock path

For writers, the out_nolock path will always attempt to wake up waiters.
This may not be really necessary if the waiter to be removed is not the
first one.

For readers, no attempt to wake up waiter is being made. However, if
the HANDOFF bit is set and the reader to be removed is the first waiter,
the waiter behind it will inherit the HANDOFF bit and for a write lock
waiter waking it up will allow it to spin on the lock to acquire it
faster. So it can be beneficial to do a wakeup in this case.

Add a new rwsem_del_wake_waiter() helper function to do that consistently
for both reader and writer out_nolock paths.

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-4-longman@redhat.com
kernel/locking/rwsem.c