Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: list: Use AtomicFlag in AtomicTracker

Make AtomicTracker use AtomicFlag instead of Atomic<bool> to avoid
slow byte-sized RMWs on architectures that don't support them.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Signed-off-by: Boqun Feng <boqun@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260129122622.3896144-3-tomo@aliasing.net
Link: https://patch.msgid.link/20260303201701.12204-10-boqun@kernel.org

authored by

FUJITA Tomonori and committed by
Peter Zijlstra
28286620 ec6fc66a

+4 -4
+4 -4
rust/kernel/list/arc.rs
··· 6 6 7 7 use crate::alloc::{AllocError, Flags}; 8 8 use crate::prelude::*; 9 - use crate::sync::atomic::{ordering, Atomic}; 9 + use crate::sync::atomic::{ordering, AtomicFlag}; 10 10 use crate::sync::{Arc, ArcBorrow, UniqueArc}; 11 11 use core::marker::PhantomPinned; 12 12 use core::ops::Deref; ··· 469 469 /// If the boolean is `false`, then there is no [`ListArc`] for this value. 470 470 #[repr(transparent)] 471 471 pub struct AtomicTracker<const ID: u64 = 0> { 472 - inner: Atomic<bool>, 472 + inner: AtomicFlag, 473 473 // This value needs to be pinned to justify the INVARIANT: comment in `AtomicTracker::new`. 474 474 _pin: PhantomPinned, 475 475 } ··· 480 480 // INVARIANT: Pin-init initializers can't be used on an existing `Arc`, so this value will 481 481 // not be constructed in an `Arc` that already has a `ListArc`. 482 482 Self { 483 - inner: Atomic::new(false), 483 + inner: AtomicFlag::new(false), 484 484 _pin: PhantomPinned, 485 485 } 486 486 } 487 487 488 - fn project_inner(self: Pin<&mut Self>) -> &mut Atomic<bool> { 488 + fn project_inner(self: Pin<&mut Self>) -> &mut AtomicFlag { 489 489 // SAFETY: The `inner` field is not structurally pinned, so we may obtain a mutable 490 490 // reference to it even if we only have a pinned reference to `self`. 491 491 unsafe { &mut Pin::into_inner_unchecked(self).inner }