lkml.org 
[lkml]   [2018]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Control dependency between prior load in while condition and later store?
On Wed, Apr 04, 2018 at 04:35:32PM -0400, Alan Stern wrote:
> On Wed, 4 Apr 2018, Daniel Jordan wrote:
>
> > A question for memory-barriers.txt aficionados.
> >
> > Is there a control dependency between the prior load of 'a' and the
> > later store of 'c'?:
> >
> > while (READ_ONCE(a));
> > WRITE_ONCE(c, 1);
>
> I would say that yes, there is.

Indeed.

> Yes, except that a more accurate view of the object code would be
> something like this:
>
> Loop: r1 = READ_ONCE(a);
> if (r1)
> goto Loop;
> else
> ; // Do nothing
> WRITE_ONCE(c, 1);
>
> Here you can see that one path branches backward, so everything
> following the "if" is dependent on the READ_ONCE.

Agreed, and I think I even have code that relies on such a pattern
somewhere.. Ah.. yes, see smp_cond_load_acquire().

\
 
 \ /
  Last update: 2018-04-05 09:32    [W:0.059 / U:5.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site