* [PATCH v4 0/3] Creation of workqueues in Rust
@ 2026-03-12 9:23 Alice Ryhl
2026-03-12 9:23 ` [PATCH v4 1/3] rust: workqueue: restrict delayed work to global wqs Alice Ryhl
0 siblings, 1 reply; 3+ messages in thread
From: Alice Ryhl @ 2026-03-12 9:23 UTC (permalink / raw)
To: Tejun Heo, Miguel Ojeda
Cc: Lai Jiangshan, Gary Guo, Björn Roy Baron, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, John Hubbard,
Philipp Stanner, rust-for-linux, linux-kernel, Alice Ryhl,
Boqun Feng, Benno Lossin, Tamir Duberstein, stable
GPU drivers often need to create their own workqueues for various
reasons. Add the ability to do so.
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
Changes in v4:
- Add link to delayed work fix.
- Redo workqueue creation to prevent invalid configurations.
- Introduce a directory as workqueue.rs was getting really large.
- Link to v3: https://lore.kernel.org/r/20260227-create-workqueue-v3-0-87de133f7849@google.com
Changes in v3:
- Switch to builder pattern.
- Drop BH workqueues for now.
- Mark delayed wq change as fix.
- Link to v2: https://lore.kernel.org/r/20251113-create-workqueue-v2-0-8b45277119bc@google.com
Changes in v2:
- Redo how flagging works.
- Restrict delayed work to not be usable on custom workqueues.
- Link to v1: https://lore.kernel.org/r/20250411-create-workqueue-v1-1-f7dbe7f1e05f@google.com
---
Alice Ryhl (3):
rust: workqueue: restrict delayed work to global wqs
rust: workqueue: create workqueue subdirectory
rust: workqueue: add creation of workqueues
MAINTAINERS | 1 +
rust/helpers/workqueue.c | 7 +
rust/kernel/workqueue/builder.rs | 380 +++++++++++++++++++++++++
rust/kernel/{workqueue.rs => workqueue/mod.rs} | 53 +++-
4 files changed, 437 insertions(+), 4 deletions(-)
---
base-commit: df9c51269a5e2a6fbca2884a756a4011a5e78748
change-id: 20250411-create-workqueue-d053158c7a4b
Best regards,
--
Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v4 1/3] rust: workqueue: restrict delayed work to global wqs 2026-03-12 9:23 [PATCH v4 0/3] Creation of workqueues in Rust Alice Ryhl @ 2026-03-12 9:23 ` Alice Ryhl 2026-03-16 10:24 ` Andreas Hindborg 0 siblings, 1 reply; 3+ messages in thread From: Alice Ryhl @ 2026-03-12 9:23 UTC (permalink / raw) To: Tejun Heo, Miguel Ojeda Cc: Lai Jiangshan, Gary Guo, Björn Roy Baron, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Daniel Almeida, John Hubbard, Philipp Stanner, rust-for-linux, linux-kernel, Alice Ryhl, Boqun Feng, Benno Lossin, Tamir Duberstein, stable When a workqueue is shut down, delayed work that is pending but not scheduled does not get properly cleaned up, so it's not safe to use `enqueue_delayed` on a workqueue that might be destroyed. To fix this, restricted `enqueue_delayed` to static queues. This may be fixed in the future by an approach along the lines of [1]. Cc: stable@vger.kernel.org Fixes: 7c098cd5eaae ("workqueue: rust: add delayed work items") Reviewed-by: John Hubbard <jhubbard@nvidia.com> Reviewed-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Gary Guo <gary@garyguo.net> Link: https://lore.kernel.org/r/20250423-destroy-workqueue-flush-v1-1-3d74820780a5@google.com [1] Signed-off-by: Alice Ryhl <aliceryhl@google.com> --- rust/kernel/workqueue.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs index 706e833e9702..1acd113c04ee 100644 --- a/rust/kernel/workqueue.rs +++ b/rust/kernel/workqueue.rs @@ -296,8 +296,15 @@ pub fn enqueue<W, const ID: u64>(&self, w: W) -> W::EnqueueOutput /// /// This may fail if the work item is already enqueued in a workqueue. /// + /// This is only valid for global workqueues (with static lifetimes) because those are the only + /// ones that outlive all possible delayed work items. + /// /// The work item will be submitted using `WORK_CPU_UNBOUND`. - pub fn enqueue_delayed<W, const ID: u64>(&self, w: W, delay: Jiffies) -> W::EnqueueOutput + pub fn enqueue_delayed<W, const ID: u64>( + &'static self, + w: W, + delay: Jiffies, + ) -> W::EnqueueOutput where W: RawDelayedWorkItem<ID> + Send + 'static, { -- 2.53.0.473.g4a7958ca14-goog ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4 1/3] rust: workqueue: restrict delayed work to global wqs 2026-03-12 9:23 ` [PATCH v4 1/3] rust: workqueue: restrict delayed work to global wqs Alice Ryhl @ 2026-03-16 10:24 ` Andreas Hindborg 0 siblings, 0 replies; 3+ messages in thread From: Andreas Hindborg @ 2026-03-16 10:24 UTC (permalink / raw) To: Alice Ryhl, Tejun Heo, Miguel Ojeda Cc: Lai Jiangshan, Gary Guo, Björn Roy Baron, Trevor Gross, Danilo Krummrich, Daniel Almeida, John Hubbard, Philipp Stanner, rust-for-linux, linux-kernel, Alice Ryhl, Boqun Feng, Benno Lossin, Tamir Duberstein, stable "Alice Ryhl" <aliceryhl@google.com> writes: > When a workqueue is shut down, delayed work that is pending but not > scheduled does not get properly cleaned up, so it's not safe to use > `enqueue_delayed` on a workqueue that might be destroyed. To fix this, > restricted `enqueue_delayed` to static queues. > > This may be fixed in the future by an approach along the lines of [1]. > > Cc: stable@vger.kernel.org > Fixes: 7c098cd5eaae ("workqueue: rust: add delayed work items") > Reviewed-by: John Hubbard <jhubbard@nvidia.com> > Reviewed-by: Danilo Krummrich <dakr@kernel.org> > Reviewed-by: Gary Guo <gary@garyguo.net> > Link: https://lore.kernel.org/r/20250423-destroy-workqueue-flush-v1-1-3d74820780a5@google.com [1] > Signed-off-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Best regards, Andreas Hindborg ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-16 10:57 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-12 9:23 [PATCH v4 0/3] Creation of workqueues in Rust Alice Ryhl 2026-03-12 9:23 ` [PATCH v4 1/3] rust: workqueue: restrict delayed work to global wqs Alice Ryhl 2026-03-16 10:24 ` Andreas Hindborg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox