* [PATCH v3 0/3] Add and use abstraction for synchronize_rcu()
@ 2026-06-24 15:07 Philipp Stanner
2026-06-24 15:07 ` [PATCH v3 1/3] rust: sync: Add " Philipp Stanner
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Philipp Stanner @ 2026-06-24 15:07 UTC (permalink / raw)
To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Alexander Viro,
Christian Brauner, Jan Kara, Lyude Paul, Paul E. McKenney,
Frederic Weisbecker, Neeraj Upadhyay, Joel Fernandes,
Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Christian Schrefl,
Philipp Stanner
Cc: rust-for-linux, linux-kernel, linux-fsdevel, rcu
Changes since v2:
- Compromise docu for "RCU versus atomic context" a bit better
- Add respective R-b's
Changes since v1:
- Vertically format imports. (Onur)
- Make the new function #[inline]. (Alice)
- Add Alice's R-b.
Philipp Stanner (3):
rust: sync: Add abstraction for synchronize_rcu()
rust: revocable: Use safe synchronize_rcu() abstraction
rust: sync: Use safe synchronize_rcu() abstraction in poll
rust/kernel/revocable.rs | 9 ++++++---
rust/kernel/sync/poll.rs | 10 ++++++----
rust/kernel/sync/rcu.rs | 16 ++++++++++++++++
3 files changed, 28 insertions(+), 7 deletions(-)
base-commit: 43a393185e33e573a374c1d4f7ddf6481484ef8d
--
2.54.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/3] rust: sync: Add abstraction for synchronize_rcu()
2026-06-24 15:07 [PATCH v3 0/3] Add and use abstraction for synchronize_rcu() Philipp Stanner
@ 2026-06-24 15:07 ` Philipp Stanner
2026-06-24 15:07 ` [PATCH v3 2/3] rust: revocable: Use safe synchronize_rcu() abstraction Philipp Stanner
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Philipp Stanner @ 2026-06-24 15:07 UTC (permalink / raw)
To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Alexander Viro,
Christian Brauner, Jan Kara, Lyude Paul, Paul E. McKenney,
Frederic Weisbecker, Neeraj Upadhyay, Joel Fernandes,
Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Christian Schrefl,
Philipp Stanner
Cc: rust-for-linux, linux-kernel, linux-fsdevel, 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>
---
rust/kernel/sync/rcu.rs | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/rust/kernel/sync/rcu.rs b/rust/kernel/sync/rcu.rs
index a32bef6e490b..2bae76d229f0 100644
--- a/rust/kernel/sync/rcu.rs
+++ b/rust/kernel/sync/rcu.rs
@@ -50,3 +50,19 @@ fn drop(&mut self) {
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 [`rcu::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() };
+}
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/3] rust: revocable: Use safe synchronize_rcu() abstraction
2026-06-24 15:07 [PATCH v3 0/3] Add and use abstraction for synchronize_rcu() Philipp Stanner
2026-06-24 15:07 ` [PATCH v3 1/3] rust: sync: Add " Philipp Stanner
@ 2026-06-24 15:07 ` Philipp Stanner
2026-06-24 15:07 ` [PATCH v3 3/3] rust: sync: Use safe synchronize_rcu() abstraction in poll Philipp Stanner
2026-06-24 15:30 ` [PATCH v3 0/3] Add and use abstraction for synchronize_rcu() Boqun Feng
3 siblings, 0 replies; 5+ messages in thread
From: Philipp Stanner @ 2026-06-24 15:07 UTC (permalink / raw)
To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Alexander Viro,
Christian Brauner, Jan Kara, Lyude Paul, Paul E. McKenney,
Frederic Weisbecker, Neeraj Upadhyay, Joel Fernandes,
Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Christian Schrefl,
Philipp Stanner
Cc: rust-for-linux, linux-kernel, linux-fsdevel, rcu
We now have a safe wrapper for the foreign function synchronize_rcu().
Use it in revocable.rs.
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>
---
rust/kernel/revocable.rs | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/rust/kernel/revocable.rs b/rust/kernel/revocable.rs
index 0f4ae673256d..f539603349f1 100644
--- a/rust/kernel/revocable.rs
+++ b/rust/kernel/revocable.rs
@@ -7,7 +7,11 @@
use pin_init::Wrapper;
-use crate::{bindings, prelude::*, sync::rcu, types::Opaque};
+use crate::{
+ prelude::*,
+ sync::rcu,
+ types::Opaque, //
+};
use core::{
marker::PhantomData,
ops::Deref,
@@ -161,8 +165,7 @@ unsafe fn revoke_internal<const SYNC: bool>(&self) -> bool {
if revoke {
if SYNC {
- // SAFETY: Just an FFI call, there are no further requirements.
- unsafe { bindings::synchronize_rcu() };
+ rcu::synchronize_rcu();
}
// SAFETY: We know `self.data` is valid because only one CPU can succeed the
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/3] rust: sync: Use safe synchronize_rcu() abstraction in poll
2026-06-24 15:07 [PATCH v3 0/3] Add and use abstraction for synchronize_rcu() Philipp Stanner
2026-06-24 15:07 ` [PATCH v3 1/3] rust: sync: Add " Philipp Stanner
2026-06-24 15:07 ` [PATCH v3 2/3] rust: revocable: Use safe synchronize_rcu() abstraction Philipp Stanner
@ 2026-06-24 15:07 ` Philipp Stanner
2026-06-24 15:30 ` [PATCH v3 0/3] Add and use abstraction for synchronize_rcu() Boqun Feng
3 siblings, 0 replies; 5+ messages in thread
From: Philipp Stanner @ 2026-06-24 15:07 UTC (permalink / raw)
To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Alexander Viro,
Christian Brauner, Jan Kara, Lyude Paul, Paul E. McKenney,
Frederic Weisbecker, Neeraj Upadhyay, Joel Fernandes,
Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Christian Schrefl,
Philipp Stanner
Cc: rust-for-linux, linux-kernel, linux-fsdevel, rcu
We now have a safe wrapper for the foreign function synchronize_rcu().
Use it in poll.rs.
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Onur Özkan <work@onurozkan.dev>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
---
rust/kernel/sync/poll.rs | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/rust/kernel/sync/poll.rs b/rust/kernel/sync/poll.rs
index 0ec985d560c8..30ebeea1702f 100644
--- a/rust/kernel/sync/poll.rs
+++ b/rust/kernel/sync/poll.rs
@@ -8,7 +8,11 @@
bindings,
fs::File,
prelude::*,
- sync::{CondVar, LockClassKey},
+ sync::{
+ CondVar,
+ LockClassKey,
+ rcu::synchronize_rcu, //
+ }, //
};
use core::{marker::PhantomData, ops::Deref};
@@ -99,8 +103,6 @@ fn drop(self: Pin<&mut Self>) {
unsafe { bindings::__wake_up_pollfree(self.inner.wait_queue_head.get()) };
// Wait for epoll items to be properly removed.
- //
- // SAFETY: Just an FFI call.
- unsafe { bindings::synchronize_rcu() };
+ synchronize_rcu();
}
}
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 0/3] Add and use abstraction for synchronize_rcu()
2026-06-24 15:07 [PATCH v3 0/3] Add and use abstraction for synchronize_rcu() Philipp Stanner
` (2 preceding siblings ...)
2026-06-24 15:07 ` [PATCH v3 3/3] rust: sync: Use safe synchronize_rcu() abstraction in poll Philipp Stanner
@ 2026-06-24 15:30 ` Boqun Feng
3 siblings, 0 replies; 5+ messages in thread
From: Boqun Feng @ 2026-06-24 15:30 UTC (permalink / raw)
To: Philipp Stanner
Cc: Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
Onur Özkan, Alexander Viro, Christian Brauner, Jan Kara,
Lyude Paul, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Christian Schrefl, rust-for-linux, linux-kernel, linux-fsdevel,
rcu
On Wed, Jun 24, 2026 at 05:07:01PM +0200, Philipp Stanner wrote:
> Changes since v2:
> - Compromise docu for "RCU versus atomic context" a bit better
> - Add respective R-b's
>
> Changes since v1:
> - Vertically format imports. (Onur)
> - Make the new function #[inline]. (Alice)
> - Add Alice's R-b.
>
> Philipp Stanner (3):
> rust: sync: Add abstraction for synchronize_rcu()
> rust: revocable: Use safe synchronize_rcu() abstraction
> rust: sync: Use safe synchronize_rcu() abstraction in poll
>
> rust/kernel/revocable.rs | 9 ++++++---
> rust/kernel/sync/poll.rs | 10 ++++++----
> rust/kernel/sync/rcu.rs | 16 ++++++++++++++++
> 3 files changed, 28 insertions(+), 7 deletions(-)
>
Queue it in rust-sync
https://git.kernel.org/pub/scm/linux/kernel/git/boqun/linux.git/ rust-sync
Thank you all!
Regards,
Boqun
>
> base-commit: 43a393185e33e573a374c1d4f7ddf6481484ef8d
> --
> 2.54.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-24 15:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 15:07 [PATCH v3 0/3] Add and use abstraction for synchronize_rcu() Philipp Stanner
2026-06-24 15:07 ` [PATCH v3 1/3] rust: sync: Add " Philipp Stanner
2026-06-24 15:07 ` [PATCH v3 2/3] rust: revocable: Use safe synchronize_rcu() abstraction Philipp Stanner
2026-06-24 15:07 ` [PATCH v3 3/3] rust: sync: Use safe synchronize_rcu() abstraction in poll Philipp Stanner
2026-06-24 15:30 ` [PATCH v3 0/3] Add and use abstraction for synchronize_rcu() Boqun Feng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.