Re: [PATCH v2 RESEND] locking/lockref/x86: Enable ARCH_USE_CMPXCHG_LOCKREF for X86_CMPXCHG64

From: Linus Torvalds
Date: Sun Jul 03 2022 - 17:01:56 EST


On Sun, Jun 26, 2022 at 1:18 PM Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
>
> Also, by using try_cmpxchg64() instead of cmpxchg64()
> in CMPXCHG_LOOP macro, the compiler actually produces sane code,
> improving lockref_get_or_lock main loop from:

Heh. I'm actually looking at that function because I committed my "add
sparse annotation for conditional locking" patch, and
lockref_get_or_lock() has the wrong "polarity" for conditional locking
(it returns false when it takes the lock).

But then I started looking closer, and that function has no users any
more. In fact, it hasn't had users since back in 2013.

So while I still think ARCH_USE_CMPXCHG_LOCKREF is fine for 32-bit
x86, the part about improving lockref_get_or_lock() code generation is
kind of pointless. I'm going to remove that function as "unused, and
with the wrong return value".

Linus