[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260127185424.39d801ea@pumpkin>
Date: Tue, 27 Jan 2026 18:54:24 +0000
From: David Laight <david.laight.linux@...il.com>
To: Marco Elver <elver@...gle.com>
Cc: Arnd Bergmann <arnd@...db.de>, Peter Zijlstra <peterz@...radead.org>,
Will Deacon <will@...nel.org>, Ingo Molnar <mingo@...nel.org>, Thomas
Gleixner <tglx@...utronix.de>, Boqun Feng <boqun.feng@...il.com>, Waiman
Long <longman@...hat.com>, Bart Van Assche <bvanassche@....org>,
llvm@...ts.linux.dev, Catalin Marinas <catalin.marinas@....com>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] arm64: Optimize __READ_ONCE() with CONFIG_LTO=y
On Tue, 27 Jan 2026 16:04:45 +0100
Marco Elver <elver@...gle.com> wrote:
...
> I think the bigger issue was 'volatile': "Passing a volatile-qualified
> pointer to READ_ONCE() is an absolute
> trainwreck for code generation [...]" per dee081bf8f82.
>
> While the above with the temporary is gone for the asm-generic
> version, the arm64 LTO still has the temporary and we need some
> qualifier-stripping helper.
I've done some real experiments, see https://www.godbolt.org/z/n9f91dGe3
If you don't strip the volatile you get a 'trainwreck'.
Visible on godbolt for the short sub-structure function f_v_s().
Fixable using __unqual_typeof__().
But the code for anything over 8 bytes is also a trainwreck.
eg: for an int[4] in a sub-structure:
return __READ_ONCE(s->s_i).i[2];
f_s_i:
sub sp, sp, #16
ldr x8, [x0, #56]
str x8, [sp, #8]
ldr w8, [x0, #64]
str w8, [sp, #4]
ldr w9, [x0, #68]
mov w0, w8
str w9, [sp], #16
ret
(The same code for a char[4] is fine...)
For integral types you can get a variable of the unqualified
type with:
auto v = (typeof(x))0;
but that doesn't help here because the code needs to read short structures.
For long structures member by member access will give better code.
I'm not sure they should be allowed.
(and there may not be any.)
David
Powered by blists - more mailing lists