mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6] Add two-byte cmpxchg emulation and wire it into the architectures
@ 2026-09-11 19:25 Bradley Morgan
  2026-09-11 19:25 ` [PATCH 1/6] lib: Add two-byte cmpxchg emulation function Bradley Morgan
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Bradley Morgan @ 2026-09-11 19:25 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: frederic, neeraj.upadhyay, boqun, joelagnelf, rcu, Andrew Morton,
	Arnd Bergmann, linux-arch, Vineet Gupta, linux-snps-arc,
	Russell King, linux-arm-kernel, Guo Ren, linux-csky,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	Chris Zankel, Max Filippov, linux-kernel, brads

Paul McKenney asked me off list to add cmpxchg_emu_u16() next to
cmpxchg_emu_u8() and wire it into the architectures that use the
one byte emulation, arc, ARMv6, csky, sh and xtensa.

Patch 1 adds the function, the prototype, and renames the Kconfig
symbol to ARCH_NEED_CMPXCHG_1_2_EMU since it now gates both
emulations. Patches 2 through 6 add case 2 beside each existing
case 1, following each file's current style. The function body
follows the two byte implementation in Paul's April 2024 RFC
series, of which only the one byte part landed as commit
a88d970c8bb5 ("lib: Add one-byte emulation function").

Per Paul's note, Arnd Bergmann's platform removal series was
checked before analyzing the users. It removes the imx31 and
omap24xx CPU_ARM1136R0 selectors, but INTEGRATOR_CM1136JFS still
selects CPU_ARM1136R0 until its scheduled removal in early 2027,
so the ARMv6 path in patch 3 is still live. The arc !LLSC path
already handles any size because it reads and writes through the
typed pointer under the atomic_ops lock, so only the LLSC switch
gains case 2.

Verification. The union splice is endian independent because h[i]
sits at byte offset 2*i on both layouts and i is (addr & 2) / 2,
so the selected halfword always matches the caller's byte offset.
A host test ran 240 cases across both halfword offsets, matching
and mismatching compares, against a byte level reference model,
all passing. The function also compiles big endian for ARM, which
matters because sh is a big endian user. lib/cmpxchg-emu.o builds
for arm with CONFIG_CPU_V6 and a test instantiation of cmpxchg()
on a u16 resolves to cmpxchg_emu_u16. The remaining checkpatch
warnings are the volatile and long line ones that the merged
cmpxchg_emu_u8() lines already carry.

Bradley Morgan (6):
  lib: Add two-byte cmpxchg emulation function
  ARC: Emulate two-byte cmpxchg
  ARM: Emulate two-byte cmpxchg on ARMv6
  csky: Emulate two-byte cmpxchg
  sh: Emulate two-byte cmpxchg
  xtensa: Emulate two-byte cmpxchg

 arch/Kconfig                      |  2 +-
 arch/arc/Kconfig                  |  2 +-
 arch/arc/include/asm/cmpxchg.h    |  3 +++
 arch/arm/Kconfig                  |  2 +-
 arch/arm/include/asm/cmpxchg.h    |  3 +++
 arch/csky/Kconfig                 |  2 +-
 arch/csky/include/asm/cmpxchg.h   |  9 ++++++++
 arch/sh/Kconfig                   |  2 +-
 arch/sh/include/asm/cmpxchg.h     |  2 ++
 arch/xtensa/Kconfig               |  2 +-
 arch/xtensa/include/asm/cmpxchg.h |  1 +
 include/linux/cmpxchg-emu.h       |  1 +
 lib/Makefile                      |  2 +-
 lib/cmpxchg-emu.c                 | 35 ++++++++++++++++++++++++++++---
 14 files changed, 58 insertions(+), 10 deletions(-)

-- 
2.47.3


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

end of thread, other threads:[~2026-09-12 21:14 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 19:25 [PATCH 0/6] Add two-byte cmpxchg emulation and wire it into the architectures Bradley Morgan
2026-09-11 19:25 ` [PATCH 1/6] lib: Add two-byte cmpxchg emulation function Bradley Morgan
2026-09-11 22:10   ` David Laight
2026-09-11 22:13     ` Bradley Morgan
2026-09-11 23:09     ` Paul E. McKenney
2026-09-12  9:30       ` David Laight
2026-09-12 10:29         ` Bradley Morgan
2026-09-12 18:58         ` Paul E. McKenney
2026-09-12 21:11           ` Bradley Morgan
2026-09-11 19:25 ` [PATCH 2/6] ARC: Emulate two-byte cmpxchg Bradley Morgan
2026-09-11 19:25 ` [PATCH 3/6] ARM: Emulate two-byte cmpxchg on ARMv6 Bradley Morgan
2026-09-11 19:25 ` [PATCH 4/6] csky: Emulate two-byte cmpxchg Bradley Morgan
2026-09-11 19:25 ` [PATCH 5/6] sh: " Bradley Morgan
2026-09-11 19:25 ` [PATCH 6/6] xtensa: " Bradley Morgan
2026-09-11 20:17 ` [PATCH 0/6] Add two-byte cmpxchg emulation and wire it into the architectures Arnd Bergmann
2026-09-11 20:20   ` Bradley Morgan

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®