[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230223123319.428168721@infradead.org>
Date: Thu, 23 Feb 2023 13:26:44 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: longman@...hat.com, mingo@...hat.com, will@...nel.org
Cc: linux-kernel@...r.kernel.org, peterz@...radead.org,
boqun.feng@...il.com
Subject: [PATCH 2/6] locking/rwsem: Enforce queueing when HANDOFF
Ensure that HANDOFF disables all spinning and stealing.
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
---
kernel/locking/rwsem.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -468,7 +468,12 @@ static void rwsem_mark_wake(struct rw_se
adjustment -= RWSEM_FLAG_HANDOFF;
lockevent_inc(rwsem_rlock_handoff);
}
+ /*
+ * With HANDOFF set for reader, we must
+ * terminate all spinning.
+ */
waiter->handoff_set = true;
+ rwsem_set_nonspinnable(sem);
}
atomic_long_add(-adjustment, &sem->count);
@@ -755,6 +760,10 @@ rwsem_spin_on_owner(struct rw_semaphore
owner = rwsem_owner_flags(sem, &flags);
state = rwsem_owner_state(owner, flags);
+
+ if (owner == current)
+ return OWNER_NONSPINNABLE; /* Handoff granted */
+
if (state != OWNER_WRITER)
return state;
Powered by blists - more mailing lists