Skip to content

Commit f9e21aa

Browse files
Waiman-LongPeter Zijlstra
authored andcommitted
locking/rwsem: No need to check for handoff bit if wait queue empty
Since commit d257cc8 ("locking/rwsem: Make handoff bit handling more consistent"), the handoff bit is always cleared if the wait queue becomes empty. There is no need to check for RWSEM_FLAG_HANDOFF when the wait list is known to be empty. Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 8b023ac commit f9e21aa

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

kernel/locking/rwsem.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -977,12 +977,11 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int stat
977977
if (list_empty(&sem->wait_list)) {
978978
/*
979979
* In case the wait queue is empty and the lock isn't owned
980-
* by a writer or has the handoff bit set, this reader can
981-
* exit the slowpath and return immediately as its
982-
* RWSEM_READER_BIAS has already been set in the count.
980+
* by a writer, this reader can exit the slowpath and return
981+
* immediately as its RWSEM_READER_BIAS has already been set
982+
* in the count.
983983
*/
984-
if (!(atomic_long_read(&sem->count) &
985-
(RWSEM_WRITER_MASK | RWSEM_FLAG_HANDOFF))) {
984+
if (!(atomic_long_read(&sem->count) & RWSEM_WRITER_MASK)) {
986985
/* Provide lock ACQUIRE */
987986
smp_acquire__after_ctrl_dep();
988987
raw_spin_unlock_irq(&sem->wait_lock);

0 commit comments

Comments
 (0)