From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B965F3D7D87 for ; Wed, 3 Jun 2026 17:07:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780506466; cv=none; b=syZ0/MDr+kyGEhHn47MEKCMD0CufUY13uRWjCfXkAW7J2K6h+OWD8cBprO9+Cc6o3FmBfoyFh0iiTgHGGEKw6XrjjeVoL0ALf/gntOSAGpjCwQ/rp3NtSBGB4rOBj+CkALUnLEIsfdmRWsHObmvYgFOT5L6XSOjgjqZDsBZxKrM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780506466; c=relaxed/simple; bh=EOkTGYKrSDYsCnFKice6l3hCAuTmWmjGp248dNODPBo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Iy378m2aMhYj6mUeVFNYaZQeRwRCD+PUoeQPCbmvOpSC8GDmWBEoVBRmjcyLYTb76pWvFda+Gc1WABucXoE/urQvvZTjR8wsFAgKWtVMAIqIwDPA09SnW0HMypfbC27NZJ0uMN6desX2QugEG9nHE3oDz5AFZHPX8a3c8EantN4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TfteH+Qo; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TfteH+Qo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15E801F00898; Wed, 3 Jun 2026 17:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780506465; bh=SUUl90bBxGO1B6lX433etgqNanyhS7+oA+suoDDsSXQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=TfteH+Qoi2UJLhzosqfIIf8mQyokOx+B8Df6uoEQj5ZZIk6zmhrL3qeq7M1pQW4ed RWhqwiZTinfwLqDbDa1CzHhZUKrpaF7MJjFBWmtjfc/Q2aXYMDhwYIipNjCtGlo3lR EukoiPXnVwFzvDcVqd8vgIj1HGSO5prweDlFuMXcZU8BKPym4/gTWElsXRuZSQe2Ii Hhn9v7R2wlM3pwkjaWwFRz+iDIi3Y3sW8xPimYi5z3JTuTZQvEONwqYU/L+Lq7TMEa Vj62kj/kmRDbd0+BSV1CtTV0WLoKJ/2cB8iSQjPnsELiZQHoqTG1wqgXDVomZ3uZMN yHczZCfpUoC8g== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.phl.internal (Postfix) with ESMTP id 5A4D3F4006B; Wed, 3 Jun 2026 13:07:43 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Wed, 03 Jun 2026 13:07:43 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEmLONpDl4bNrf+o6zh7xRwbhEQE5eD6c9jTYvZefMuZUkAi41AL8/OImTsC5i9Mv FCCYs9wuRgz0cwFVweEieedbLvtPWT2IVkFzHB8M2gC2apblN7NZFhdha5TasqrGtLE0qy uIFSFmNz9Lwt+qCdl/hUIX47wQGCUJhI/PqG3lSm+S3E8T/HrzvKYpzCKB5a5bEtK9KZcE CMnNtMh8kbiM+DSZG5zwYSR8lQ1de20HcPwXFuxABzYpPX+w4AEioZfxRDq1QUiV6eAz25 vHt34XXB4KaYPV9tPS+WT9MlsKuCFZ8Tp5uyQHVL4WDmpYCj9OUyEoAu750SBIL33RqdVI sGjIp7TDKYLDYzMPP87uaKBHVSrVdlm6LSToUW8e8AVbRZpj3y+rIe931HDmtONaaVHNPF zTTnO0fWMvmfjPAgFCd/f5aGuNUVrt5pBf3AhH4whkLI9eRP8qA8n4Ru4N62/JUgZMMYny zKViaMAMl/LmRM77fir82u82yv30qb0yXfSxdhtv/TukBnU6HY6ocUrPvw8GbvH/VmOjs4 11wKcORvSUIGO9DJ8pePVF0iEM1hwLzIq2gh+FIDAaGMg+BCNI8fFB2ROY+gZDGUL9T5V5 IH7JT93x17OaMC4zb7LSu/152uWJE89gBIskOFls7Blfaf9fadIdVj3GlhUw X-ME-Proxy: Feedback-ID: i8dbe485b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 3 Jun 2026 13:07:42 -0400 (EDT) Date: Wed, 3 Jun 2026 10:07:41 -0700 From: Boqun Feng To: Philipp Stanner Cc: Miguel Ojeda , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Sumit Semwal , Christian =?iso-8859-1?Q?K=F6nig?= , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Daniel Almeida , Greg Kroah-Hartman , Igor Korotin , Lorenzo Stoakes , Alexandre Courbot , FUJITA Tomonori , Krishna Ketan Rai , Shankari Anand , manos@pitsidianak.is, Boris Brezillon , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, rcu@vger.kernel.org Subject: Re: [PATCH 2/4] rust: rcu: add RcuBox type Message-ID: References: <20260530143541.229628-2-phasta@kernel.org> <20260530143541.229628-4-phasta@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260530143541.229628-4-phasta@kernel.org> On Sat, May 30, 2026 at 04:35:10PM +0200, Philipp Stanner wrote: > From: Alice Ryhl > A few minor things below: [...] > diff --git a/rust/kernel/sync/rcu/rcu_box.rs b/rust/kernel/sync/rcu/rcu_box.rs > new file mode 100644 > index 000000000000..2508fdb609ec > --- /dev/null > +++ b/rust/kernel/sync/rcu/rcu_box.rs > @@ -0,0 +1,145 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +// Copyright (C) 2026 Google LLC. > + > +//! Provides the `RcuBox` type for Rust allocations that live for a grace period. > + > +use core::{ops::Deref, ptr::NonNull}; > + > +use kernel::{ Let's use `crate::` here since RcuBox is part of the kernel crate. > + alloc::{self, AllocError}, > + bindings, > + ffi::c_void, > + prelude::*, > + sync::rcu::{ForeignOwnableRcu, Guard}, > + types::ForeignOwnable, > +}; > + > +/// A box that is freed with rcu. > +/// > +/// The value must be `Send`, as rcu may drop it on another thread. > +/// > +/// # Invariants > +/// > +/// * The pointer is valid and references a pinned `RcuBoxInner` allocated with `kmalloc`. > +/// * This `RcuBox` holds exclusive permissions to rcu free the allocation. > +pub struct RcuBox(NonNull>); > + > +struct RcuBoxInner { > + value: T, > + rcu_head: bindings::callback_head, Probably should reorder these fields. > +} > + > +// Note that `T: Sync` is required since when moving an `RcuBox`, the previous owner may still > +// access `&T` for one grace period. > +// > +// SAFETY: Ownership of the `RcuBox` allows for `&T` and dropping the `T`, so `T: Send + Sync` > +// implies `RcuBox: Send`. > +unsafe impl Send for RcuBox {} > + > +// SAFETY: `&RcuBox` allows for no operations other than those permitted by `&T`, so `T: Sync` > +// implies `RcuBox: Sync`. > +unsafe impl Sync for RcuBox {} @Alice, we have `T: Send` mostly because `RcuBox` itself has the `T: Send` bound? I.e. the to be `Sync` we actually don't need `T` being `Send`, right? Regards, Boqun [...]