mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/5] Add two-byte cmpxchg emulation and wire it into the architectures
@ 2026-09-17 16:38 Bradley Morgan
  2026-09-17 16:38 ` [PATCH v3 1/5] lib: Add two-byte cmpxchg emulation function Bradley Morgan
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Bradley Morgan @ 2026-09-17 16:38 UTC (permalink / raw)
  To: Andrew Morton, Vineet Gupta, Guo Ren, Yoshinori Sato,
	Rich Felker, Chris Zankel, Max Filippov
  Cc: Arnd Bergmann, Paul E . McKenney, David Laight,
	John Paul Adrian Glaubitz, linux-snps-arc, linux-csky, linux-sh,
	linux-kernel, Bradley Morgan

This is v3 of the two byte cmpxchg emulation series, wiring
cmpxchg_emu_u16() into arc, csky, sh and xtensa.

v2 tried u16 as the parameter type. David Laight pointed out that
this does not compile warning free when exchanging a pointer type,
because the switch statements in the architecture macros instantiate
every size case, so a pointer cmpxchg() type checks the two byte
case, and the (u16) casts there warn. v3 takes the old and new
values as unsigned long and casts to u16 inside the function, so the
call sites need no narrowing casts and pointer exchanges compile
clean. The function still compares and returns exactly the 16 bits
of the emulated halfword, which matches hardware cmpxchg r16
behaviour, and a host test of 972 cases across both halfword offsets
against a byte level reference model still passes.

David also noted the missing pointer to integer type check in some
of the macros, so cmpxchg(&p, 4, 5) compiled silently. The csky
macros typed __old and __new through __typeof__(old), which skips
the check, and sh had none either. Both now type check through
(unsigned long)(0 ? *(ptr) : (old)), the idiom David suggested,
which keeps the pointer to integer conversion explicit while making
the compiler reject mismatched types. Both of his test cases now
fail to compile on every macro shape.

The ARMv6 wiring stays dropped from v1, per Arnd Bergmann's offer to
take the INTEGRATOR_CM1136JFS cleanup in his platform removal series.

Thank you, Paul McKenney for suggesting this, and David Laight and
Arnd Bergmann for the review that shaped all three revisions.

Bradley Morgan (5):
  lib: Add two-byte cmpxchg emulation function
  ARC: Emulate two-byte cmpxchg
  csky: Emulate two-byte cmpxchg
  sh: Emulate two-byte cmpxchg
  xtensa: Emulate two-byte cmpxchg
-- 
2.47.3


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

end of thread, other threads:[~2026-09-18  9:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 16:38 [PATCH v3 0/5] Add two-byte cmpxchg emulation and wire it into the architectures Bradley Morgan
2026-09-17 16:38 ` [PATCH v3 1/5] lib: Add two-byte cmpxchg emulation function Bradley Morgan
2026-09-18  8:59   ` David Laight
2026-09-17 16:38 ` [PATCH v3 2/5] ARC: Emulate two-byte cmpxchg Bradley Morgan
2026-09-17 16:38 ` [PATCH v3 3/5] csky: " Bradley Morgan
2026-09-17 16:38 ` [PATCH v3 4/5] sh: " Bradley Morgan
2026-09-17 16:38 ` [PATCH v3 5/5] xtensa: " Bradley Morgan
2026-09-17 16:42   ` Bradley Morgan
2026-09-18  9:10 ` [PATCH v3 0/5] Add two-byte cmpxchg emulation and wire it into the architectures David Laight

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®