Messages in this thread Patch in this message | | | From | Waiman Long <> | Subject | [PATCH v2 4/8] locking/rwsem: Simplify rwsem_writer_wake() | Date | Mon, 27 Mar 2023 16:24:09 -0400 |
| |
From: Peter Zijlstra <peterz@infradead.org>
Since @waiter := rwsem_first_waiter() simplify things.
Suggested-by: Waiman Long <longman@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> --- kernel/locking/rwsem.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c index 0cc0aa566a6b..225e86326ea4 100644 --- a/kernel/locking/rwsem.c +++ b/kernel/locking/rwsem.c @@ -426,26 +426,12 @@ rwsem_waiter_wake(struct rwsem_waiter *waiter, struct wake_q_head *wake_q) static inline bool rwsem_try_write_lock(struct rw_semaphore *sem, struct rwsem_waiter *waiter) { - - struct rwsem_waiter *first = rwsem_first_waiter(sem); long count, new; lockdep_assert_held(&sem->wait_lock); count = atomic_long_read(&sem->count); do { - bool has_handoff = !!(count & RWSEM_FLAG_HANDOFF); - - if (has_handoff) { - /* - * Honor handoff bit and yield only when the first - * waiter is the one that set it. Otherwisee, we - * still try to acquire the rwsem. - */ - if (first->handoff_set && (waiter != first)) - return false; - } - new = count; if (count & RWSEM_LOCK_MASK) { @@ -454,8 +440,9 @@ static inline bool rwsem_try_write_lock(struct rw_semaphore *sem, * if it is an RT task or wait in the wait queue * for too long. */ - if (has_handoff || (!rt_task(waiter->task) && - !time_after(jiffies, waiter->timeout))) + if ((count & RWSEM_FLAG_HANDOFF) || + (!rt_task(waiter->task) && + !time_after(jiffies, waiter->timeout))) return false; new |= RWSEM_FLAG_HANDOFF; @@ -474,7 +461,7 @@ static inline bool rwsem_try_write_lock(struct rw_semaphore *sem, * set here to enable optimistic spinning in slowpath loop. */ if (new & RWSEM_FLAG_HANDOFF) { - first->handoff_set = true; + waiter->handoff_set = true; lockevent_inc(rwsem_wlock_handoff); return false; } -- 2.31.1
| |