Re: [PATCH 0/3] powerpc: Implement cmpxchg128()

From: Nysal Jan K.A.

Date: Thu Nov 26 2026 - 05:08:20 EST


On Wed, Nov 25, 2026 at 09:51:30AM -0800, Nick Desaulniers wrote:
> 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

I've opened one now and will add the link in v2 - https://github.com/llvm/llvm-project/issues/246292

Thanks
--Nysal