From: "Onur Özkan" <work@onurozkan.dev>
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, "Onur Özkan" <work@onurozkan.dev>
Subject: Re: [PATCH] rust: workqueue: fix SAFETY comment Arc refs in Pin<KBox<T>>
Date: Tue, 28 Apr 2026 13:57:49 +0300 [thread overview]
Message-ID: <20260428105751.193593-1-work@onurozkan.dev> (raw)
In-Reply-To: <20260425135701.34010-1-sagartaunk2@gmail.com>
On Sat, 25 Apr 2026 19:27:01 +0530
Sagar Taunk <sagartaunk2@gmail.com> 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.
> let boxed = unsafe { KBox::from_raw(ptr) };
> // SAFETY: The box was already pinned when it was enqueued.
> let pinned = unsafe { Pin::new_unchecked(boxed) };
> --
> 2.54.0
>
Thank you!
Reviewed-by: Onur Özkan <work@onurozkan.dev>
prev parent reply other threads:[~2026-04-28 10:57 UTC|newest]
Thread overview: 5+ 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
2026-04-26 13:38 ` Miguel Ojeda
2026-04-27 14:56 ` Alice Ryhl
2026-04-28 10:57 ` Onur Özkan [this message]
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=20260428105751.193593-1-work@onurozkan.dev \
--to=work@onurozkan.dev \
--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 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.