From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Will Deacon <will.deacon@arm.com>
Cc: Boqun Feng <boqun.feng@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, mingo@kernel.org,
dhowells@redhat.com, stern@rowland.harvard.edu
Subject: Re: [PATCH locking/Documentation 1/2] Add note of release-acquire store vulnerability
Date: Fri, 30 Sep 2016 04:35:31 -0700 [thread overview]
Message-ID: <20160930113531.GN14933@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160930092009.GF10184@arm.com>
On Fri, Sep 30, 2016 at 10:20:09AM +0100, Will Deacon wrote:
> On Fri, Sep 30, 2016 at 01:53:52PM +0800, Boqun Feng wrote:
> > On Thu, Sep 29, 2016 at 10:23:22AM -0700, Paul E. McKenney wrote:
> > > If two processes are related by a RELEASE+ACQUIRE pair, ordering can be
> > > broken if a third process overwrites the value written by the RELEASE
> > > operation before the ACQUIRE operation has a chance of reading it, for
> > > example:
> > >
> > > P0(int *x, int *y)
> > > {
> > > WRITE_ONCE(*x, 1);
> > > smp_wmb();
> > ^^^^^^^^^^^
> >
> > What is this smp_wmb() for?
Seems redundant to me, now that you mention it. ;-)
But maybe this does something on ARM?
> > > smp_store_release(y, 1);
> > > }
> > >
> > > P1(int *y)
> > > {
> > > WRITE_ONCE(*y, 2);
> >
> > If we change this WRITE_ONCE to a relaxed atomic operation(e.g.
> > xchg_relaxed(y, 2)), both herd and ppcmem said the exist-clause "y = 2
> > /\ 2:r1 = 2 /\ 2:r2 = 0" wouldn't be triggered on PPC.
> >
> > I guess we will get the same behavior on ARM/ARM64, Will?
> >
> > If a normal store could break chain, while a RmW atomic won't, do we
> > want to call it out in the document and build our memory model around
> > this?
>
> I think this is required to work by C11's definition of release sequences,
> so any architecture that claims to support those with the same instructions
> will need this to be forbidden.
Yes.
> Personally, I think that's a bug in C11, because I think it goes too far
> in forbidding some hardware optimisations around relaxed xchg, but it is
> what it is.
The idea at the time (2007 or thereabouts) was that the atomic operation
would have a hard time breaking the causal chain. To your point, atomic
xchg could presumably update the value and figure out what the previous
value was after the fact. Maybe we should try to get the committee to
relax the requirement for relaxed xchg, though backwards compatibility
will make that a tough sell. Might need a new xchg API.
Thanx, Paul
next prev parent reply other threads:[~2016-09-30 11:35 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-29 15:54 [PATCH locking/Documentation 1/2] Add note of release-acquire store vulnerability Paul E. McKenney
2016-09-29 15:58 ` Peter Zijlstra
2016-09-29 16:03 ` Will Deacon
2016-09-29 16:17 ` Peter Zijlstra
2016-09-29 16:44 ` Paul E. McKenney
2016-09-29 16:43 ` Paul E. McKenney
2016-09-29 17:10 ` Will Deacon
2016-09-29 17:23 ` Paul E. McKenney
2016-09-29 18:04 ` Paul E. McKenney
2016-09-29 18:10 ` Paul E. McKenney
2016-09-29 18:44 ` Peter Zijlstra
2016-09-29 19:18 ` Paul E. McKenney
2016-09-29 19:36 ` Alan Stern
2016-09-29 20:26 ` Paul E. McKenney
2016-09-30 8:53 ` Peter Zijlstra
2016-09-30 9:00 ` Peter Zijlstra
2016-09-30 9:57 ` Peter Zijlstra
2016-09-30 12:14 ` Paul E. McKenney
2016-09-30 12:51 ` Peter Zijlstra
2016-09-30 13:35 ` Paul E. McKenney
2016-09-30 5:53 ` Boqun Feng
2016-09-30 9:20 ` Will Deacon
2016-09-30 11:35 ` Paul E. McKenney [this message]
2016-09-30 10:25 ` Peter Zijlstra
2016-09-30 12:17 ` Paul E. McKenney
2016-09-30 12:45 ` Peter Zijlstra
2016-09-30 13:10 ` Paul E. McKenney
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=20160930113531.GN14933@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=boqun.feng@gmail.com \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=stern@rowland.harvard.edu \
--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