| bd36f6e2 | 24-Jan-2026 |
Miguel Ojeda <ojeda@kernel.org> |
rust: sync: atomic: Provide stub for `rusttest` 32-bit hosts
For arm32, on a x86_64 builder, running the `rusttest` target yields:
error[E0080]: evaluation of constant value failed --> ru
rust: sync: atomic: Provide stub for `rusttest` 32-bit hosts
For arm32, on a x86_64 builder, running the `rusttest` target yields:
error[E0080]: evaluation of constant value failed --> rust/kernel/static_assert.rs:37:23 | 37 | const _: () = ::core::assert!($condition $(,$arg)?); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: size_of::<isize>() == size_of::<isize_atomic_repr>()', rust/kernel/sync/atomic/predefine.rs:68:1 | ::: rust/kernel/sync/atomic/predefine.rs:68:1 | 68 | static_assert!(size_of::<isize>() == size_of::<isize_atomic_repr>()); | -------------------------------------------------------------------- in this macro invocation | = note: this error originates in the macro `::core::assert` which comes from the expansion of the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)
The reason is that `rusttest` runs on the host, so for e.g. a x86_64 builder `isize` is 64 bits but it is not a `CONFIG_64BIT` build.
Fix it by providing a stub for `rusttest` as usual.
Fixes: 84c6d36bcaf9 ("rust: sync: atomic: Add Atomic<{usize,isize}>") Cc: stable@vger.kernel.org Reviewed-by: Onur Özkan <work@onurozkan.dev> Acked-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20260123233432.22703-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| ccf9e070 | 18-Dec-2025 |
Alice Ryhl <aliceryhl@google.com> |
rust: sync: Inline various lock related methods
While debugging a different issue [1], the following relocation was noticed in the rust_binder.ko file:
R_AARCH64_CALL26 _RNvXNtNtNtCsdfZWD8DztAw_6k
rust: sync: Inline various lock related methods
While debugging a different issue [1], the following relocation was noticed in the rust_binder.ko file:
R_AARCH64_CALL26 _RNvXNtNtNtCsdfZWD8DztAw_6kernel4sync4lock8spinlockNtB2_15SpinLockBackendNtB4_7Backend6unlock
This relocation (and a similar one for lock) occurred many times throughout the module. That is not really useful because all this function does is call spin_unlock(), so what we actually want here is that a call to spin_unlock() dirctly is generated in favor of this wrapper method.
Thus, mark these methods inline.
[boqun: Reword the commit message a bit]
Link: https://lore.kernel.org/p/20251111-binder-fix-list-remove-v1-0-8ed14a0da63d@google.com Signed-off-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20251218-inline-lock-unlock-v2-1-fbadac8bd61b@google.com
show more ...
|
| 4bac2872 | 01-Jan-2026 |
FUJITA Tomonori <fujita.tomonori@gmail.com> |
rust: sync: atomic: Add atomic bool tests
Add tests for Atomic<bool> operations.
Atomic<bool> does not fit into the existing u8/16/32/64 tests so introduce a dedicated test for it.
Signed-off-by:
rust: sync: atomic: Add atomic bool tests
Add tests for Atomic<bool> operations.
Atomic<bool> does not fit into the existing u8/16/32/64 tests so introduce a dedicated test for it.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20260101034922.2020334-3-fujita.tomonori@gmail.com
show more ...
|
| 06bd0e52 | 01-Jan-2026 |
FUJITA Tomonori <fujita.tomonori@gmail.com> |
rust: sync: atomic: Add atomic bool support via i8 representation
Add `bool` support, `Atomic<bool>` by using `i8` as its underlying representation.
Rust specifies that `bool` has size 1 and alignm
rust: sync: atomic: Add atomic bool support via i8 representation
Add `bool` support, `Atomic<bool>` by using `i8` as its underlying representation.
Rust specifies that `bool` has size 1 and alignment 1 [1], so it matches `i8` on layout; keep `static_assert!()` checks to enforce this assumption at build time.
[boqun: Remove the unnecessary impl AtomicImpl for bool]
Link: https://doc.rust-lang.org/reference/types/boolean.html [1] Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20260101034922.2020334-2-fujita.tomonori@gmail.com
show more ...
|
| 584f286f | 28-Dec-2025 |
FUJITA Tomonori <fujita.tomonori@gmail.com> |
rust: sync: atomic: Add i8/i16 xchg and cmpxchg support
Add atomic xchg and cmpxchg operation support for i8 and i16 types with tests.
Note that since the current implementation of Atomic::<{i8,i16
rust: sync: atomic: Add i8/i16 xchg and cmpxchg support
Add atomic xchg and cmpxchg operation support for i8 and i16 types with tests.
Note that since the current implementation of Atomic::<{i8,i16}>::{load,store}() is READ_ONCE()/WRITE_ONCE()-based. The atomicity between load/store and xchg/cmpxchg is only guaranteed if the architecture has native RmW support, hence i8/i16 is currently AtomicImpl only when CONFIG_ARCH_SUPPORTS_ATOMIC_RWM=y.
[boqun: Make i8/i16 AtomicImpl only when CONFIG_ARCH_SUPPORTS_ATOMIC_RWM=y]
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20251228120546.1602275-4-fujita.tomonori@gmail.com
show more ...
|
| 7b001c97 | 11-Dec-2025 |
FUJITA Tomonori <fujita.tomonori@gmail.com> |
rust: sync: atomic: Add store_release/load_acquire tests
Add minimum store_release/load_acquire tests.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Reviewed-by: Gary Guo <gary@garyguo
rust: sync: atomic: Add store_release/load_acquire tests
Add minimum store_release/load_acquire tests.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20251211113826.1299077-5-fujita.tomonori@gmail.com
show more ...
|
| b33796d5 | 11-Dec-2025 |
FUJITA Tomonori <fujita.tomonori@gmail.com> |
rust: sync: atomic: Add i8/i16 load and store support
Add atomic operation support for i8 and i16 types using volatile read/write and smp_load_acquire/smp_store_release helpers.
[boqun: Adjust [1]
rust: sync: atomic: Add i8/i16 load and store support
Add atomic operation support for i8 and i16 types using volatile read/write and smp_load_acquire/smp_store_release helpers.
[boqun: Adjust [1] to avoid introduction of impl_atomic_only_load_and_store_ops!() in the middle]
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com> Link: https://lore.kernel.org/all/20251228120546.1602275-1-fujita.tomonori@gmail.com/ [1] Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20251211113826.1299077-4-fujita.tomonori@gmail.com
show more ...
|
| 2bb8c41e | 28-Dec-2025 |
FUJITA Tomonori <fujita.tomonori@gmail.com> |
rust: sync: atomic: Prepare AtomicOps macros for i8/i16 support
Rework the internal AtomicOps macro plumbing to generate per-type implementations from a mapping list.
Capture the trait definition o
rust: sync: atomic: Prepare AtomicOps macros for i8/i16 support
Rework the internal AtomicOps macro plumbing to generate per-type implementations from a mapping list.
Capture the trait definition once and reuse it for both declaration and per-type impl expansion to reduce duplication and keep future extensions simple.
This is a preparatory refactor for enabling i8/i16 atomics cleanly.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20251228120546.1602275-2-fujita.tomonori@gmail.com
show more ...
|
| 09248ed8 | 18-Dec-2025 |
Alice Ryhl <aliceryhl@google.com> |
rust: sync: Implement Unpin for ARef
The default implementation of Unpin for ARef<T> is conditional on T being Unpin due to its PhantomData<T> field. However, this is overly strict as pointers to T
rust: sync: Implement Unpin for ARef
The default implementation of Unpin for ARef<T> is conditional on T being Unpin due to its PhantomData<T> field. However, this is overly strict as pointers to T are legal to move even if T itself cannot move.
Since commit 66f1ea83d9f8 ("rust: lock: Add a Pin<&mut T> accessor") this causes build failures when combined with a Mutex that contains an field ARef<T>, because almost any type that ARef is used with is !Unpin.
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20251218-unpin-for-aref-v2-1-30d77129cbc6@google.com
show more ...
|
| 309e4903 | 04-Dec-2025 |
Miguel Ojeda <ojeda@kernel.org> |
rust: sync: atomic: separate import "blocks"
Commit 14e9a18b07ec ("rust: sync: atomic: Make Atomic*Ops pub(crate)") added a `pub(crate)` import in the same "block" as the `pub` one, without running
rust: sync: atomic: separate import "blocks"
Commit 14e9a18b07ec ("rust: sync: atomic: Make Atomic*Ops pub(crate)") added a `pub(crate)` import in the same "block" as the `pub` one, without running `rustfmt`, which would sort them differently.
Instead of running `rustfmt` as-is, add a newline to keep the import "blocks" with different visibilities separate.
Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
show more ...
|
| 013f912e | 22-Oct-2025 |
Boqun Feng <boqun.feng@gmail.com> |
rust: sync: atomic: Implement Debug for Atomic<Debug>
If `Atomic<T>` is `Debug` then it's a `debugfs::Writer`, therefore make it so since 1) debugfs needs to support `Atomic<T>` and 2) it's rather t
rust: sync: atomic: Implement Debug for Atomic<Debug>
If `Atomic<T>` is `Debug` then it's a `debugfs::Writer`, therefore make it so since 1) debugfs needs to support `Atomic<T>` and 2) it's rather trivial to implement `Debug` for `Atomic<Debug>`.
Tested-by: David Gow <davidgow@google.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20251022035324.70785-3-boqun.feng@gmail.com
show more ...
|
| 66f1ea83 | 19-Sep-2025 |
Daniel Almeida <daniel.almeida@collabora.com> |
rust: lock: Add a Pin<&mut T> accessor
In order for callers to be able to access the inner T safely if T: !Unpin, there needs to be a way to get a Pin<&mut T>. Add this accessor and a corresponding
rust: lock: Add a Pin<&mut T> accessor
In order for callers to be able to access the inner T safely if T: !Unpin, there needs to be a way to get a Pin<&mut T>. Add this accessor and a corresponding example to tell users how it works.
This requires the pin projection functionality [1] for better ergonomic.
[boqun: Apply Daniel's fix to the code example, add the reference to pin projection patch and remove out-of-date part in the commit log]
Suggested-by: Benno Lossin <lossin@kernel.org> Suggested-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Link: https://github.com/Rust-for-Linux/linux/issues/1181 Link: https://lore.kernel.org/rust-for-linux/20250912174148.373530-1-lossin@kernel.org/ [1]
show more ...
|
| 2497a711 | 19-Sep-2025 |
Daniel Almeida <daniel.almeida@collabora.com> |
rust: lock: Pin the inner data
In preparation to support Lock<T> where T is pinned, the first thing that needs to be done is to structurally pin the 'data' member. This switches the 't' parameter in
rust: lock: Pin the inner data
In preparation to support Lock<T> where T is pinned, the first thing that needs to be done is to structurally pin the 'data' member. This switches the 't' parameter in Lock<T>::new() to take in an impl PinInit<T> instead of a plain T. This in turn uses the blanket implementation "impl PinInit<T> for T".
Subsequent patches will touch on Guard<T>.
Suggested-by: Benno Lossin <lossin@kernel.org> Suggested-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Benno Lossin <lossin@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://github.com/Rust-for-Linux/linux/issues/1181
show more ...
|