lkml.org 
[lkml]   [2017]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Unlock-lock questions and the Linux Kernel Memory Model
On Wed, 29 Nov 2017, Peter Zijlstra wrote:

> On Wed, Nov 29, 2017 at 11:04:53AM -0800, Daniel Lustig wrote:
>
> > While we're here, let me ask about another test which isn't directly
> > about unlock/lock but which is still somewhat related to this
> > discussion:
> >
> > "MP+wmb+xchg-acq" (or some such)
> >
> > {}
> >
> > P0(int *x, int *y)
> > {
> > WRITE_ONCE(*x, 1);
> > smp_wmb();
> > WRITE_ONCE(*y, 1);
> > }
> >
> > P1(int *x, int *y)
> > {
> > r1 = atomic_xchg_relaxed(y, 2);
> > r2 = smp_load_acquire(y);
> > r3 = READ_ONCE(*x);
> > }
> >
> > exists (1:r1=1 /\ 1:r2=2 /\ 1:r3=0)
> >
> > C/C++ would call the atomic_xchg_relaxed part of a release sequence
> > and hence would forbid this outcome.
>
> That's just weird. Either its _relaxed, or its _release. Making _relaxed
> mean _release is just daft.

The C11 memory model specifically allows atomic operations to be
interspersed within a release sequence. But it doesn't say why.

Alan

\
 
 \ /
  Last update: 2017-11-29 20:54    [W:0.067 / U:0.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site