lockref scalability on x86-64 vs cpu_relax

Linus Torvalds torvalds at linux-foundation.org
Fri Jan 13 15:15:22 AEDT 2023


On Thu, Jan 12, 2023 at 9:20 PM Nicholas Piggin <npiggin at gmail.com> wrote:
>
> Actually what we'd really want is an arch specific implementation of
> lockref.

The problem is mainly that then you need to generate the asm versions
of all those different CMPXCHG_LOOP()  variants.

They are all fairly simple, though, and it woudln't be hard to make
the current lib/lockref.c just be the generic fallback if you don't
have an arch-specific one.

And even if you do have the arch-specific LL/SC version, you'd still
want the generic fallback for the case where a spinlock isn't a single
word any more (which happens when the spinlock debugging options are
on).

            Linus


More information about the Linuxppc-dev mailing list