LKML Archive on
help / color / mirror / Atom feed
From: Daniel Jordan <>
	Steven Sistare <>,
	Pasha Tatashin <>
Subject: Control dependency between prior load in while condition and later store?
Date: Wed, 4 Apr 2018 15:29:33 -0400	[thread overview]
Message-ID: <> (raw)

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?


             reply	other threads:[~2018-04-04 19:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-04 19:29 Daniel Jordan [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: Control dependency between prior load in while condition and later store?' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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