Re: [PATCH 0/3] rust: workqueue: add safe cancellation and status methods

Onur Özkan
2026-04-02T11:19:37Z

Hi Aakash,

On Thu, 02 Apr 2026 08:53:45 +0530
Aakash Bollineni via B4 Relay
<devnull+aakash.bollineni.multicorewareinc.com@kernel.org> wrote:

> This series modernizes the Rust workqueue infrastructure by adding
> methods for status checking and safe cancellation. These capabilities
> are essential for implementing safe driver teardown paths, such as in
> 'Drop' implementations or device removal, where background tasks must
> be stopped before resources are freed.
> This version (v2) addresses the feedback from Miguel Ojeda:

I thought this series was v1 because it doesn't have the version
prefix. Please make sure to include the version tag in your subject
line (e.g., [PATCH v2 0/3]) so maintainers can track the revisions
properly.

Thanks,
Onur

> - The work has been split into a logical 3-patch series.
> - Spurious changes (top-level .kunitconfig) have been removed.
> - Initialization for DelayedWork is now handled via a robust C-helper
> (INIT_DELAYED_WORK) to ensure correct timer function registration.
> - Pointer arithmetic in the reclamation path has been simplified and
> verified to be underflow-free.
> Summary of changes:
> 1. Helpers: Adds C FFI wrappers for workqueue macros and robust
> DelayedWork initialization.
> 2. Core API: Implements is_pending(), cancel(), and cancel_sync() with
> guaranteed pointer reclamation and layout safety
> (#[repr(transparent)]). 3. Tests: Adds a comprehensive KUnit suite
> and a standalone stress-test sample.
> The implementation has been verified on x86_64 using KUnit (4/4
> PASSED) and confirmed to be race-free under high-load stress testing.
> Changelog v1 -> v2:
> - Split into a 3-patch series to separate helpers from API and tests.
> - Replaced manual timer initialization with
> rust_helper_init_delayed_work.
> - Fixed field offset arithmetic in container_of macro path.
> - Expanded KUnit tests to cover DelayedWork specifically.
> - Wrapped commit messages and cover letter to 75 columns.
>
> Signed-off-by: Aakash Bollineni
> <aakash.bollineni@multicorewareinc.com> ---
> Aakash Bollineni (3):
> rust: helpers: add workqueue helpers
> rust: workqueue: add safe cancellation and status methods
> rust: workqueue: add KUnit and sample stress tests
>
> rust/helpers/workqueue.c | 34 +++
> rust/kernel/workqueue.rs | 467
> +++++++++++++++++++++++++++++++++--- samples/rust/Makefile
> | 2 + samples/rust/rust_workqueue_test.rs | 214 +++++++++++++++++
> 4 files changed, 682 insertions(+), 35 deletions(-)
> ---
> base-commit: bf074eb6891be799174ff42e0051492681fdc045
> change-id: 20260402-rust-next-19ba03aad3f4
>
> Best regards,