[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Wed, 4 Apr 2018 15:29:33 -0400
From: Daniel Jordan <daniel.m.jordan@...cle.com>
To: stern@...land.harvard.edu, parri.andrea@...il.com,
will.deacon@....com, peterz@...radead.org, boqun.feng@...il.com,
npiggin@...il.com, dhowells@...hat.com, j.alglave@....ac.uk,
luc.maranget@...ia.fr, paulmck@...ux.vnet.ibm.com,
akiyks@...il.com, linux-kernel@...r.kernel.org,
Steven Sistare <steven.sistare@...cle.com>,
Pasha Tatashin <pasha.tatashin@...cle.com>
Subject: Control dependency between prior load in while condition and later
store?
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 have my doubts because memory-barriers.txt doesn't talk much about
loops and because of what that document says here:
In addition, control dependencies apply only to the then-clause and
else-clause of the if-statement in question. In particular, it does
not necessarily apply to code following the if-statement:
q = READ_ONCE(a);
if (q) {
WRITE_ONCE(b, 1);
} else {
WRITE_ONCE(b, 2);
}
WRITE_ONCE(c, 1); /* BUG: No ordering against the read from 'a'. */
It's not obvious to me how the then-clause/else-clause idea maps onto
loops, but if we think of the example at the top like this...
while (1) {
if (!READ_ONCE(a)) {
WRITE_ONCE(c, 1);
break;
}
}
...then the dependent store is within the then-clause. Viewed this way,
it seems there would be a control dependency between a and c.
Is that right?
Thanks,
Daniel
Powered by blists - more mailing lists