Messages in this thread | | | From | Linus Torvalds <> | Date | Thu, 17 Mar 2022 16:31:19 -0700 | Subject | Re: [PATCH v5] x86: use builtins to read eflags |
| |
On Thu, Mar 17, 2022 at 4:25 PM Segher Boessenkool <segher@kernel.crashing.org> wrote: > > > I still think that from a sanity standpoint, it would be good to > > actually strengthen the semantics of "asm volatile" to literally act > > as - and be ordered with - volatile memory accesses. > > > > But I guess that's water under the bridge. > > That is what it has actually done since forever. See C 5.1.2.3. For > GCC, "asm volatile" has a side effect like in /2 there as well, as does > unspec_volatile (an internal GCC thing used to implement certain > builtins, among other things).
Oh, so two "asm volatile" statements _are_ in fact defined to be ordered wrt each other?
Because the gcc docs certainly don't say that ;(
Yeah, yeah, dead code can be removed, whether volatile or not. That's true of "*(volatile int *)x" too. It's not the dead code that is the interesting case, though..
Is this also well-defined ordering-wise:
asm volatile("do_something"); WRITE_ONCE(x, 1);
(where "WRITE_ONCE()" is that kernel macro that just uses a volatile pointer assignment to force the access)?
And could we get that documented?
Linus
| |