Re: [PATCH] locking/local_lock: Don't evaluate the per-CPU lock pointer if unused

From: Nick Desaulniers

Date: Tue Nov 24 2026 - 14:32:19 EST


On Tue, Nov 24, 2026 at 8:39 AM Sebastian Andrzej Siewior
<bigeasy@xxxxxxxxxxxxx> wrote:
>
> On 2026-11-23 13:52:09 [-0800], Nick Desaulniers wrote:
> > On Mon, Nov 23, 2026 at 1:23 PM Ard Biesheuvel <ardb@xxxxxxxxxx> wrote:
> > >
> > >
> > > On Mon, 23 Nov 2026, at 20:12, Nick Desaulniers wrote:
> > > > Very detailed commit message, but you kind of bury the lede here on
> > > > what the actual problem this patch is fixing *is*.
> > > >
> > >
> > > Apologies. I'll trim it down,
> > >
> > > The TL;DR is that non-volatile asm() statements with memory input
> > > operands are not elided by Clang if their output is never used.
> >
> > That's not a bug; both Clang and GCC behave that way.
> > https://godbolt.org/z/sEhec4oae
> >
> > (perhaps there is a clang bug somewhere, just trying to suss out if
> > there's something we need to fix here; forgive me for being pedantic
> > here)
>
> I see a
> movq %gs:this_cpu_off(%rip), %rXX
>
> on x86-64 with clang-21, not with gcc-16 for local_lock() and
> local_lock_nested_bh(). Are we hunting a clang bug or considering this
> patch?

Both; I'm just trying to better understand:
1. what is the actual point of the patch (see my "burying the lede"
comment upthread)
2. what issues on the clang side are outstanding and conspiring here.
I think a v2 with a revised commit message is good to go, though I
don't know if Ard saw (or ignored) my questions about the temporary or
casts? Ideally v2 adds git trailers for:

Link: https://github.com/llvm/llvm-project/issues/93449
Link: https://github.com/llvm/llvm-project/issues/245738

(Since if both of the above were fixed, this patch would be moot)
(I've assigned the second one to you, Bill, since you're "in the
neighborhood" (touching lots of related code in LLVM recently))
--
Thanks,
~Nick Desaulniers