On Fri, Jan 16, 2026 at 03:46:35PM +0000, Alice Ryhl wrote:
> I'm sending this RFC to share an experiment I'm looking at. This may let
> us replace the range allocator in Rust Binder with a maple tree.
> 

Thank you, Alice.

> An RcuBox is like a Box except that it lets you obtain a &T that
> outlives the box by a grace period. It does not allow mutable access to

I think the `RcuBox` can be folded into the more generic RCU pointer api
[1], e.g. Rcu<Box<RcuBoxInner<T>>> where RcuBoxInner<T>: HasRcuHead. The
benefits are at least 1) we use relaxed atomic read for RCU readers
which guarantees address dependency that RCU needs under LKMM (while in
the RcuBox here, we just use plain reads), 2) we also support mutable
access as well.

As for the progress of that effort, the Rcu atomic pointer is almost
ready [2], I will likely send it early next week. For the `HasRcuHead`
part, as you may be aware, I'm working on a generic `HasField` approach
to avoid duplication of `Has*` trait and macros [3], that requires some
syn adjustments from Gary and Benno, but they should be available next
cycle. I will probably send the patches for reviews before that. Once we
have that `HasRcuHead` should be easily to add.

Given the WIP code I have, I *think* we are not that far from providing
what you need for binder.

> the inner value (Binder would probably use LockedBy for inner values).
> 

[1]: 
https://lore.kernel.org/rust-for-linux/[email protected]/
[2]: 
https://git.kernel.org/pub/scm/linux/kernel/git/boqun/linux.git/log/?h=rust-sync
[3]: 
https://git.kernel.org/pub/scm/linux/kernel/git/boqun/linux.git/log/?h=rust-field

Regards,
Boqun

> Signed-off-by: Alice Ryhl <[email protected]>
> ---
> Alice Ryhl (2):
>       rust: rcu: add RcuBox type
>       rust: maple_tree: add load_rcu()
> 
>  rust/bindings/bindings_helper.h |   1 +
>  rust/kernel/maple_tree.rs       |  52 ++++++++++++++
>  rust/kernel/sync/rcu.rs         |  31 ++++++++-
>  rust/kernel/sync/rcu/rcu_box.rs | 145 
> ++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 228 insertions(+), 1 deletion(-)
> ---
> base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> change-id: 20260116-rcu-box-7a8e4c9f2180
> 
> Best regards,
> -- 
> Alice Ryhl <[email protected]>
> 

Reply via email to