xref: /linux/rust/kernel/sync/atomic.rs (revision b638c9bc471030ebd898b57c5bf7c96f6d70cda4)
12387fb2aSBoqun Feng // SPDX-License-Identifier: GPL-2.0
22387fb2aSBoqun Feng 
32387fb2aSBoqun Feng //! Atomic primitives.
42387fb2aSBoqun Feng //!
52387fb2aSBoqun Feng //! These primitives have the same semantics as their C counterparts: and the precise definitions of
62387fb2aSBoqun Feng //! semantics can be found at [`LKMM`]. Note that Linux Kernel Memory (Consistency) Model is the
72387fb2aSBoqun Feng //! only model for Rust code in kernel, and Rust's own atomics should be avoided.
82387fb2aSBoqun Feng //!
92387fb2aSBoqun Feng //! # Data races
102387fb2aSBoqun Feng //!
112387fb2aSBoqun Feng //! [`LKMM`] atomics have different rules regarding data races:
122387fb2aSBoqun Feng //!
132387fb2aSBoqun Feng //! - A normal write from C side is treated as an atomic write if
142387fb2aSBoqun Feng //!   CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=y.
152387fb2aSBoqun Feng //! - Mixed-size atomic accesses don't cause data races.
162387fb2aSBoqun Feng //!
172387fb2aSBoqun Feng //! [`LKMM`]: srctree/tools/memory-model/
182387fb2aSBoqun Feng 
192387fb2aSBoqun Feng #[allow(dead_code, unreachable_pub)]
202387fb2aSBoqun Feng mod internal;
21*b638c9bcSBoqun Feng pub mod ordering;
222387fb2aSBoqun Feng 
232387fb2aSBoqun Feng pub use internal::AtomicImpl;
24*b638c9bcSBoqun Feng pub use ordering::{Acquire, Full, Relaxed, Release};
25