From: Davidlohr Bueso <dave@stgolabs.net>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, will.deacon@arm.com,
waiman.long@hpe.com, mingo@redhat.com,
paulmck@linux.vnet.ibm.com, boqun.feng@gmail.com,
torvalds@linux-foundation.org
Subject: Re: [RFC][PATCH 2/3] locking/qrwlock: Use smp_cond_load_acquire()
Date: Mon, 11 Apr 2016 21:58:27 -0700 [thread overview]
Message-ID: <20160412045827.GA18437@linux-uzut.site> (raw)
In-Reply-To: <20160404123633.423468902@infradead.org>
On Mon, 04 Apr 2016, Peter Zijlstra wrote:
>Use smp_cond_load_acquire() to make better use of the hardware
>assisted 'spin' wait on arm64.
>
>Arguably the second hunk is the more horrid abuse possible, but
>avoids having to use cmpwait (see next patch) directly. Also, this
>makes 'clever' (ab)use of the cond+rmb acquire to omit the acquire
>from cmpxchg().
>
>Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
>---
> kernel/locking/qrwlock.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
>
>--- a/kernel/locking/qrwlock.c
>+++ b/kernel/locking/qrwlock.c
>@@ -53,10 +53,7 @@ struct __qrwlock {
> static __always_inline void
> rspin_until_writer_unlock(struct qrwlock *lock, u32 cnts)
> {
>- while ((cnts & _QW_WMASK) == _QW_LOCKED) {
>- cpu_relax_lowlatency();
>- cnts = atomic_read_acquire(&lock->cnts);
>- }
>+ smp_cond_load_acquire(&lock->cnts.counter, (VAL & _QW_WMASK) != _QW_LOCKED);
> }
>
> /**
>@@ -109,8 +106,6 @@ EXPORT_SYMBOL(queued_read_lock_slowpath)
> */
> void queued_write_lock_slowpath(struct qrwlock *lock)
> {
>- u32 cnts;
>-
> /* Put the writer into the wait queue */
> arch_spin_lock(&lock->wait_lock);
>
>@@ -134,15 +129,10 @@ void queued_write_lock_slowpath(struct q
> }
>
> /* When no more readers, set the locked flag */
>- for (;;) {
>- cnts = atomic_read(&lock->cnts);
>- if ((cnts == _QW_WAITING) &&
>- (atomic_cmpxchg_acquire(&lock->cnts, _QW_WAITING,
>- _QW_LOCKED) == _QW_WAITING))
>- break;
>+ smp_cond_load_acquire(&lock->cnts.counter,
>+ (VAL == _QW_WAITING) &&
>+ atomic_cmpxchg_relaxed(&lock->cnts, _QW_WAITING, _QW_LOCKED) == _QW_WAITING);
>
>- cpu_relax_lowlatency();
You would need some variant for cpu_relax_lowlatency otherwise you'll be hurting s390, no?
fwiw back when I was looking at this, I recall thinking about possibly introducing
smp_cond_acquire_lowlatency but never got around to it.
Thanks,
Davidlohr
next prev parent reply other threads:[~2016-04-12 4:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-04 12:22 [RFC][PATCH 0/3] smp_cond_load_acquire + cmpwait Peter Zijlstra
2016-04-04 12:22 ` [RFC][PATCH 1/3] locking: Replace smp_cond_acquire with smp_cond_load_acquire Peter Zijlstra
2016-04-04 18:20 ` Waiman Long
2016-04-04 12:22 ` [RFC][PATCH 2/3] locking/qrwlock: Use smp_cond_load_acquire() Peter Zijlstra
2016-04-12 4:58 ` Davidlohr Bueso [this message]
2016-04-12 16:45 ` Waiman Long
2016-04-04 12:22 ` [RFC][PATCH 3/3] locking,arm64: Introduce cmpwait() Peter Zijlstra
2016-04-04 13:12 ` Peter Zijlstra
2016-04-12 16:59 ` Will Deacon
2016-04-13 12:52 ` Peter Zijlstra
2016-04-26 16:33 ` Will Deacon
2016-04-26 17:15 ` Will Deacon
2016-04-26 20:25 ` Peter Zijlstra
2016-04-22 16:08 ` Boqun Feng
2016-04-22 16:53 ` Will Deacon
2016-04-23 4:02 ` Boqun Feng
2016-04-23 2:37 ` Peter Zijlstra
2016-04-23 3:40 ` Boqun Feng
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=20160412045827.GA18437@linux-uzut.site \
--to=dave@stgolabs.net \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=waiman.long@hpe.com \
--cc=will.deacon@arm.com \
/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