Re: [PATCH v10 4/5] rust: sync: add SRCU abstraction
From: Gary Guo
Date: Fri Jul 10 2026 - 09:44:34 EST
On Sat Jun 13, 2026 at 7:40 AM BST, Onur Özkan wrote:
> Add a Rust abstraction for sleepable RCU (SRCU), backed by C srcu_struct.
> Provide FFI helpers and a safe wrapper with a guard-based API for read-side
> critical sections.
>
> Cleanup is handled via `PinnedDrop`. It first checks for active read-side
> sections and emits a warning if any guards were leaked. In that case, it
> waits in `synchronize_srcu()` rather than risking a UAF by freeing the
> `srcu_struct` that is still reachable from the C side. It then uses
> `srcu_barrier()` to drain pending callbacks before finally calling
> `cleanup_srcu_struct()`.
>
> Signed-off-by: Onur Özkan <work@xxxxxxxxxxxxx>
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
> ---
> rust/kernel/sync.rs | 2 +
> rust/kernel/sync/srcu.rs | 171 +++++++++++++++++++++++++++++++++++++++
> 2 files changed, 173 insertions(+)
> create mode 100644 rust/kernel/sync/srcu.rs