Thread (29 messages) 29 messages, 4 authors, 2023-05-10

Re: [PATCH 02/12] powerpc: qspinlock: Mark accesses to qnode lock checks

From: "Nicholas Piggin" <npiggin@gmail.com>
Date: 2023-05-09 02:03:57

On Mon May 8, 2023 at 12:01 PM AEST, Rohan McLure wrote:
The powerpc implemenation of qspinlocks will both poll and spin on the
bitlock guarding a qnode. Mark these accesses with READ_ONCE to convey
to KCSAN that polling is intentional here.
Yeah, and obviously pairs with the WRITE_ONCE so comment isn't really
necessary.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
quoted hunk ↗ jump to hunk
Signed-off-by: Rohan McLure <redacted>
---
 arch/powerpc/lib/qspinlock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/lib/qspinlock.c b/arch/powerpc/lib/qspinlock.c
index 9cf93963772b..579290d55abf 100644
--- a/arch/powerpc/lib/qspinlock.c
+++ b/arch/powerpc/lib/qspinlock.c
@@ -435,7 +435,7 @@ static __always_inline bool yield_to_prev(struct qspinlock *lock, struct qnode *
 
 	smp_rmb(); /* See __yield_to_locked_owner comment */
 
-	if (node->locked) {
+	if (READ_ONCE(node->locked)) {
 		yield_to_preempted(prev_cpu, yield_count);
 		spin_begin();
 		return preempted;
@@ -584,7 +584,7 @@ static __always_inline void queued_spin_lock_mcs_queue(struct qspinlock *lock, b
 
 		/* Wait for mcs node lock to be released */
 		spin_begin();
-		while (node->locked) {
+		while (READ_ONCE(node->locked)) {
 			spec_barrier();
 
 			if (yield_to_prev(lock, node, old, paravirt))
-- 
2.37.2
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help