mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] locking/rwsem: Remove unnessary check in rwsem_down_read_slowpath()
@ 2023-11-08 10:56 Haifeng Xu
  2023-11-08 14:04 ` Waiman Long
  0 siblings, 1 reply; 7+ messages in thread
From: Haifeng Xu @ 2023-11-08 10:56 UTC (permalink / raw)
  To: longman; +Cc: peterz, mingo, will, boqun.feng, linux-kernel, Haifeng Xu

When the owner of rw_semaphore is reader, the count can't be
RWSEM_WRITER_LOCKED, so there is no need to check it.

Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
---
 kernel/locking/rwsem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
index 2340b6d90ec6..7a4d8a9ebd9c 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -1005,8 +1005,7 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int stat
 	 * waiter, don't attempt optimistic lock stealing if the lock is
 	 * currently owned by readers.
 	 */
-	if ((atomic_long_read(&sem->owner) & RWSEM_READER_OWNED) &&
-	    (rcnt > 1) && !(count & RWSEM_WRITER_LOCKED))
+	if ((atomic_long_read(&sem->owner) & RWSEM_READER_OWNED) && (rcnt > 1))
 		goto queue;
 
 	/*
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-11-10 18:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-08 10:56 [PATCH] locking/rwsem: Remove unnessary check in rwsem_down_read_slowpath() Haifeng Xu
2023-11-08 14:04 ` Waiman Long
2023-11-09  3:17   ` Haifeng Xu
2023-11-10  6:54     ` Tang Yizhou
2023-11-10 10:29       ` Haifeng Xu
2023-11-10 13:38         ` Waiman Long
2023-11-10 11:00       ` Haifeng Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®