From: "Paul E. McKenney" <paulmck@kernel.org>
To: Florian Weimer <fw@deneb.enyo.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Segher Boessenkool <segher@kernel.crashing.org>,
Will Deacon <will@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Alan Stern <stern@rowland.harvard.edu>,
Andrea Parri <parri.andrea@gmail.com>,
Boqun Feng <boqun.feng@gmail.com>,
Nicholas Piggin <npiggin@gmail.com>,
David Howells <dhowells@redhat.com>,
j alglave <j.alglave@ucl.ac.uk>,
luc maranget <luc.maranget@inria.fr>, akiyks <akiyks@gmail.com>,
linux-toolchains <linux-toolchains@vger.kernel.org>,
linux-arch <linux-arch@vger.kernel.org>
Subject: Re: [RFC PATCH] LKMM: Add ctrl_dep() macro for control dependency
Date: Thu, 14 Oct 2021 09:23:11 -0700 [thread overview]
Message-ID: <20211014162311.GD880162@paulmck-ThinkPad-P17-Gen-1> (raw)
In-Reply-To: <87lf2v61k7.fsf@mid.deneb.enyo.de>
On Thu, Oct 14, 2021 at 05:58:16PM +0200, Florian Weimer wrote:
> * Paul E. McKenney:
>
> > On Sun, Oct 10, 2021 at 04:02:02PM +0200, Florian Weimer wrote:
> >> * Linus Torvalds:
> >>
> >> > On Fri, Oct 1, 2021 at 9:26 AM Florian Weimer <fweimer@redhat.com> wrote:
> >> >>
> >> >> Will any conditional branch do, or is it necessary that it depends in
> >> >> some way on the data read?
> >> >
> >> > The condition needs to be dependent on the read.
> >> >
> >> > (Easy way to see it: if the read isn't related to the conditional or
> >> > write data/address, the read could just be delayed to after the
> >> > condition and the store had been done).
> >>
> >> That entirely depends on how the hardware is specified to work. And
> >> the hardware could recognize certain patterns as always producing the
> >> same condition codes, e.g., AND with zero. Do such tests still count?
> >> It depends on what the specification says.
> >>
> >> What I really dislike about this: Operators like & and < now have side
> >> effects, and is no longer possible to reason about arithmetic
> >> expressions in isolation.
> >
> > Is there a reasonable syntax that might help with these issues?
>
> Is this really a problem of syntax?
No, but we seem to need some way to communicate the control-dependency's
ordering intent to the compiler. ;-)
> > Yes, I know, we for sure have conflicting constraints on "reasonable"
> > on copy on this email. What else is new? ;-)
> >
> > I could imagine a tag of some sort on the load and store, linking the
> > operations that needed to be ordered. You would also want that same
> > tag on any conditional operators along the way? Or would the presence
> > of the tags on the load and store suffice?
>
> If the load is assigned to a local variable whose address is not taken
> and which is only assigned this once, it could be used to label the
> store. Then the compiler checks if all paths from the load to the
> store feature a condition that depends on the local variable (where
> qualifying conditions probably depend on the architecture). If it
> can't prove that is the case, it emits a fake no-op condition that
> triggers the hardware barrier. This formulation has the advantage
> that it does not add side effects to operators like <. It even
> generalizes to different barrier-implying instructions besides
> conditional branches.
So something like this?
tagvar = READ_ONCE(a);
if (tagvar)
WRITE_ONCE_COND(b, 1, tagvar);
(This seems to me to be an eminently reasonable syntax.)
Or did I miss a turn in there somewhere?
> But I'm not sure if all this complexity will be a tangible improvement
> over just using that no-op condition all the time (whether implied by
> READ_ONCE, or in a separate ctrl_dep macro).
That is an excellent question. I have no idea what the answer is. ;-)
Thanx, Paul
next prev parent reply other threads:[~2021-10-14 16:23 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-28 21:15 [RFC PATCH] LKMM: Add ctrl_dep() macro for control dependency Mathieu Desnoyers
2021-09-29 12:06 ` Marco Elver
2021-10-01 15:45 ` Mathieu Desnoyers
2021-10-01 16:20 ` Linus Torvalds
2021-10-01 17:28 ` Mathieu Desnoyers
2021-10-01 18:18 ` Linus Torvalds
2021-09-29 12:28 ` Florian Weimer
2021-09-29 17:41 ` Segher Boessenkool
2021-09-29 19:46 ` Florian Weimer
2021-10-01 16:13 ` Mathieu Desnoyers
2021-10-01 16:26 ` Florian Weimer
2021-10-01 16:35 ` Linus Torvalds
2021-10-10 14:02 ` Florian Weimer
2021-10-14 0:01 ` Paul E. McKenney
2021-10-14 2:14 ` Alan Stern
2021-10-14 16:14 ` Paul E. McKenney
2021-10-14 15:58 ` Florian Weimer
2021-10-14 16:23 ` Paul E. McKenney [this message]
2021-10-14 18:19 ` Florian Weimer
2021-10-14 21:09 ` Paul E. McKenney
2021-10-14 22:36 ` Linus Torvalds
2021-09-30 13:28 ` Mathieu Desnoyers
2021-09-29 14:47 ` Linus Torvalds
2021-09-29 14:54 ` Linus Torvalds
2021-09-29 19:50 ` Mathieu Desnoyers
2021-09-29 20:13 ` Mathieu Desnoyers
2021-09-29 19:27 ` Mathieu Desnoyers
2021-09-29 22:14 ` Linus Torvalds
2021-09-29 21:47 ` Segher Boessenkool
2021-09-29 23:57 ` Paul E. McKenney
2021-10-01 15:28 ` Mathieu Desnoyers
2021-10-01 22:53 ` Paul E. McKenney
2021-10-01 19:10 ` Segher Boessenkool
2021-10-01 22:50 ` Paul E. McKenney
2021-10-02 14:29 ` 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:
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=20211014162311.GD880162@paulmck-ThinkPad-P17-Gen-1 \
--to=paulmck@kernel.org \
--cc=akiyks@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=dhowells@redhat.com \
--cc=fw@deneb.enyo.de \
--cc=j.alglave@ucl.ac.uk \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-toolchains@vger.kernel.org \
--cc=luc.maranget@inria.fr \
--cc=mathieu.desnoyers@efficios.com \
--cc=npiggin@gmail.com \
--cc=parri.andrea@gmail.com \
--cc=peterz@infradead.org \
--cc=segher@kernel.crashing.org \
--cc=stern@rowland.harvard.edu \
--cc=torvalds@linux-foundation.org \
--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).