[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ef39d1a7-7f13-436d-adcf-cefd7cd854b4@nvidia.com>
Date: Fri, 16 Jan 2026 11:23:25 -0500
From: Joel Fernandes <joelagnelf@...dia.com>
To: Alice Ryhl <aliceryhl@...gle.com>, "Paul E. McKenney"
<paulmck@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>
Cc: Gary Guo <gary@...yguo.net>, Miguel Ojeda <ojeda@...nel.org>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
Neeraj Upadhyay <neeraj.upadhyay@...nel.org>,
Josh Triplett <josh@...htriplett.org>, Uladzislau Rezki <urezki@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>, Zqiang <qiang.zhang@...ux.dev>,
Andrew Ballance <andrewjballance@...il.com>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, rcu@...r.kernel.org,
maple-tree@...ts.infradead.org, linux-mm@...ck.org
Subject: Re: [PATCH RFC 1/2] rust: rcu: add RcuBox type
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
Powered by blists - more mailing lists