lkml.org 
[lkml]   [2020]   [Nov]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH memory-model 5/8] tools/memory-model: Add a glossary of LKMM terms
On Fri, Nov 06, 2020 at 01:04:13PM -0800, Paul E. McKenney wrote:
> On Fri, Nov 06, 2020 at 03:40:08PM -0500, Alan Stern wrote:
> > Is it really true that data dependencies are so easily destroyed? I
> > would expect that a true "semantic" dependency (i.e., one where the
> > value written really does vary according to the value read) would be
> > rather hard to second guess.
>
> The usual optimizations apply, for but one example:
>
> r1 = READ_ONCE(x);
> WRITE_ONCE(y, (r1 + 1) % MAX_ELEMENTS);
>
> If MAX_ELEMENTS is 1, so long, data dependency!

Sure, but if MAX_ELEMENTS is 1 then the value written will always be 0
no matter what value r1 has, so it isn't a semantic dependency.
Presumably a semantic data dependency would be much more robust.

I wonder if it's worth pointing out this distinction to the reader.

> With pointers, the compiler has fewer optimization opportunities,
> but there are still cases where it can break the dependency.
> Or transform it to a control dependency.

Transforming a data dependency into a control dependency wouldn't make
any important difference; the hardware would still provide the desired
ordering.

Alan

\
 
 \ /
  Last update: 2020-11-07 03:33    [W:0.080 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site