Thread (19 messages) 19 messages, 6 authors, 2021-10-02

Re: [RFC PATCH] LKMM: Add ctrl_dep() macro for control dependency

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2021-09-29 14:47:50
Also in: linux-toolchains, lkml

On Tue, Sep 28, 2021 at 2:15 PM Mathieu Desnoyers
[off-list ref] wrote:
Introduce the ctrl_dep macro in the generic headers, and use it
everywhere it appears relevant.
The control dependency is so subtle - just see our discussions - that
I really think every single use of it needs to have a comment about
why it's needed.

Right now, that patch seems to just sprinkle them more or less
randomly. That's absolutely not what I want. It will just mean that
other people start sprinkling them randomly even more, and nobody will
dare remove them.

So I'd literally want a comment about "this needs a control
dependency, because otherwise the compiler could merge the two
identical stores X and Y".

When you have a READ_ONCE() in the conditional, and a WRITE_ONCE() in
the statement protected by the conditional, there is *no* need to
randomly sprinkle noise that doesn't matter.

And if there *is* need ("look, we have that same store in both the if-
and the else-statement" or whatever), then say so, and state that
thing.

               Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help