[RFC PATCH 1/4] powerpc/qspinlock: Avoid cmpxchg pattern in lock stealing
Nicholas Piggin
npiggin at gmail.com
Tue Nov 15 03:11:16 AEDT 2022
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 at gmail.com>
---
arch/powerpc/lib/qspinlock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 {
--
2.37.2
More information about the Linuxppc-dev
mailing list