From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Jordan Niethe <jniethe5@gmail.com>,
Laurent Dufour <laurent.dufour@fr.ibm.com>,
Nicholas Piggin <npiggin@gmail.com>
Subject: [RFC PATCH 1/4] powerpc/qspinlock: Avoid cmpxchg pattern in lock stealing
Date: Tue, 15 Nov 2022 02:11:16 +1000 [thread overview]
Message-ID: <20221114161119.2883620-2-npiggin@gmail.com> (raw)
In-Reply-To: <20221114161119.2883620-1-npiggin@gmail.com>
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 --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
next prev parent reply other threads:[~2022-11-14 16:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 16:11 [RFC PATCH 0/4] powerpc/qspinlock: make slowpath accesses more efficient Nicholas Piggin
2022-11-14 16:11 ` Nicholas Piggin [this message]
2022-11-14 16:11 ` [RFC PATCH 2/4] powerpc/qspinlock: Avoid cmpxchg style patterns in queue head locking Nicholas Piggin
2022-11-14 16:11 ` [RFC PATCH 3/4] powerpc/qspinlock: Remove !maybe_waiters special case " Nicholas Piggin
2022-11-14 16:11 ` [RFC PATCH 4/4] powerpc/qspinlock: add compile-time tuning adjustments Nicholas Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221114161119.2883620-2-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=jniethe5@gmail.com \
--cc=laurent.dufour@fr.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).