[PATCH v3 cmpxchg 0/4] Provide emulation for one--byte cmpxchg()

From: Paul E. McKenney
Date: Tue Jun 04 2024 - 13:02:36 EST


Hello!

This v3 series uses one-byte cmpxchg emulation for those architectures
that do not support this in hardware and that are not already using this
emulation. The emulation is in terms of the fully ordered four-byte
cmpxchg() that is supplied by all of these architectures. This was
tested by the csky commit already in mainline and by making x86 forget
that it can do one-byte cmpxchg() natively:

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

This x86 commit has since been dropped from RCU in favor of the
aforementioned csky commit in mainline.

Once one-byte cmpxchg emulation patches are in mainline for all remaining
architectures in need of it, RCU Tasks will use one-byte cmpxchg()
in place of the current rcu_trc_cmpxchg_need_qs() open-coding of this
emulation.

The remaining patches are as follows:

1. ARC: Emulate one-byte cmpxchg.

2. Emulate one-byte cmpxchg.

3. Emulate one-byte cmpxchg.

4. ARM: Emulate one-byte cmpxchg.

Changes since v2:

o Dropped the sparc32, parisc, lib, and csky patches due to their
having been accepted into mainline.

o Added a 32-bit ARM patch for systems with v6 and earlier CPUs.

o Apply other feedback from review and testing.

Changes since v1:

o Dropped riscv patch in favor of alternative patch that
provides native support.

o Fixed yet more casting bugs spotted by kernel test robot
and by Geert Uytterhoeven.

Changes since RFC:

o Add native support for sparc32 and parisc, courtesy of Al Viro.

o Remove two-byte emulation due to architectures that still do not
support two-byte load and store instructions, per Arnd Bergmann
feedback. (Yes, there are a few systems out there that do not
even support one-byte load instructions, but these are slated
for removal anyway.)

o Fix numerous casting bugs spotted by kernel test robot.

o Fix SPDX header. "//" for .c files and "/*" for .h files.
I am sure that there is a good reason for this. ;-)

Thanx, Paul

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

arc/Kconfig | 1 +
arc/include/asm/cmpxchg.h | 33 ++++++++++++++++++++++++---------
arm/Kconfig | 1 +
arm/include/asm/cmpxchg.h | 7 ++++++-
sh/Kconfig | 1 +
sh/include/asm/cmpxchg.h | 3 +++
xtensa/Kconfig | 1 +
xtensa/include/asm/cmpxchg.h | 2 ++
8 files changed, 39 insertions(+), 10 deletions(-)