On 1/16/2026 10:46 AM, Alice Ryhl wrote:
> +impl<T: Send> Drop for RcuBox<T> {
> +    fn drop(&mut self) {
> +        // SAFETY: The `rcu_head` field is in-bounds of a valid allocation.
> +        let rcu_head = unsafe { &raw mut (*self.0.as_ptr()).rcu_head };
> +        if core::mem::needs_drop::<T>() {
> +            // SAFETY: `rcu_head` is the `rcu_head` field of 
> `RcuBoxInner<T>`. All users will be
> +            // gone in an rcu grace period. This is the destructor, so we 
> may pass ownership of the
> +            // allocation.
> +            unsafe { bindings::call_rcu(rcu_head, Some(drop_rcu_box::<T>)) };
> +        } else {
> +            // SAFETY: All users will be gone in an rcu grace period.
> +            unsafe { bindings::kvfree_call_rcu(rcu_head, 
> self.0.as_ptr().cast()) };
> +        }
> +    }

We should probably add support for asynchronous callbacks for Rust instead of
directly calling the bindings in Rcubox. I know Boqun and me talked about that a
while back, and there was a usecase missing. Perhaps, RcuBox is a good use case
for the same?

 - Joel


Reply via email to