Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH] rust: workqueue: fix SAFETY comments in Pin<KBox<T>> run()
@ 2026-11-23 22:26 Andrea Tontini
  2026-11-24  0:29 ` Miguel Ojeda
  0 siblings, 1 reply; 2+ messages in thread
From: Andrea Tontini @ 2026-11-23 22:26 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Martin Rodriguez Reboredo,
	Tejun Heo, Andreas Hindborg (Samsung)
  Cc: rust-for-linux, Andrea Tontini

The `WorkItemPointer` implementation for `Pin<KBox<T>>` was copied from
the `Arc<T>` implementation, and the SAFETY comments in its `run()`
function still claim that the pointer comes from `Arc::into_raw`.

However, the matching `RawWorkItem::__enqueue` implementation for
`Pin<KBox<T>>` obtains the pointer from `KBox::into_raw`, which is also
what makes the subsequent `KBox::from_raw` call sound.

Update the comments to reference the correct function. No functional
change.

This patch was prepared with the help of an AI coding assistant (Claude
Code), which found the mismatch and wrote the change; it was reviewed
and build-tested with CLIPPY=1 by the submitter.

Fixes: 47f0dbe8fdc2 ("rust: workqueue: implement `WorkItemPointer` for pointer types")
Signed-off-by: Andrea Tontini <andreatontinidev@gmail.com>
---
 rust/kernel/workqueue.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
index a872f9fffb90..3815f08dfc0e 100644
--- a/rust/kernel/workqueue.rs
+++ b/rust/kernel/workqueue.rs
@@ -890,9 +890,9 @@ 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've been given back ownership.
         let boxed = unsafe { KBox::from_raw(ptr) };
         // SAFETY: The box was already pinned when it was enqueued.
         let pinned = unsafe { Pin::new_unchecked(boxed) };

---
base-commit: 4405c18c95d2d0f99f6c581ef0ee8591a1aa6ccd
change-id: 20261122-rust-workqueue-safety-comment-4bde8f258d52

Best regards,
--  
Andrea Tontini <andreatontinidev@gmail.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rust: workqueue: fix SAFETY comments in Pin<KBox<T>> run()
  2026-11-23 22:26 [PATCH] rust: workqueue: fix SAFETY comments in Pin<KBox<T>> run() Andrea Tontini
@ 2026-11-24  0:29 ` Miguel Ojeda
  0 siblings, 0 replies; 2+ messages in thread
From: Miguel Ojeda @ 2026-11-24  0:29 UTC (permalink / raw)
  To: Andrea Tontini, Sagar Taunk
  Cc: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Martin Rodriguez Reboredo,
	Tejun Heo, Andreas Hindborg (Samsung), rust-for-linux

On Mon, Nov 23, 2026 at 11:27 PM Andrea Tontini
<andreatontinidev@gmail.com> wrote:
>
> This patch was prepared with the help of an AI coding assistant (Claude
> Code), which found the mismatch and wrote the change; it was reviewed
> and build-tested with CLIPPY=1 by the submitter.

Thanks for the patch! This would normally go below the `---` line
(sometimes we do mention testing if there is something in particular
important to say, but build-testing and `CLIPPY=1`  are always
expected, so there is no need to mention it, especially in the commit
message).

Also, please see this patch as well:

  https://lore.kernel.org/rust-for-linux/20261025114304.16730-1-sagartaunk@proton.me/

Cc'ing Sagar.

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24  0:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 22:26 [PATCH] rust: workqueue: fix SAFETY comments in Pin<KBox<T>> run() Andrea Tontini
2026-11-24  0:29 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox