From: Will Deacon <will.deacon@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"Waiman.Long@hp.com" <Waiman.Long@hp.com>,
"mingo@redhat.com" <mingo@redhat.com>
Subject: Re: [PATCH 5/9] locking/qrwlock: remove redundant cmpxchg barriers on writer slow-path
Date: Wed, 8 Jul 2015 14:34:03 +0100 [thread overview]
Message-ID: <20150708133343.GC9283@arm.com> (raw)
In-Reply-To: <20150708100526.GC3644@twins.programming.kicks-ass.net>
On Wed, Jul 08, 2015 at 11:05:26AM +0100, Peter Zijlstra wrote:
> On Tue, Jul 07, 2015 at 06:24:21PM +0100, Will Deacon wrote:
> > +#ifndef cmpxchg_relaxed
> > +# define cmpxchg_relaxed cmpxchg
> > +#endif
>
> Should we collate this _relaxed stuff and make it 'official' instead of
> these ad-hoc/in-situ things?
>
> There's more archs that can usefully implement them than seem to have
> implemented them atm. Of course that means someone doing a full arch/*
> sweep, but hey.. :-)
Well, in writing this series, I'm seeing a repeated need for:
* acquire/release/relaxed variants of cmpxchg
* acquire/relaxed atomic_add_return
* acquire/release atomic_sub
I also suspect that if I look at getting qspinlock up and running, the
list above will grow.
So you're right, but it sounds like we need to extend the atomic APIs to
have acquire/release/relaxed variants. The easiest start would be to
extend the _return variants (+cmpxchg) to allow the new options, but
defaulting to the existing (full barrier) implementations if the arch
doesn't provide an alternative. Weird things like dec_if_positive could
be left alone (i.e. not implemented) for now.
The hard part is defining the semantics of these new flavours. Do we want
SC acquire/release (i.e. what we have on arm64) or PC acquire/release (i.e.
what we have in C11)? For architectures building these constructs out of
barrier instructions, the former requires an additional barrier following
a release operation so that it is ordered against a subsequent acquire.
Another potential problem of defining things this way is cmpxchg_acquire
potentially giving relaxed semantics if the comparison fails (different
to C11, iirc).
Anyway, clearly a separate series. Should keep me busy...
Will
WARNING: multiple messages have this Message-ID (diff)
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/9] locking/qrwlock: remove redundant cmpxchg barriers on writer slow-path
Date: Wed, 8 Jul 2015 14:34:03 +0100 [thread overview]
Message-ID: <20150708133343.GC9283@arm.com> (raw)
In-Reply-To: <20150708100526.GC3644@twins.programming.kicks-ass.net>
On Wed, Jul 08, 2015 at 11:05:26AM +0100, Peter Zijlstra wrote:
> On Tue, Jul 07, 2015 at 06:24:21PM +0100, Will Deacon wrote:
> > +#ifndef cmpxchg_relaxed
> > +# define cmpxchg_relaxed cmpxchg
> > +#endif
>
> Should we collate this _relaxed stuff and make it 'official' instead of
> these ad-hoc/in-situ things?
>
> There's more archs that can usefully implement them than seem to have
> implemented them atm. Of course that means someone doing a full arch/*
> sweep, but hey.. :-)
Well, in writing this series, I'm seeing a repeated need for:
* acquire/release/relaxed variants of cmpxchg
* acquire/relaxed atomic_add_return
* acquire/release atomic_sub
I also suspect that if I look at getting qspinlock up and running, the
list above will grow.
So you're right, but it sounds like we need to extend the atomic APIs to
have acquire/release/relaxed variants. The easiest start would be to
extend the _return variants (+cmpxchg) to allow the new options, but
defaulting to the existing (full barrier) implementations if the arch
doesn't provide an alternative. Weird things like dec_if_positive could
be left alone (i.e. not implemented) for now.
The hard part is defining the semantics of these new flavours. Do we want
SC acquire/release (i.e. what we have on arm64) or PC acquire/release (i.e.
what we have in C11)? For architectures building these constructs out of
barrier instructions, the former requires an additional barrier following
a release operation so that it is ordered against a subsequent acquire.
Another potential problem of defining things this way is cmpxchg_acquire
potentially giving relaxed semantics if the comparison fails (different
to C11, iirc).
Anyway, clearly a separate series. Should keep me busy...
Will
next prev parent reply other threads:[~2015-07-08 13:34 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 17:24 [PATCH 0/9] locking/qrwlock: get qrwlocks up and running on arm64 Will Deacon
2015-07-07 17:24 ` Will Deacon
2015-07-07 17:24 ` [PATCH 1/9] locking/qrwlock: include <linux/spinlock.h> for arch_spin_{lock,unlock} Will Deacon
2015-07-07 17:24 ` [PATCH 1/9] locking/qrwlock: include <linux/spinlock.h> for arch_spin_{lock, unlock} Will Deacon
2015-07-07 17:24 ` [PATCH 2/9] locking/qrwlock: avoid redundant atomic_add_return on read_lock_slowpath Will Deacon
2015-07-07 17:24 ` Will Deacon
2015-07-07 17:51 ` Waiman Long
2015-07-07 17:51 ` Waiman Long
2015-07-07 18:19 ` Will Deacon
2015-07-07 18:19 ` Will Deacon
2015-07-07 19:28 ` Waiman Long
2015-07-07 19:28 ` Waiman Long
2015-07-08 9:59 ` Peter Zijlstra
2015-07-08 9:59 ` Peter Zijlstra
2015-07-08 13:37 ` Will Deacon
2015-07-08 13:37 ` Will Deacon
2015-07-07 21:30 ` Peter Zijlstra
2015-07-07 21:30 ` Peter Zijlstra
2015-07-07 17:24 ` [PATCH 3/9] locking/qrwlock: tidy up rspin_until_writer_unlock Will Deacon
2015-07-07 17:24 ` Will Deacon
2015-07-07 17:24 ` [PATCH 4/9] locking/qrwlock: implement queue_write_unlock using smp_store_release Will Deacon
2015-07-07 17:24 ` Will Deacon
2015-07-08 10:00 ` Peter Zijlstra
2015-07-08 10:00 ` Peter Zijlstra
2015-07-07 17:24 ` [PATCH 5/9] locking/qrwlock: remove redundant cmpxchg barriers on writer slow-path Will Deacon
2015-07-07 17:24 ` Will Deacon
2015-07-08 10:05 ` Peter Zijlstra
2015-07-08 10:05 ` Peter Zijlstra
2015-07-08 13:34 ` Will Deacon [this message]
2015-07-08 13:34 ` Will Deacon
2015-07-07 17:24 ` [PATCH 6/9] locking/qrwlock: allow architectures to hook in to contended paths Will Deacon
2015-07-07 17:24 ` Will Deacon
2015-07-08 10:06 ` Peter Zijlstra
2015-07-08 10:06 ` Peter Zijlstra
2015-07-08 13:35 ` Will Deacon
2015-07-08 13:35 ` Will Deacon
2015-07-07 17:24 ` [PATCH 7/9] locking/qrwlock: expose internal lock structure in qrwlock definition Will Deacon
2015-07-07 17:24 ` Will Deacon
2015-07-07 17:24 ` [PATCH 8/9] arm64: cmpxchg: implement cmpxchg_relaxed Will Deacon
2015-07-07 17:24 ` Will Deacon
2015-07-07 17:24 ` [PATCH 9/9] arm64: locking: replace read/write locks with generic qrwlock code Will Deacon
2015-07-07 17:24 ` Will Deacon
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=20150708133343.GC9283@arm.com \
--to=will.deacon@arm.com \
--cc=Waiman.Long@hp.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.