Skip to content

Commit d566c78

Browse files
Waiman-LongIngo Molnar
authored andcommitted
locking/rwsem: Clarify that RWSEM_READER_OWNED is just a hint
Clarify in the comments that the RWSEM_READER_OWNED bit in the owner field is just a hint, not an authoritative state of the rwsem. Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d6cac0b commit d566c78

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/locking/rwsem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
/*
3636
* The least significant 2 bits of the owner value has the following
3737
* meanings when set.
38-
* - Bit 0: RWSEM_READER_OWNED - The rwsem is owned by readers
38+
* - Bit 0: RWSEM_READER_OWNED - rwsem may be owned by readers (just a hint)
3939
* - Bit 1: RWSEM_NONSPINNABLE - Cannot spin on a reader-owned lock
4040
*
4141
* When the rwsem is reader-owned and a spinning writer has timed out,
@@ -1002,8 +1002,8 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int stat
10021002

10031003
/*
10041004
* To prevent a constant stream of readers from starving a sleeping
1005-
* waiter, don't attempt optimistic lock stealing if the lock is
1006-
* currently owned by readers.
1005+
* writer, don't attempt optimistic lock stealing if the lock is
1006+
* very likely owned by readers.
10071007
*/
10081008
if ((atomic_long_read(&sem->owner) & RWSEM_READER_OWNED) &&
10091009
(rcnt > 1) && !(count & RWSEM_WRITER_LOCKED))

0 commit comments

Comments
 (0)