xref: /linux/rust/kernel/sync/atomic.rs (revision 2387fb2a9b84950dfe2eaa0b170f429e04b38168)
1*2387fb2aSBoqun Feng // SPDX-License-Identifier: GPL-2.0
2*2387fb2aSBoqun Feng 
3*2387fb2aSBoqun Feng //! Atomic primitives.
4*2387fb2aSBoqun Feng //!
5*2387fb2aSBoqun Feng //! These primitives have the same semantics as their C counterparts: and the precise definitions of
6*2387fb2aSBoqun Feng //! semantics can be found at [`LKMM`]. Note that Linux Kernel Memory (Consistency) Model is the
7*2387fb2aSBoqun Feng //! only model for Rust code in kernel, and Rust's own atomics should be avoided.
8*2387fb2aSBoqun Feng //!
9*2387fb2aSBoqun Feng //! # Data races
10*2387fb2aSBoqun Feng //!
11*2387fb2aSBoqun Feng //! [`LKMM`] atomics have different rules regarding data races:
12*2387fb2aSBoqun Feng //!
13*2387fb2aSBoqun Feng //! - A normal write from C side is treated as an atomic write if
14*2387fb2aSBoqun Feng //!   CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=y.
15*2387fb2aSBoqun Feng //! - Mixed-size atomic accesses don't cause data races.
16*2387fb2aSBoqun Feng //!
17*2387fb2aSBoqun Feng //! [`LKMM`]: srctree/tools/memory-model/
18*2387fb2aSBoqun Feng 
19*2387fb2aSBoqun Feng #[allow(dead_code, unreachable_pub)]
20*2387fb2aSBoqun Feng mod internal;
21*2387fb2aSBoqun Feng 
22*2387fb2aSBoqun Feng pub use internal::AtomicImpl;
23