Re: [PATCH 0/3] powerpc: Implement cmpxchg128()
From: Nick Desaulniers
Date: Wed Nov 25 2026 - 12:51:57 EST
On Wed, Nov 25, 2026 at 9:41 AM Nysal Jan K.A. <nysal@xxxxxxxxxxxxx> wrote:
>
> This series adds arch_cmpxchg128() and arch_cmpxchg128_local() for
> little-endian POWER8 and later, using lqarx/stqcx. This enables
> HAVE_CMPXCHG_DOUBLE and HAVE_ALIGNED_STRUCT_PAGE, which gives us:
>
> * SLUB's lockless __update_freelist_fast() path (avoiding slab_lock()).
> * kmalloc_nolock(), without which BPF task-local storage creation fails
> with -ENOMEM, and the selftests task_local_data_race and
> struct_ops_assoc (timer subtests) fail. BPF Arena kfuncs were changed
> to be callable from any context. kmalloc_nolock() replaced kvcalloc()
> in the arena allocation paths because kvcalloc() may sleep and take
> ordinary allocator locks, while kmalloc_nolock() can run in NMI or
> non-sleepable contexts.
>
> The lqarx and stqcx. instructions require the 128-bit operand to reside in
> a consecutive even/odd register pair. In the Power ISA, the operand uses
> big-endian register layout where the most significant and least
> significant 64 bits are in the even and odd registers respectively.
> Until now this could not be expressed in inline asm without hard
> register constraints [1].
>
> GCC now supports this through the PTI mode attribute [2,3] for PowerPC
> and it will be available in the upcoming GCC 17 release. Backports have
> landed in the GCC 14, 15 and 16 branches. GCC 16.2 is the first release
> which has PTI mode support. For older GCC releases and clang there is a
> fallback implementation with hard register constraints.
Is there a feature request in llvm's bug tracker? If so, can you link
to it? If not, can you please file one, then link to it?
https://github.com/llvm/llvm-project/issues
>
> Additionally, this series enables PPC_HAS_LBARX_LHARX for Power10, which
> was previously omitted in the Kconfig.
>
> [1] https://github.com/linuxppc/issues/issues/463
> [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106895
> [3] https://gcc.gnu.org/pipermail/gcc-patches/2026-April/712831.html
>
> Nysal Jan K.A. (3):
> powerpc: Add support for 128-bit cmpxchg
> powerpc: Implement 128-bit cmpxchg fallback
> powerpc: Enable lbarx/lharx for Power10
>
> arch/powerpc/Kconfig | 8 ++
> arch/powerpc/include/asm/cmpxchg.h | 100 +++++++++++++++++++++++++
> arch/powerpc/platforms/Kconfig.cputype | 4 +
> 3 files changed, 112 insertions(+)
>
>
> base-commit: 65e4fd942f72a9dba0e4e257290c4fa1aa756854
> --
> 2.52.0
>
--
Thanks,
~Nick Desaulniers