Messages in this thread | | | From | Linus Torvalds <> | Date | Thu, 19 Oct 2023 10:08:59 -0700 | Subject | Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() |
| |
On Thu, 19 Oct 2023 at 09:32, Uros Bizjak <ubizjak@gmail.com> wrote: > > Perhaps you will be interested in chapter 6.47.2.1, "Volatile" of GCC > manual that says: > > " Under certain circumstances, GCC may duplicate (or remove duplicates > of) your assembly code when optimizing." > > The compiler may re-materialize non-volatile asm in the same way it > may re-materialize arguments from non-volatile memory. To avoid this, > volatile asm is necessary when unstable memory arguments are accessed > using this_* variants.
That's disgusting. The whole (and only) point of rematerialization is as an optimization. When gcc doesn't know how expensive an inline asm is (and they can be very expensive indeed), doing remat on it would be an obvious mistake.
I think what you say is "we're technically allowed to do it, but we'd be crazy to *actually* do it".
The kernel does require a sane compiler. We will turn off options that make it do insane things - even when said insane things are allowed by a bad standard.
Do you actually have gcc code that rematerializes an inline asm?
Linus
| |