Re: [PATCH v4 5/5] rust: workqueue: add ScopedWork for non-'static work items
From: Tejun Heo
Date: Thu Nov 26 2026 - 07:23:07 EST
Hello, Alice.
On Wed, Nov 25, 2026 at 06:17:52PM +0000, Alice Ryhl wrote:
> What I'd say is that this isn't the only way to spawn work on the
> workqueue. This utility is intended for use-cases where it's convenient
> to do it like that (e.g. because the queue is defined before the work
> item in the same struct). We already have another way of spawning work
> that uses different ownership rules (e.g. self-freeing work) and that
> mechanism would not go through ScopedWork.
This is your design and you know this area far better than I do, so please
take this with a grain of salt. That said, I wonder whether the interface
is more tortured and twisted than it needs to be.
Workqueue lifetime seems to add a layer of ugliness, at least going by the
restrictions on ScopedWork. Wouldn't that be relatively easy to solve by
adding a percpu refcnt to the Rust wrapper of workqueue and tying work and
delayed work items to it? Dropping the workqueue would wait until nothing
is pending, and cancelling delayed work items before that would be up to
the user. Work and delayed work items would then behave the same way and
be usable on any workqueue.
Thanks.
--
tejun