From: Gary Guo <gary@garyguo.net>
To: Benno Lossin <lossin@kernel.org>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>, "Tejun Heo" <tj@kernel.org>,
"Tamir Duberstein" <tamird@gmail.com>,
"Dirk Behme" <dirk.behme@gmail.com>,
"Alban Kurti" <kurti@invicto.ai>, "Fiona Behrens" <me@kloenk.dev>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] rust: pin-init: add pin projections to `#[pin_data]`
Date: Wed, 10 Sep 2025 23:20:27 +0100 [thread overview]
Message-ID: <20250910232027.332a840a.gary@garyguo.net> (raw)
In-Reply-To: <20250905171209.944599-2-lossin@kernel.org>
On Fri, 5 Sep 2025 19:12:07 +0200
Benno Lossin <lossin@kernel.org> wrote:
> Make the `#[pin_data]` macro generate a `*Projection` struct that holds
> either `Pin<&mut Field>` or `&mut Field` for every field of the original
> struct. Which version is chosen depends on weather there is a `#[pin]`
> or not respectively. Access to this projected version is enabled through
> generating `fn project(self: Pin<&mut Self>) -> SelfProjection<'_>`.
>
> Link: https://github.com/Rust-for-Linux/pin-init/pull/75/commits/2d698367d646c7ede90e01aa22842c1002d017b3
> [ Adapt workqueue to use the new projection instead of its own, custom
> one - Benno ]
> Signed-off-by: Benno Lossin <lossin@kernel.org>
LGTM, make sure to remove the spurious comment that Alice mentioned.
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> rust/kernel/workqueue.rs | 10 ++-----
> rust/pin-init/src/macros.rs | 60 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 62 insertions(+), 8 deletions(-)
>
> diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
> index b9343d5bc00f..6ca14c629643 100644
> --- a/rust/kernel/workqueue.rs
> +++ b/rust/kernel/workqueue.rs
> @@ -356,18 +356,12 @@ struct ClosureWork<T> {
> func: Option<T>,
> }
>
> -impl<T> ClosureWork<T> {
> - fn project(self: Pin<&mut Self>) -> &mut Option<T> {
> - // SAFETY: The `func` field is not structurally pinned.
> - unsafe { &mut self.get_unchecked_mut().func }
> - }
> -}
> -
> impl<T: FnOnce()> WorkItem for ClosureWork<T> {
> type Pointer = Pin<KBox<Self>>;
>
> fn run(mut this: Pin<KBox<Self>>) {
> - if let Some(func) = this.as_mut().project().take() {
> + if let Some(func) = this.as_mut().project().func.take() {
> + // if let Some(func) = this.as_mut().project_func().take() {
> (func)()
> }
> }
next prev parent reply other threads:[~2025-09-10 22:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 17:12 [PATCH 1/2] rust: pin-init: rename `project` -> `project_this` in doctest Benno Lossin
2025-09-05 17:12 ` [PATCH 2/2] rust: pin-init: add pin projections to `#[pin_data]` Benno Lossin
2025-09-10 10:23 ` Alice Ryhl
2025-09-10 10:24 ` Alice Ryhl
2025-09-10 10:38 ` Benno Lossin
2025-09-10 10:38 ` Benno Lossin
2025-09-10 10:54 ` Alice Ryhl
2025-09-10 12:18 ` Benno Lossin
2025-09-10 12:28 ` Alice Ryhl
2025-09-10 12:52 ` Benno Lossin
2025-09-11 3:31 ` Boqun Feng
2025-09-10 22:20 ` Gary Guo [this message]
2025-09-11 21:32 ` [PATCH 1/2] rust: pin-init: rename `project` -> `project_this` in doctest Benno Lossin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250910232027.332a840a.gary@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=dirk.behme@gmail.com \
--cc=kurti@invicto.ai \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=me@kloenk.dev \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@gmail.com \
--cc=tj@kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.