From: Alice Ryhl <aliceryhl@google.com>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: "Tejun Heo" <tj@kernel.org>, "Miguel Ojeda" <ojeda@kernel.org>,
"Lai Jiangshan" <jiangshanlai@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"John Hubbard" <jhubbard@nvidia.com>,
"Philipp Stanner" <phasta@kernel.org>,
"Tamir Duberstein" <tamird@gmail.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
"Benno Lossin" <lossin@kernel.org>
Subject: Re: [PATCH v2 2/2] rust: workqueue: add creation of workqueues
Date: Fri, 14 Nov 2025 09:44:56 +0000 [thread overview]
Message-ID: <aRb6GPDZo3kaoeKm@google.com> (raw)
In-Reply-To: <aRY28VITGL53zenZ@tardis.local>
On Thu, Nov 13, 2025 at 11:52:17AM -0800, Boqun Feng wrote:
> On Thu, Nov 13, 2025 at 10:01:07AM +0000, Alice Ryhl wrote:
> > Creating workqueues is needed by various GPU drivers. Not only does it
> > give you better control over execution, it also allows devices to ensure
> > that all tasks have exited before the device is unbound (or similar) by
> > running the workqueue destructor.
> >
> > A wrapper type Flags is provided for workqueue flags. It allows you to
> > build any valid flag combination, while using a type-level marker for
> > whether WQ_BH is used to prevent invalid flag combinations. The Flags wrapper
> > also forces you to explicitly pick one of percpu, unbound, or bh.
> >
> > Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> [...]
> > +/// An owned kernel work queue.
> > +///
> > +/// Dropping a workqueue blocks on all pending work.
> > +///
> > +/// # Invariants
> > +///
> > +/// `queue` points at a valid workqueue that is owned by this `OwnedQueue`.
> > +pub struct OwnedQueue {
> > + queue: NonNull<Queue>,
>
> I hope Owned/Ownable can make it just a Owned<Queue> here ;-) And
> that'll make Owned<Queue> automatically Send + Sync. I think it's not a
> rare ask for `OwnedQueue` to be Send + Sync.
Oh yeah it should be Send/Sync.
And hopefully we get Owned eventually.
> > +}
> > +
> > +#[expect(clippy::manual_c_str_literals)]
> > +impl OwnedQueue {
> > + /// Allocates a new workqueue.
> > + ///
> > + /// The provided name is used verbatim as the workqueue name.
> > + ///
> > + /// # Examples
> > + ///
> > + /// ```
> > + /// use kernel::c_str;
> > + /// use kernel::workqueue::{OwnedQueue, Flags};
> > + ///
> > + /// let wq = OwnedQueue::new(c_str!("my-wq"), Flags::unbound().sysfs(), 0)?;
> > + /// wq.try_spawn(
> > + /// GFP_KERNEL,
> > + /// || pr_warn!("Printing from my-wq"),
> > + /// )?;
> > + /// # Ok::<(), Error>(())
> > + /// ```
> > + #[inline]
> > + pub fn new<const BH: bool>(
> > + name: &CStr,
> > + flags: Flags<BH>,
> > + max_active: usize,
>
> Do we need to support `max_active` as `usize` when the underlying C
> code only support i32?
Negative values don't really make sense. But maybe it's a good idea,
yeah.
Alice
next prev parent reply other threads:[~2025-11-14 9:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 10:01 [PATCH v2 0/2] Creation of workqueues in Rust Alice Ryhl
2025-11-13 10:01 ` [PATCH v2 1/2] rust: workqueue: restrict delayed work to global wqs Alice Ryhl
2025-11-13 10:06 ` Miguel Ojeda
2025-11-13 10:08 ` Alice Ryhl
2025-11-13 11:58 ` Miguel Ojeda
2025-11-13 20:40 ` John Hubbard
2025-11-13 21:06 ` Miguel Ojeda
2025-11-13 10:01 ` [PATCH v2 2/2] rust: workqueue: add creation of workqueues Alice Ryhl
2025-11-13 19:52 ` Boqun Feng
2025-11-14 9:44 ` Alice Ryhl [this message]
2025-11-13 21:55 ` Danilo Krummrich
2025-11-14 0:26 ` John Hubbard
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=aRb6GPDZo3kaoeKm@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=phasta@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@gmail.com \
--cc=tj@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).