LKML Archive on
help / color / mirror / Atom feed
* Control dependency between prior load in while condition and later store?
@ 2018-04-04 19:29 Daniel Jordan
  2018-04-04 20:35 ` Alan Stern
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Jordan @ 2018-04-04 19:29 UTC (permalink / raw)
  To: stern, parri.andrea, will.deacon, peterz, boqun.feng, npiggin,
	dhowells, j.alglave, luc.maranget, paulmck, akiyks, linux-kernel,
	Steven Sistare, Pasha Tatashin

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);

...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?


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-04-05 15:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04 19:29 Control dependency between prior load in while condition and later store? Daniel Jordan
2018-04-04 20:35 ` Alan Stern
2018-04-04 21:10   ` Daniel Jordan
2018-04-05  7:32   ` Peter Zijlstra
2018-04-05 14:35     ` Alan Stern
2018-04-05 14:56       ` Peter Zijlstra
2018-04-05 15:16         ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).