From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Sagar Taunk" <sagartaunk2@gmail.com>
Cc: <ojeda@kernel.org>, <aliceryhl@google.com>,
<bjorn3_gh@protonmail.com>, <boqun@kernel.org>,
<gary@garyguo.net>, <lossin@kernel.org>, <a.hindborg@kernel.org>,
<tmgross@umich.edu>, <dakr@kernel.org>, <contact@onurozkan.dev>,
<rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rust: workqueue: fix SAFETY comment Arc refs in Pin<KBox<T>>
Date: Sun, 26 Apr 2026 00:15:32 +0900 [thread overview]
Message-ID: <DI2C20BLZ28S.1BBI3HTPX8GBZ@nvidia.com> (raw)
In-Reply-To: <20260425135701.34010-1-sagartaunk2@gmail.com>
On Sat Apr 25, 2026 at 10:57 PM JST, Sagar Taunk wrote:
> The `WorkItemPointer` implementation for `Pin<KBox<T>>` contained SAFETY
> comments that incorrectly referenced `Arc::into_raw` instead of
> `KBox::into_raw`. This implementation uses `KBox`, not `Arc`, so update
> the comments to accurately reflect the actual ownership transfer.
>
> Suggested-by: Onur Özkan <contact@onurozkan.dev>
> Link: https://github.com/Rust-for-Linux/linux/issues/1233
> Signed-off-by: Sagar Taunk <sagartaunk2@gmail.com>
> ---
> rust/kernel/workqueue.rs | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
> index 7e253b6f299c..74c59f2b1c09 100644
> --- a/rust/kernel/workqueue.rs
> +++ b/rust/kernel/workqueue.rs
> @@ -890,9 +890,10 @@ unsafe impl<T, const ID: u64> WorkItemPointer<ID> for Pin<KBox<T>>
> unsafe extern "C" fn run(ptr: *mut bindings::work_struct) {
> // The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
> let ptr = ptr.cast::<Work<T, ID>>();
> - // SAFETY: This computes the pointer that `__enqueue` got from `Arc::into_raw`.
> + // SAFETY: This computes the pointer that `__enqueue` got from `KBox::into_raw`.
> let ptr = unsafe { T::work_container_of(ptr) };
> - // SAFETY: This pointer comes from `Arc::into_raw` and we've been given back ownership.
> + // SAFETY: This pointer comes from `KBox::into_raw` and we have been given back ownership,
> + // as the workqueue guarantees `run` is called exactly once.
Not sure if extending the comment is useful, but the comment looks correct.
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
next prev parent reply other threads:[~2026-04-25 15:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-25 13:57 [PATCH] rust: workqueue: fix SAFETY comment Arc refs in Pin<KBox<T>> Sagar Taunk
2026-04-25 15:15 ` Alexandre Courbot [this message]
2026-04-26 13:38 ` Miguel Ojeda
2026-04-27 14:56 ` Alice Ryhl
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=DI2C20BLZ28S.1BBI3HTPX8GBZ@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=contact@onurozkan.dev \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sagartaunk2@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox