mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] powerpc: Implement cmpxchg128()
@ 2026-11-25 17:40 Nysal Jan K.A.
  2026-11-25 17:40 ` [PATCH 1/3] powerpc: Add support for 128-bit cmpxchg Nysal Jan K.A.
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nysal Jan K.A. @ 2026-11-25 17:40 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Jeevitha Palanisamy, Nysal Jan K.A.,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Ritesh Harjani (IBM),
	Shrikanth Hegde, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Andrew Morton,
	David Hildenbrand (Arm),
	SJ Park, Usama Arif, Kevin Brodsky, Kiryl Shutsemau (Meta),
	linux-kernel, llvm

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.

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-25 17:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 17:40 [PATCH 0/3] powerpc: Implement cmpxchg128() Nysal Jan K.A.
2026-11-25 17:40 ` [PATCH 1/3] powerpc: Add support for 128-bit cmpxchg Nysal Jan K.A.
2026-11-25 17:40 ` [PATCH 2/3] powerpc: Implement 128-bit cmpxchg fallback Nysal Jan K.A.
2026-11-25 17:40 ` [PATCH 3/3] powerpc: Enable lbarx/lharx for Power10 Nysal Jan K.A.
2026-11-25 17:51 ` [PATCH 0/3] powerpc: Implement cmpxchg128() Nick Desaulniers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®