* [PATCH v3 0/4] rust: Add i8 and i16 atomic support
@ 2025-12-11 11:38 FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 1/4] rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release helpers FUJITA Tomonori
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: FUJITA Tomonori @ 2025-12-11 11:38 UTC (permalink / raw)
To: boqun.feng, ojeda, peterz, will
Cc: acourbot, a.hindborg, aliceryhl, bjorn3_gh, dakr, gary, lossin,
mark.rutland, tmgross, rust-for-linux
This adds Atomic<i8> and Atomic<i16> support; including
load/store(Relaxed) and load(Acquire)/store(Release) operations.
Relaxed operations are implemented in C's READ_ONCE() and
WRITE_ONCE() macros.
load(Acquire)/store(Release) use C's smp_load_acquire() and
smp_store_release() macros. They internally use the appropriate
architecture-specific instructions.
v3:
- Move i8/i16 AtomicImp next to i32/i64 with the comments updated
- Add a comment about leaving the existing macros untouched
- Add __rust_helper for helpers
- Update commit messages about atomic_ext.c instead of atomic.c
v2: https://lore.kernel.org/rust-for-linux/20251117001035.4068507-1-fujita.tomonori@gmail.com/
- Implement relaxed operations by using C's READ_ONCE/WRITE_ONCE
- Rename smp_load_acquire() and smp_store_release() helpers
- Simplify the macro to generate atomic methods
v1: https://lore.kernel.org/rust-for-linux/20251115050305.3872412-1-fujita.tomonori@gmail.com/
FUJITA Tomonori (4):
rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release
helpers
rust: helpers: Add i8/i16 relaxed atomic helpers
rust: sync: atomic: Add i8/i16 load and store support
rust: sync: atomic: Add store_release/load_acquire tests
rust/helpers/atomic_ext.c | 44 ++++++++++++++++++
rust/helpers/helpers.c | 1 +
rust/kernel/sync/atomic/internal.rs | 69 ++++++++++++++++++++++++++--
rust/kernel/sync/atomic/predefine.rs | 24 +++++++++-
4 files changed, 132 insertions(+), 6 deletions(-)
create mode 100644 rust/helpers/atomic_ext.c
base-commit: d358e5254674b70f34c847715ca509e46eb81e6f
--
2.43.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 1/4] rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release helpers
2025-12-11 11:38 [PATCH v3 0/4] rust: Add i8 and i16 atomic support FUJITA Tomonori
@ 2025-12-11 11:38 ` FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 2/4] rust: helpers: Add i8/i16 relaxed atomic helpers FUJITA Tomonori
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: FUJITA Tomonori @ 2025-12-11 11:38 UTC (permalink / raw)
To: boqun.feng, ojeda, peterz, will
Cc: acourbot, a.hindborg, aliceryhl, bjorn3_gh, dakr, gary, lossin,
mark.rutland, tmgross, rust-for-linux
Add helper functions to expose smp_load_acquire() and
smp_store_release() for i8 and i16 types.
The smp_load_acquire() and smp_store_release() macros require type
information (sizeof) to generate appropriate architecture-specific
memory ordering instructions. Therefore, separate helper functions are
needed for each type size.
These helpers expose different symbol names than their C counterparts
so they are split into atomic_ext.c instead of atomic.c. The symbol
names; atomic_[i8|i16]_load_acquire and atomic_[i8|i16]_store_release
makes the interface Rust/C clear, consistent with i32/i64.
These helpers will be used by the upcoming Atomic<i8> and Atomic<i16>
implementation to provide proper Acquire/Release semantics across all
architectures.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
rust/helpers/atomic_ext.c | 23 +++++++++++++++++++++++
rust/helpers/helpers.c | 1 +
2 files changed, 24 insertions(+)
create mode 100644 rust/helpers/atomic_ext.c
diff --git a/rust/helpers/atomic_ext.c b/rust/helpers/atomic_ext.c
new file mode 100644
index 000000000000..a10c723ab224
--- /dev/null
+++ b/rust/helpers/atomic_ext.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <asm/barrier.h>
+
+__rust_helper s8 rust_helper_atomic_i8_load_acquire(s8 *ptr)
+{
+ return smp_load_acquire(ptr);
+}
+
+__rust_helper s16 rust_helper_atomic_i16_load_acquire(s16 *ptr)
+{
+ return smp_load_acquire(ptr);
+}
+
+__rust_helper void rust_helper_atomic_i8_store_release(s8 *ptr, s8 val)
+{
+ smp_store_release(ptr, val);
+}
+
+__rust_helper void rust_helper_atomic_i16_store_release(s16 *ptr, s16 val)
+{
+ smp_store_release(ptr, val);
+}
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index 79c72762ad9c..15d75578f459 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -8,6 +8,7 @@
*/
#include "atomic.c"
+#include "atomic_ext.c"
#include "auxiliary.c"
#include "barrier.c"
#include "binder.c"
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 2/4] rust: helpers: Add i8/i16 relaxed atomic helpers
2025-12-11 11:38 [PATCH v3 0/4] rust: Add i8 and i16 atomic support FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 1/4] rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release helpers FUJITA Tomonori
@ 2025-12-11 11:38 ` FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 3/4] rust: sync: atomic: Add i8/i16 load and store support FUJITA Tomonori
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: FUJITA Tomonori @ 2025-12-11 11:38 UTC (permalink / raw)
To: boqun.feng, ojeda, peterz, will
Cc: acourbot, a.hindborg, aliceryhl, bjorn3_gh, dakr, gary, lossin,
mark.rutland, tmgross, rust-for-linux
Add READ_ONCE/WRITE_ONCE based helpers for i8 and i16 types to support
relaxed atomic operations in Rust.
While relaxed operations could be implemented purely in Rust using
read_volatile() and write_volatile(), using C's READ_ONCE() and
WRITE_ONCE() macros ensures complete consistency with the kernel
memory model.
These helpers expose different symbol names than their C counterparts
so they are split into atomic_ext.c instead of atomic.c. The symbol
names; the names make the interface Rust/C clear, consistent with
i32/i64.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
rust/helpers/atomic_ext.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/rust/helpers/atomic_ext.c b/rust/helpers/atomic_ext.c
index a10c723ab224..fedf808383e0 100644
--- a/rust/helpers/atomic_ext.c
+++ b/rust/helpers/atomic_ext.c
@@ -1,22 +1,43 @@
// SPDX-License-Identifier: GPL-2.0
#include <asm/barrier.h>
+#include <asm/rwonce.h>
+
+__rust_helper s8 rust_helper_atomic_i8_load(s8 *ptr)
+{
+ return READ_ONCE(*ptr);
+}
__rust_helper s8 rust_helper_atomic_i8_load_acquire(s8 *ptr)
{
return smp_load_acquire(ptr);
}
+__rust_helper s16 rust_helper_atomic_i16_load(s16 *ptr)
+{
+ return READ_ONCE(*ptr);
+}
+
__rust_helper s16 rust_helper_atomic_i16_load_acquire(s16 *ptr)
{
return smp_load_acquire(ptr);
}
+__rust_helper void rust_helper_atomic_i8_store(s8 *ptr, s8 val)
+{
+ WRITE_ONCE(*ptr, val);
+}
+
__rust_helper void rust_helper_atomic_i8_store_release(s8 *ptr, s8 val)
{
smp_store_release(ptr, val);
}
+__rust_helper void rust_helper_atomic_i16_store(s16 *ptr, s16 val)
+{
+ WRITE_ONCE(*ptr, val);
+}
+
__rust_helper void rust_helper_atomic_i16_store_release(s16 *ptr, s16 val)
{
smp_store_release(ptr, val);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 3/4] rust: sync: atomic: Add i8/i16 load and store support
2025-12-11 11:38 [PATCH v3 0/4] rust: Add i8 and i16 atomic support FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 1/4] rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release helpers FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 2/4] rust: helpers: Add i8/i16 relaxed atomic helpers FUJITA Tomonori
@ 2025-12-11 11:38 ` FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 4/4] rust: sync: atomic: Add store_release/load_acquire tests FUJITA Tomonori
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: FUJITA Tomonori @ 2025-12-11 11:38 UTC (permalink / raw)
To: boqun.feng, ojeda, peterz, will
Cc: acourbot, a.hindborg, aliceryhl, bjorn3_gh, dakr, gary, lossin,
mark.rutland, tmgross, rust-for-linux
Add atomic operation support for i8 and i16 types using volatile
read/write and smp_load_acquire/smp_store_release helpers.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
rust/kernel/sync/atomic/internal.rs | 69 ++++++++++++++++++++++++++--
rust/kernel/sync/atomic/predefine.rs | 14 +++++-
2 files changed, 77 insertions(+), 6 deletions(-)
diff --git a/rust/kernel/sync/atomic/internal.rs b/rust/kernel/sync/atomic/internal.rs
index 6fdd8e59f45b..51c5750d7986 100644
--- a/rust/kernel/sync/atomic/internal.rs
+++ b/rust/kernel/sync/atomic/internal.rs
@@ -13,17 +13,22 @@ mod private {
pub trait Sealed {}
}
-// `i32` and `i64` are only supported atomic implementations.
+// The C side supports atomic primitives only for `i32` and `i64` (`atomic_t` and `atomic64_t`),
+// while the Rust side also layers provides atomic support for `i8` and `i16`
+// on top of lower-level C primitives.
+impl private::Sealed for i8 {}
+impl private::Sealed for i16 {}
impl private::Sealed for i32 {}
impl private::Sealed for i64 {}
/// A marker trait for types that implement atomic operations with C side primitives.
///
-/// This trait is sealed, and only types that have directly mapping to the C side atomics should
-/// impl this:
+/// This trait is sealed, and only types that map directly to the C side atomics
+/// or can be implemented with lower-level C primitives are allowed to implement this:
///
-/// - `i32` maps to `atomic_t`.
-/// - `i64` maps to `atomic64_t`.
+/// - `i8` and `i16` are implemented with lower-level C primitives.
+/// - `i32` map to `atomic_t`
+/// - `i64` map to `atomic64_t`
pub trait AtomicImpl: Sized + Send + Copy + private::Sealed {
/// The type of the delta in arithmetic or logical operations.
///
@@ -32,6 +37,14 @@ pub trait AtomicImpl: Sized + Send + Copy + private::Sealed {
type Delta;
}
+impl AtomicImpl for i8 {
+ type Delta = Self;
+}
+
+impl AtomicImpl for i16 {
+ type Delta = Self;
+}
+
// `atomic_t` implements atomic operations on `i32`.
impl AtomicImpl for i32 {
type Delta = Self;
@@ -215,6 +228,15 @@ fn set[release](a: &AtomicRepr<Self>, v: Self) {
}
);
+// It is still unclear whether i8/i16 atomics will eventually support
+// the same set of operations as i32/i64, because some architectures
+// do not provide hardware support for the required atomic primitives.
+// Furthermore, supporting Atomic<bool> will require even more
+// significant structural changes.
+//
+// To avoid premature refactoring, a separate macro for i8 and i16 is
+// used for now, leaving the existing macros untouched until the overall
+// design requirements are settled.
declare_and_impl_atomic_methods!(
/// Exchange and compare-and-exchange atomic operations
pub trait AtomicExchangeOps {
@@ -263,3 +285,40 @@ fn fetch_add[acquire, release, relaxed](a: &AtomicRepr<Self>, v: Self::Delta) ->
}
}
);
+
+macro_rules! impl_atomic_only_load_and_store_ops {
+ ($($ty:ty),* $(,)?) => {
+ $(
+ impl AtomicBasicOps for $ty {
+ paste! {
+ #[inline(always)]
+ fn atomic_read(a: &AtomicRepr<Self>) -> Self {
+ // SAFETY: `a.as_ptr()` is valid and properly aligned.
+ unsafe { bindings::[< atomic_ $ty _load >](a.as_ptr().cast()) }
+ }
+
+ #[inline(always)]
+ fn atomic_read_acquire(a: &AtomicRepr<Self>) -> Self {
+ // SAFETY: `a.as_ptr()` is valid and properly aligned.
+ unsafe { bindings::[< atomic_ $ty _load_acquire >](a.as_ptr().cast()) }
+ }
+
+ // Generate atomic_set and atomic_set_release
+ #[inline(always)]
+ fn atomic_set(a: &AtomicRepr<Self>, v: Self) {
+ // SAFETY: `a.as_ptr()` is valid and properly aligned.
+ unsafe { bindings::[< atomic_ $ty _store >](a.as_ptr().cast(), v) }
+ }
+
+ #[inline(always)]
+ fn atomic_set_release(a: &AtomicRepr<Self>, v: Self) {
+ // SAFETY: `a.as_ptr()` is valid and properly aligned.
+ unsafe { bindings::[< atomic_ $ty _store_release >](a.as_ptr().cast(), v) }
+ }
+ }
+ }
+ )*
+ };
+}
+
+impl_atomic_only_load_and_store_ops!(i8, i16);
diff --git a/rust/kernel/sync/atomic/predefine.rs b/rust/kernel/sync/atomic/predefine.rs
index 45a17985cda4..09b357be59b8 100644
--- a/rust/kernel/sync/atomic/predefine.rs
+++ b/rust/kernel/sync/atomic/predefine.rs
@@ -5,6 +5,18 @@
use crate::static_assert;
use core::mem::{align_of, size_of};
+// SAFETY: `i8` has the same size and alignment with itself, and is round-trip transmutable to
+// itself.
+unsafe impl super::AtomicType for i8 {
+ type Repr = i8;
+}
+
+// SAFETY: `i16` has the same size and alignment with itself, and is round-trip transmutable to
+// itself.
+unsafe impl super::AtomicType for i16 {
+ type Repr = i16;
+}
+
// SAFETY: `i32` has the same size and alignment with itself, and is round-trip transmutable to
// itself.
unsafe impl super::AtomicType for i32 {
@@ -118,7 +130,7 @@ macro_rules! for_each_type {
#[test]
fn atomic_basic_tests() {
- for_each_type!(42 in [i32, i64, u32, u64, isize, usize] |v| {
+ for_each_type!(42 in [i8, i16, i32, i64, u32, u64, isize, usize] |v| {
let x = Atomic::new(v);
assert_eq!(v, x.load(Relaxed));
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 4/4] rust: sync: atomic: Add store_release/load_acquire tests
2025-12-11 11:38 [PATCH v3 0/4] rust: Add i8 and i16 atomic support FUJITA Tomonori
` (2 preceding siblings ...)
2025-12-11 11:38 ` [PATCH v3 3/4] rust: sync: atomic: Add i8/i16 load and store support FUJITA Tomonori
@ 2025-12-11 11:38 ` FUJITA Tomonori
2025-12-11 16:49 ` [PATCH v3 0/4] rust: Add i8 and i16 atomic support Joel Fernandes
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: FUJITA Tomonori @ 2025-12-11 11:38 UTC (permalink / raw)
To: boqun.feng, ojeda, peterz, will
Cc: acourbot, a.hindborg, aliceryhl, bjorn3_gh, dakr, gary, lossin,
mark.rutland, tmgross, rust-for-linux
Add minimum store_release/load_acquire tests.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
rust/kernel/sync/atomic/predefine.rs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/rust/kernel/sync/atomic/predefine.rs b/rust/kernel/sync/atomic/predefine.rs
index 09b357be59b8..51e9df0cf56e 100644
--- a/rust/kernel/sync/atomic/predefine.rs
+++ b/rust/kernel/sync/atomic/predefine.rs
@@ -137,6 +137,16 @@ fn atomic_basic_tests() {
});
}
+ #[test]
+ fn atomic_acquire_release_tests() {
+ for_each_type!(42 in [i8, i16, i32, i64, u32, u64, isize, usize] |v| {
+ let x = Atomic::new(0);
+
+ x.store(v, Release);
+ assert_eq!(v, x.load(Acquire));
+ });
+ }
+
#[test]
fn atomic_xchg_tests() {
for_each_type!(42 in [i32, i64, u32, u64, isize, usize] |v| {
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 0/4] rust: Add i8 and i16 atomic support
2025-12-11 11:38 [PATCH v3 0/4] rust: Add i8 and i16 atomic support FUJITA Tomonori
` (3 preceding siblings ...)
2025-12-11 11:38 ` [PATCH v3 4/4] rust: sync: atomic: Add store_release/load_acquire tests FUJITA Tomonori
@ 2025-12-11 16:49 ` Joel Fernandes
2025-12-11 17:37 ` Gary Guo
2025-12-14 21:54 ` Boqun Feng
6 siblings, 0 replies; 9+ messages in thread
From: Joel Fernandes @ 2025-12-11 16:49 UTC (permalink / raw)
To: FUJITA Tomonori
Cc: boqun.feng, ojeda, peterz, will, acourbot, a.hindborg, aliceryhl,
bjorn3_gh, dakr, gary, lossin, mark.rutland, tmgross,
rust-for-linux
On Thu, Dec 11, 2025 at 08:38:22PM +0900, FUJITA Tomonori wrote:
> This adds Atomic<i8> and Atomic<i16> support; including
> load/store(Relaxed) and load(Acquire)/store(Release) operations.
>
> Relaxed operations are implemented in C's READ_ONCE() and
> WRITE_ONCE() macros.
>
> load(Acquire)/store(Release) use C's smp_load_acquire() and
> smp_store_release() macros. They internally use the appropriate
> architecture-specific instructions.
>
> v3:
> - Move i8/i16 AtomicImp next to i32/i64 with the comments updated
> - Add a comment about leaving the existing macros untouched
> - Add __rust_helper for helpers
> - Update commit messages about atomic_ext.c instead of atomic.c
> v2: https://lore.kernel.org/rust-for-linux/20251117001035.4068507-1-fujita.tomonori@gmail.com/
> - Implement relaxed operations by using C's READ_ONCE/WRITE_ONCE
> - Rename smp_load_acquire() and smp_store_release() helpers
> - Simplify the macro to generate atomic methods
> v1: https://lore.kernel.org/rust-for-linux/20251115050305.3872412-1-fujita.tomonori@gmail.com/
>
> FUJITA Tomonori (4):
> rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release
> helpers
> rust: helpers: Add i8/i16 relaxed atomic helpers
> rust: sync: atomic: Add i8/i16 load and store support
> rust: sync: atomic: Add store_release/load_acquire tests
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
thanks,
- Joel
>
> rust/helpers/atomic_ext.c | 44 ++++++++++++++++++
> rust/helpers/helpers.c | 1 +
> rust/kernel/sync/atomic/internal.rs | 69 ++++++++++++++++++++++++++--
> rust/kernel/sync/atomic/predefine.rs | 24 +++++++++-
> 4 files changed, 132 insertions(+), 6 deletions(-)
> create mode 100644 rust/helpers/atomic_ext.c
>
>
> base-commit: d358e5254674b70f34c847715ca509e46eb81e6f
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 0/4] rust: Add i8 and i16 atomic support
2025-12-11 11:38 [PATCH v3 0/4] rust: Add i8 and i16 atomic support FUJITA Tomonori
` (4 preceding siblings ...)
2025-12-11 16:49 ` [PATCH v3 0/4] rust: Add i8 and i16 atomic support Joel Fernandes
@ 2025-12-11 17:37 ` Gary Guo
2025-12-11 20:05 ` Joel Fernandes
2025-12-14 21:54 ` Boqun Feng
6 siblings, 1 reply; 9+ messages in thread
From: Gary Guo @ 2025-12-11 17:37 UTC (permalink / raw)
To: FUJITA Tomonori
Cc: boqun.feng, ojeda, peterz, will, acourbot, a.hindborg, aliceryhl,
bjorn3_gh, dakr, lossin, mark.rutland, tmgross, rust-for-linux
On Thu, 11 Dec 2025 20:38:22 +0900
FUJITA Tomonori <fujita.tomonori@gmail.com> wrote:
> This adds Atomic<i8> and Atomic<i16> support; including
> load/store(Relaxed) and load(Acquire)/store(Release) operations.
>
> Relaxed operations are implemented in C's READ_ONCE() and
> WRITE_ONCE() macros.
>
> load(Acquire)/store(Release) use C's smp_load_acquire() and
> smp_store_release() macros. They internally use the appropriate
> architecture-specific instructions.
>
> v3:
> - Move i8/i16 AtomicImp next to i32/i64 with the comments updated
> - Add a comment about leaving the existing macros untouched
> - Add __rust_helper for helpers
> - Update commit messages about atomic_ext.c instead of atomic.c
> v2: https://lore.kernel.org/rust-for-linux/20251117001035.4068507-1-fujita.tomonori@gmail.com/
> - Implement relaxed operations by using C's READ_ONCE/WRITE_ONCE
> - Rename smp_load_acquire() and smp_store_release() helpers
> - Simplify the macro to generate atomic methods
> v1: https://lore.kernel.org/rust-for-linux/20251115050305.3872412-1-fujita.tomonori@gmail.com/
Thanks for the work. I discussed with Boqun off-list about whether the
RAED_ONCE/WRITE_ONCE should be helpers and he convinced me that we
should start with helpers to begin with. So the series LGTM.
Reviewed-by: Gary Guo <gary@garyguo.net>
>
> FUJITA Tomonori (4):
> rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release
> helpers
> rust: helpers: Add i8/i16 relaxed atomic helpers
> rust: sync: atomic: Add i8/i16 load and store support
> rust: sync: atomic: Add store_release/load_acquire tests
>
> rust/helpers/atomic_ext.c | 44 ++++++++++++++++++
> rust/helpers/helpers.c | 1 +
> rust/kernel/sync/atomic/internal.rs | 69 ++++++++++++++++++++++++++--
> rust/kernel/sync/atomic/predefine.rs | 24 +++++++++-
> 4 files changed, 132 insertions(+), 6 deletions(-)
> create mode 100644 rust/helpers/atomic_ext.c
>
>
> base-commit: d358e5254674b70f34c847715ca509e46eb81e6f
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 0/4] rust: Add i8 and i16 atomic support
2025-12-11 17:37 ` Gary Guo
@ 2025-12-11 20:05 ` Joel Fernandes
0 siblings, 0 replies; 9+ messages in thread
From: Joel Fernandes @ 2025-12-11 20:05 UTC (permalink / raw)
To: Gary Guo
Cc: Tomonori FUJITA, boqun.feng@gmail.com, ojeda@kernel.org,
peterz@infradead.org, will@kernel.org, Alexandre Courbot,
a.hindborg@kernel.org, aliceryhl@google.com,
bjorn3_gh@protonmail.com, dakr@kernel.org, lossin@kernel.org,
mark.rutland@arm.com, tmgross@umich.edu,
rust-for-linux@vger.kernel.org
> On Dec 12, 2025, at 2:37 AM, Gary Guo <gary@garyguo.net> wrote:
>
> On Thu, 11 Dec 2025 20:38:22 +0900
> FUJITA Tomonori <fujita.tomonori@gmail.com> wrote:
>
>> This adds Atomic<i8> and Atomic<i16> support; including
>> load/store(Relaxed) and load(Acquire)/store(Release) operations.
>>
>> Relaxed operations are implemented in C's READ_ONCE() and
>> WRITE_ONCE() macros.
>>
>> load(Acquire)/store(Release) use C's smp_load_acquire() and
>> smp_store_release() macros. They internally use the appropriate
>> architecture-specific instructions.
>>
>> v3:
>> - Move i8/i16 AtomicImp next to i32/i64 with the comments updated
>> - Add a comment about leaving the existing macros untouched
>> - Add __rust_helper for helpers
>> - Update commit messages about atomic_ext.c instead of atomic.c
>> v2: https://lore.kernel.org/rust-for-linux/20251117001035.4068507-1-fujita.tomonori@gmail.com/
>> - Implement relaxed operations by using C's READ_ONCE/WRITE_ONCE
>> - Rename smp_load_acquire() and smp_store_release() helpers
>> - Simplify the macro to generate atomic methods
>> v1: https://lore.kernel.org/rust-for-linux/20251115050305.3872412-1-fujita.tomonori@gmail.com/
>
> Thanks for the work. I discussed with Boqun off-list about whether the
> RAED_ONCE/WRITE_ONCE should be helpers and he convinced me that we
> should start with helpers to begin with. So the series LGTM.
>
> Reviewed-by: Gary Guo <gary@garyguo.net>
Indeed, I also vehemently agree with the notion of reusing C architecture support / memory model for these.
thanks,
- Joel
>
>>
>> FUJITA Tomonori (4):
>> rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release
>> helpers
>> rust: helpers: Add i8/i16 relaxed atomic helpers
>> rust: sync: atomic: Add i8/i16 load and store support
>> rust: sync: atomic: Add store_release/load_acquire tests
>>
>> rust/helpers/atomic_ext.c | 44 ++++++++++++++++++
>> rust/helpers/helpers.c | 1 +
>> rust/kernel/sync/atomic/internal.rs | 69 ++++++++++++++++++++++++++--
>> rust/kernel/sync/atomic/predefine.rs | 24 +++++++++-
>> 4 files changed, 132 insertions(+), 6 deletions(-)
>> create mode 100644 rust/helpers/atomic_ext.c
>>
>>
>> base-commit: d358e5254674b70f34c847715ca509e46eb81e6f
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 0/4] rust: Add i8 and i16 atomic support
2025-12-11 11:38 [PATCH v3 0/4] rust: Add i8 and i16 atomic support FUJITA Tomonori
` (5 preceding siblings ...)
2025-12-11 17:37 ` Gary Guo
@ 2025-12-14 21:54 ` Boqun Feng
6 siblings, 0 replies; 9+ messages in thread
From: Boqun Feng @ 2025-12-14 21:54 UTC (permalink / raw)
To: FUJITA Tomonori
Cc: ojeda, peterz, will, acourbot, a.hindborg, aliceryhl, bjorn3_gh,
dakr, gary, lossin, mark.rutland, tmgross, rust-for-linux
On Thu, Dec 11, 2025 at 08:38:22PM +0900, FUJITA Tomonori wrote:
> This adds Atomic<i8> and Atomic<i16> support; including
> load/store(Relaxed) and load(Acquire)/store(Release) operations.
>
> Relaxed operations are implemented in C's READ_ONCE() and
> WRITE_ONCE() macros.
>
> load(Acquire)/store(Release) use C's smp_load_acquire() and
> smp_store_release() macros. They internally use the appropriate
> architecture-specific instructions.
>
> v3:
> - Move i8/i16 AtomicImp next to i32/i64 with the comments updated
> - Add a comment about leaving the existing macros untouched
> - Add __rust_helper for helpers
> - Update commit messages about atomic_ext.c instead of atomic.c
> v2: https://lore.kernel.org/rust-for-linux/20251117001035.4068507-1-fujita.tomonori@gmail.com/
> - Implement relaxed operations by using C's READ_ONCE/WRITE_ONCE
> - Rename smp_load_acquire() and smp_store_release() helpers
> - Simplify the macro to generate atomic methods
> v1: https://lore.kernel.org/rust-for-linux/20251115050305.3872412-1-fujita.tomonori@gmail.com/
>
Queued in:
https://git.kernel.org/pub/scm/linux/kernel/git/boqun/linux.git/ rust-sync
Thank you all!
Regards,
Boqun
> FUJITA Tomonori (4):
> rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release
> helpers
> rust: helpers: Add i8/i16 relaxed atomic helpers
> rust: sync: atomic: Add i8/i16 load and store support
> rust: sync: atomic: Add store_release/load_acquire tests
>
> rust/helpers/atomic_ext.c | 44 ++++++++++++++++++
> rust/helpers/helpers.c | 1 +
> rust/kernel/sync/atomic/internal.rs | 69 ++++++++++++++++++++++++++--
> rust/kernel/sync/atomic/predefine.rs | 24 +++++++++-
> 4 files changed, 132 insertions(+), 6 deletions(-)
> create mode 100644 rust/helpers/atomic_ext.c
>
>
> base-commit: d358e5254674b70f34c847715ca509e46eb81e6f
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-12-14 21:55 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-11 11:38 [PATCH v3 0/4] rust: Add i8 and i16 atomic support FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 1/4] rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release helpers FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 2/4] rust: helpers: Add i8/i16 relaxed atomic helpers FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 3/4] rust: sync: atomic: Add i8/i16 load and store support FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 4/4] rust: sync: atomic: Add store_release/load_acquire tests FUJITA Tomonori
2025-12-11 16:49 ` [PATCH v3 0/4] rust: Add i8 and i16 atomic support Joel Fernandes
2025-12-11 17:37 ` Gary Guo
2025-12-11 20:05 ` Joel Fernandes
2025-12-14 21:54 ` Boqun Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).