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 <[email protected]>
---
 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

Reply via email to