]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: sync: atomic: Remove bound `T: Sync` for `Atomic::from_ptr()`
authorBoqun Feng <boqun.feng@gmail.com>
Tue, 3 Mar 2026 20:16:49 +0000 (12:16 -0800)
committerPeter Zijlstra <peterz@infradead.org>
Sun, 8 Mar 2026 10:06:47 +0000 (11:06 +0100)
commit4a5dc632e0b603ec1cbbf87b78de86b4b6359cff
tree27ac97b55f2b1d9f27be3b3e9543b5897cfd3974
parent0da9ca4c08e709144a1bd2f765c14205960ac64d
rust: sync: atomic: Remove bound `T: Sync` for `Atomic::from_ptr()`

Originally, `Atomic::from_ptr()` requires `T` being a `Sync` because I
thought having the ability to do `from_ptr()` meant multiplle
`&Atomic<T>`s shared by different threads, which was identical (or
similar) to multiple `&T`s shared by different threads. Hence `T` was
required to be `Sync`. However this is not true, since `&Atomic<T>` is
not the same at `&T`. Moreover, having this bound makes `Atomic::<*mut
T>::from_ptr()` impossible, which is definitely not intended. Therefore
remove the `T: Sync` bound.

[boqun: Fix title typo spotted by Alice & Gary]

Fixes: 29c32c405e53 ("rust: sync: atomic: Add generic atomics")
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: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260120115207.55318-2-boqun.feng@gmail.com
Link: https://patch.msgid.link/20260303201701.12204-2-boqun@kernel.org
rust/kernel/sync/atomic.rs