lkml.org 
[lkml]   [2017]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Prototype patch for Linux-kernel memory model
On Tue, 19 Dec 2017, afzal mohammed wrote:

> Hi,
>
> A trivial & late (sorry) comment,
>
> On Wed, Nov 15, 2017 at 08:37:49AM -0800, Paul E. McKenney wrote:
>
> > +THE HAPPENS-BEFORE RELATION: hb
> > +-------------------------------
>
> > +Less trivial examples of prop all involve fences. Unlike the simple
> > +examples above, they can require that some instructions are executed
> > +out of program order. This next one should look familiar:
> > +
> > + int buf = 0, flag = 0;
> > +
> > + P0()
> > + {
> > + WRITE_ONCE(buf, 1);
> > + smp_wmb();
> > + WRITE_ONCE(flag, 1);
> > + }
> > +
> > + P1()
> > + {
> > + int r1;
> > + int r2;
> > +
> > + r1 = READ_ONCE(flag);
> > + r2 = READ_ONCE(buf);
> > + }
> > +
> > +This is the MP pattern again, with an smp_wmb() fence between the two
> > +stores. If r1 = 1 and r2 = 0 at the end then there is a prop link
> > +from P1's second load to its first (backwards!). The reason is
> > +similar to the previous examples: The value P1 loads from buf gets
> > +overwritten by P1's store to buf,
>
> P0's store to buf
>
> afzal

Thank you; I have applied the change.

Alan Stern

\
 
 \ /
  Last update: 2017-12-19 17:07    [W:0.093 / U:2.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site