[PATCH v2 01/10] rust: rcu: Add get_state_synchronize_rcu()
From: Philipp Stanner
Date: Tue Nov 24 2026 - 07:30:37 EST
Some users don't want to perform a full call to synchronize_rcu() if it
is avoidable.
Add abstractions for get_state_synchronize_rcu() to obtain a grace
period identifier.
Signed-off-by: Philipp Stanner <phasta@xxxxxxxxxx>
---
rust/kernel/sync/rcu.rs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/rust/kernel/sync/rcu.rs b/rust/kernel/sync/rcu.rs
index 0daa1ac87d81..7afc78b34759 100644
--- a/rust/kernel/sync/rcu.rs
+++ b/rust/kernel/sync/rcu.rs
@@ -86,3 +86,13 @@ pub fn synchronize_rcu() {
// SAFETY: `synchronize_rcu()` is always safe to be called from process context.
unsafe { bindings::synchronize_rcu() };
}
+
+/// Obtain a cookie identifying a grace period.
+///
+/// Returns an identifier that can be used by other functions to check whether
+/// a specific grace period has passed already.
+#[inline]
+pub fn get_state_synchronize_rcu() -> usize {
+ // SAFETY: `get_state_synchronize_rcu()` is always safe to be called.
+ unsafe { bindings::get_state_synchronize_rcu() }
+}
--
2.56.0