public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/3] rust: Add xchg and cmpxchg support on i8/i16
@ 2025-12-28 12:05 FUJITA Tomonori
  2025-12-28 12:05 ` [PATCH v1 1/3] rust: sync: atomic: Prepare AtomicOps macros for i8/i16 support FUJITA Tomonori
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: FUJITA Tomonori @ 2025-12-28 12:05 UTC (permalink / raw)
  To: boqun.feng, ojeda
  Cc: a.hindborg, aliceryhl, bjorn3_gh, dakr, gary, lossin, tmgross,
	acourbot, rust-for-linux, linux-arch

This series extends the Rust atomic internal to support i8 and i16
exchange operations (xchg and cmpxchg), in addition to the existing
i32/i64 support.

The macro structure is specialized around i32/i64 so i8/i16 has a
separate path for Basic operations only.

This series generalizes the existing declare_and_impl_atomic_methods!
macro so it can generate implementations for multiple backends via a
type-to-C-backend mapping, and uses that to add i8/i16 support for
AtomicBasicOps (load/store) and AtomicExchangeOps (xchg/cmpxchg).

With these changes in place, the i8/i16-only
impl_atomic_only_load_and_store_ops macro becomes redundant and is
removed.

AtomicArithmeticOps for i8/i16 isn't addressed here. There is no
corresponding C API for i8/i16 arithmetic atomics. Adding arithmetic
support in Rust would require a Rust-defined implementation that is
consistent with the kernel's atomic semantics and the LKMM
expectations. That direction would move away from the current design
approach of "using LKMM-backed C atomics for Rust code", and I'm not
sure yet whether we should provide i8/i16 arithmetic atomics.

This series depends on the i8/i16 cmpxchg helpers series [1].

[1] https://lore.kernel.org/all/20251227115951.1424458-1-fujita.tomonori@gmail.com/

FUJITA Tomonori (3):
  rust: sync: atomic: Prepare AtomicOps macros for i8/i16 support
  rust: sync: atomic: Remove workaround macro for i8/i16 BasicOps
  rust: sync: atomic: Add i8/i16 xchg and cmpxchg support

 rust/helpers/atomic_ext.c            |  16 ++--
 rust/kernel/sync/atomic/internal.rs  | 131 ++++++++++++++-------------
 rust/kernel/sync/atomic/predefine.rs |   4 +-
 3 files changed, 76 insertions(+), 75 deletions(-)


base-commit: e24011042180d038293182de25eaaa21b8829050
-- 
2.43.0


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

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

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-28 12:05 [PATCH v1 0/3] rust: Add xchg and cmpxchg support on i8/i16 FUJITA Tomonori
2025-12-28 12:05 ` [PATCH v1 1/3] rust: sync: atomic: Prepare AtomicOps macros for i8/i16 support FUJITA Tomonori
2025-12-29 11:13   ` Boqun Feng
2025-12-29 11:54     ` FUJITA Tomonori
2025-12-29 16:36     ` Gary Guo
2025-12-30  0:17       ` Boqun Feng
2026-01-02 11:25         ` Gary Guo
2025-12-28 12:05 ` [PATCH v1 2/3] rust: sync: atomic: Remove workaround macro for i8/i16 BasicOps FUJITA Tomonori
2025-12-29 11:58   ` Boqun Feng
2025-12-29 12:55     ` FUJITA Tomonori
2025-12-29 13:19       ` Boqun Feng
2025-12-28 12:05 ` [PATCH v1 3/3] rust: sync: atomic: Add i8/i16 xchg and cmpxchg support FUJITA Tomonori
2025-12-29 12:27   ` Boqun Feng
2025-12-29 12:30     ` Boqun Feng
2025-12-29 13:04       ` FUJITA Tomonori
2025-12-29 13:13         ` Boqun Feng

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