linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: "Paul Heidekrüger" <Paul.Heidekrueger@in.tum.de>
Cc: clang-built-linux <llvm@lists.linux.dev>,
	linux-toolchains@vger.kernel.org,
	Andrea Parri <parri.andrea@gmail.com>,
	Will Deacon <will@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	David Howells <dhowells@redhat.com>,
	Jade Alglave <j.alglave@ucl.ac.uk>,
	Luc Maranget <luc.maranget@inria.fr>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Akira Yokosawa <akiyks@gmail.com>,
	Daniel Lustig <dlustig@nvidia.com>,
	Joel Fernandes <joel@joelfernandes.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>, Palmer Dabbelt <palmer@dabbelt.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	Marco Elver <elver@google.com>,
	Charalampos Mainas <charalampos.mainas@gmail.com>,
	Pramod Bhatotia <pramod.bhatotia@in.tum.de>,
	Soham Chakraborty <s.s.chakraborty@tudelft.nl>,
	Martin Fink <martin.fink@in.tum.de>
Subject: Re: [PATCH RFC] tools/memory-model: Adjust ctrl dependency definition
Date: Mon, 27 Jun 2022 10:56:09 -0400	[thread overview]
Message-ID: <YrnFCSjESpeQdciv@rowland.harvard.edu> (raw)
In-Reply-To: <04B4DBD6-1262-4905-9E85-9466FC104895@in.tum.de>

On Mon, Jun 27, 2022 at 11:47:43AM +0200, Paul Heidekrüger wrote:
> 
> > On 21. Jun 2022, at 16:24, Alan Stern <stern@rowland.harvard.edu> wrote:
> > 
> > On Tue, Jun 21, 2022 at 01:59:27PM +0200, Paul Heidekrüger wrote:
> >> OK. So, LKMM limits the scope of control dependencies to its arm(s), hence
> >> there is a control dependency from the last READ_ONCE() before the loop
> >> exists to the WRITE_ONCE().
> >> 
> >> But then what about the following:
> >> 
> >>> int *x, *y;
> >>> 
> >>> int foo()
> >>> {
> >>> 	/* More code */
> >>> 
> >>> 	if(READ_ONCE(x))
> >>> 		return 42;
> >>> 
> >>> 	/* More code */
> >>> 
> >>> 	WRITE_ONCE(y, 42);
> >>> 
> >>> 	/* More code */
> >>> 
> >>> 	return 0;
> >>> }
> >> 
> >> The READ_ONCE() determines whether the WRITE_ONCE() will be executed at all,
> >> but the WRITE_ONCE() doesn't lie in the if condition's arm.
> > 
> > So in this case the LKMM would not recognize that there's a control 
> > dependency, even though it clearly exists.
> 
> Oh, that's unfortunate.
> 
> Then I would still argue that the "at all" definition is misleading. This

I agree, and I would welcome a patch improving the definition.  Perhaps 
something along the lines of what I wrote earlier in this email thread.

> time in the other direction as I had initially proposed though, as the above
> example is a case where "at all" holds true, but LKMM doesn't cover it. Or
> do you think that caveating this in litmus-tests.txt, e.g. via the patch we
> had recently worked out [1], is enough?

No, the explanation should be improved.

Alan

  reply	other threads:[~2022-06-27 14:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-15 11:43 [PATCH RFC] tools/memory-model: Adjust ctrl dependency definition Paul Heidekrüger
2022-06-15 14:16 ` Alan Stern
2022-06-21 11:59   ` Paul Heidekrüger
2022-06-21 14:24     ` Alan Stern
2022-06-27  9:47       ` Paul Heidekrüger
2022-06-27 14:56         ` Alan Stern [this message]
2022-07-15 12:27           ` Paul Heidekrüger
2022-07-15 13:27             ` Alan Stern
2022-07-15 15:21               ` Paul E. McKenney
2022-07-18  8:24                 ` Paul Heidekrüger

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=YrnFCSjESpeQdciv@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=Paul.Heidekrueger@in.tum.de \
    --cc=akiyks@gmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=charalampos.mainas@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=dlustig@nvidia.com \
    --cc=elver@google.com \
    --cc=j.alglave@ucl.ac.uk \
    --cc=joel@joelfernandes.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=luc.maranget@inria.fr \
    --cc=martin.fink@in.tum.de \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=npiggin@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=parri.andrea@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pramod.bhatotia@in.tum.de \
    --cc=s.s.chakraborty@tudelft.nl \
    --cc=trix@redhat.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).