From: "Gary Guo" <gary@garyguo.net>
To: "Gary Guo" <gary@garyguo.net>, "Alice Ryhl" <aliceryhl@google.com>
Cc: "Tejun Heo" <tj@kernel.org>, "Miguel Ojeda" <ojeda@kernel.org>,
"Lai Jiangshan" <jiangshanlai@gmail.com>,
"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>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
"Boqun Feng" <boqun@kernel.org>,
"Benno Lossin" <lossin@kernel.org>,
"Tamir Duberstein" <tamird@kernel.org>
Subject: Re: [PATCH v4 3/3] rust: workqueue: add creation of workqueues
Date: Fri, 13 Mar 2026 13:29:41 +0000 [thread overview]
Message-ID: <DH1OVJDQ3B1B.302K37FK77JPC@garyguo.net> (raw)
In-Reply-To: <DH1OS4RI52DR.165D2P9C5AW9Z@garyguo.net>
On Fri Mar 13, 2026 at 1:25 PM GMT, Gary Guo wrote:
> On Thu Mar 12, 2026 at 10:56 PM GMT, Alice Ryhl wrote:
>> On Thu, Mar 12, 2026 at 04:39:00PM +0000, Gary Guo wrote:
>>> > + flags: bindings::wq_flags,
>>> > + max_active: i32,
>>> > + _type: PhantomData<T>,
>>>
>>> Hmm, it is somewhat awkward to me that we are having a `PhantomData<T>` here,
>>> as `PhantomData` is documented to "behave as it it owns a `T`", but all the
>>> possible `T`s that we use here are uninhabited.
>>
>> I don't think this is an issue.
>
> Fair. I also don't think it's an issue, just awkward.
>
> I would rather make the uninhabited enums be just unit structs, though (like what we do
> for atomic ordering and device contexts).
One interesting idea with unit structs, is to allow the type to be passed in as
argument rather than having multiple new_ variants:
Queue::builder(wq::TypeUnbound).max_active(..).build(...)
This is the trick that we use to make atomic API looks nice, although in this
case it seems that it's not worth the hassle as it needs an extra import...
Best,
Gary
>
>>
>>> > + /// Build a single-threaded workqueue that executes jobs in order.
>>> > + ///
>>> > + /// # Examples
>>> > + ///
>>> > + /// ```
>>> > + /// use kernel::workqueue::Queue;
>>> > + ///
>>> > + /// let wq = Queue::new_ordered().build(c"my-wq")?;
>>> > + /// wq.try_spawn(GFP_KERNEL, || pr_info!("Hello from ordered wq"))?;
>>> > + /// # Ok::<(), Error>(())
>>> > + /// ```
>>> > + #[inline]
>>> > + #[doc(alias = "alloc_ordered_workqueue")]
>>> > + #[doc(alias = "__WQ_ORDERED")]
>>> > + pub fn new_ordered() -> Builder<TypeOrdered> {
>>> > + Builder {
>>> > + flags: bindings::wq_flags_WQ_UNBOUND | bindings::wq_flags___WQ_ORDERED,
>>> > + max_active: 0,
>>>
>>> This should be 1 instead of 0.
>>
>> Hmm, it's weird that the doc-test didn't catch this.
>
> It seems that there's no check for this in the __alloc_workqueue (which I guess
> makes sense, because there's a C macro for allocating ordered workqueue which
> doesn't take max_active and pass 1 along).
>
> The only assertion is in workqueue_set_max_active to prevent changing it after
> creation.
>
> Best,
> Gary
>
>>
>>> > +/// 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>,
>>> > +}
>>>
>>> This looks like something that can become `Owned<Queue>` when Andreas' series
>>> land?
>>
>> That's right.
>>
>> Alice
next prev parent reply other threads:[~2026-03-13 13:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2026-03-12 9:23 ` [PATCH v4 2/3] rust: workqueue: create workqueue subdirectory Alice Ryhl
2026-03-12 9:23 ` [PATCH v4 3/3] rust: workqueue: add creation of workqueues Alice Ryhl
2026-03-12 16:39 ` Gary Guo
2026-03-12 22:56 ` Alice Ryhl
2026-03-13 13:25 ` Gary Guo
2026-03-13 13:29 ` Gary Guo [this message]
2026-03-14 10:31 ` Alice Ryhl
2026-03-12 17:59 ` Danilo Krummrich
2026-03-14 10:30 ` Alice Ryhl
2026-03-16 10:43 ` Danilo Krummrich
2026-03-16 10:24 ` Andreas Hindborg
2026-03-16 10:57 ` Andreas Hindborg
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=DH1OVJDQ3B1B.302K37FK77JPC@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--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@kernel.org \
--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