[PATCH RFC cmpxchg 0/8] Provide emulation for one- and two-byte cmpxchg()

Paul E. McKenney
2024-04-01T21:39:21Z

Hello!

This series provides emulation functions for one-byte and two-byte
cmpxchg, and uses them for those architectures not supporting these
in hardware. The emulation is in terms of the fully ordered four-byte
cmpxchg() that is supplied by all of these architectures. These were
tested by making x86 forget that it can do these natively:

88a9b3f7a924 ("EXP arch/x86: Test one-byte cmpxchg emulation")

This commit is local to -rcu and is of course not intended for mainline.

If accepted, RCU Tasks will use this capability in place of the current
rcu_trc_cmpxchg_need_qs() open-coding of this emulation.

1. Add one-byte and two-byte cmpxchg() emulation functions.

2. sparc: Emulate one-byte and two-byte cmpxchg.

3. ARC: Emulate one-byte and two-byte cmpxchg.

4. csky: Emulate one-byte and two-byte cmpxchg.

5. sh: Emulate one-byte and two-byte cmpxchg.

6. xtensa: Emulate one-byte and two-byte cmpxchg.

7. parisc: Emulate two-byte cmpxchg.

8. riscv: Emulate one-byte and two-byte cmpxchg.

Thanx, Paul

------------------------------------------------------------------------

arch/Kconfig | 3 +
arch/arc/Kconfig | 1
arch/arc/include/asm/cmpxchg.h | 38 ++++++++++++++----
arch/csky/Kconfig | 1
arch/csky/include/asm/cmpxchg.h | 18 ++++++++
arch/parisc/Kconfig | 1
arch/parisc/include/asm/cmpxchg.h | 1
arch/riscv/Kconfig | 1
arch/riscv/include/asm/cmpxchg.h | 25 ++++++++++++
arch/sh/Kconfig | 1
arch/sh/include/asm/cmpxchg.h | 4 +
arch/sparc/Kconfig | 1
arch/sparc/include/asm/cmpxchg_32.h | 6 ++
arch/xtensa/Kconfig | 1
arch/xtensa/include/asm/cmpxchg.h | 3 +
include/linux/cmpxchg-emu.h | 16 +++++++
lib/Makefile | 1
lib/cmpxchg-emu.c | 74 ++++++++++++++++++++++++++++++++++++
18 files changed, 187 insertions(+), 9 deletions(-)