summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorPhilipp Stanner <phasta@kernel.org>2026-06-24 17:07:02 +0200
committerBoqun Feng <boqun@kernel.org>2026-08-04 05:52:53 -0700
commit1fb92e0625596985b3941925afe7906fef41214b (patch)
tree48f1e3678490958dee33efd09ecd6fa8a6fa991b /rust
parent1c7efabfbaf796f11000a46094a69955a01ec6cc (diff)
downloadlinux-1fb92e0625596985b3941925afe7906fef41214b.tar.gz
linux-1fb92e0625596985b3941925afe7906fef41214b.zip
rust: sync: Add abstraction for synchronize_rcu()
synchronize_rcu() is a frequently used C function which is always safe to be called. Add a safe abstraction for synchronize_rcu(). Signed-off-by: Philipp Stanner <phasta@kernel.org> Reviewed-by: Onur Özkan <work@onurozkan.dev> Reviewed-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Gary Guo <gary@garyguo.net> [boqun: Fix rustdoc reported by kernel test robot <lkp@intel.com>] Signed-off-by: Boqun Feng <boqun@kernel.org> Link: https://patch.msgid.link/20260624150704.1504001-3-phasta@kernel.org
Diffstat (limited to 'rust')
-rw-r--r--rust/kernel/sync/rcu.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/rust/kernel/sync/rcu.rs b/rust/kernel/sync/rcu.rs
index a32bef6e490b..d867240be736 100644
--- a/rust/kernel/sync/rcu.rs
+++ b/rust/kernel/sync/rcu.rs
@@ -50,3 +50,19 @@ impl Drop for Guard {
pub fn read_lock() -> Guard {
Guard::new()
}
+
+/// Wait for one RCU grace period.
+///
+/// Waits for all RCU read-side critical sections (such as those established by
+/// a [`Guard`]) at the moment of the function call to finish.
+///
+/// Does not prevent new read-side critical sections from starting, which may
+/// begin and run while this call is blocking.
+///
+/// Note that this is one of the RCU primitives which must not be called in
+/// atomic context.
+#[inline]
+pub fn synchronize_rcu() {
+ // SAFETY: `synchronize_rcu()` is always safe to be called from process context.
+ unsafe { bindings::synchronize_rcu() };
+}