diff mbox series

[RFC,1/4] powerpc/qspinlock: Avoid cmpxchg pattern in lock stealing

Message ID 20221114161119.2883620-2-npiggin@gmail.com (mailing list archive)
State Superseded
Headers show
Series powerpc/qspinlock: make slowpath accesses more efficient | expand

Commit Message

Nicholas Piggin Nov. 14, 2022, 4:11 p.m. UTC
Using a cmpxchg-style trylock in the lock stealing code opens the
possibility for failures due to the lock word changing, even if it
could have been stolen.

Instead, use the stealing trylock which will do the right thing
and succeed unless the lwarx finds it locked or mustq.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/lib/qspinlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/powerpc/lib/qspinlock.c b/arch/powerpc/lib/qspinlock.c
index 36afdfde41aa..ff718f27cbc9 100644
--- a/arch/powerpc/lib/qspinlock.c
+++ b/arch/powerpc/lib/qspinlock.c
@@ -497,7 +497,7 @@  static __always_inline bool try_to_steal_lock(struct qspinlock *lock, bool parav
 
 		if (unlikely(!(val & _Q_LOCKED_VAL))) {
 			spin_end();
-			if (trylock_with_tail_cpu(lock, val))
+			if (__queued_spin_trylock_steal(lock))
 				return true;
 			spin_begin();
 		} else {