Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr()

From: Nadav Amit
Date: Wed Oct 18 2023 - 14:29:15 EST



> On Oct 18, 2023, at 9:08 PM, Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
>
> We can use alias to __seg_gs non-const memory, so the value can be
> accessed without asm. __barrier() will then force reload. Please note
> that any memory clobber, hidden inside asm will also force reload.

For the record, at the time I tried to find a creative solution to
have fine granularity barrier control. I looked into address-spaces,
pure and const function attributes, and use of the restrict keyword.

I did not find a better solution. The behavior of most of these
mechanisms was non-intuitive for me and inconsistent across compilers.

You may succeed where I have failed as you seem more familiar with
the compiler code, but be aware it is a rabbit hole...