Re: [PATCH] workqueue: rust: add creation of workqueues

From: Tejun Heo
Date: Tue Apr 15 2025 - 13:03:08 EST


On Tue, Apr 15, 2025 at 09:05:16AM +0000, Alice Ryhl wrote:
> On Mon, Apr 14, 2025 at 07:23:42AM -1000, Tejun Heo wrote:
> > Hello,
> >
> > On Fri, Apr 11, 2025 at 03:34:24PM +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.
> > >
> > > This patch is being developed in parallel with the new Owned type [1].
> > > The OwnedQueue struct becomes redundant once [1] lands; at that point it
> > > can be replaced with Owned<Queue>, and constructors can be moved to the
> > > Queue type.
> > >
> > > A wrapper type WqFlags is provided for workqueue flags. Since we only
> > > provide the | operator for this wrapper type, this makes it impossible
> > > to pass internal workqueue flags to the workqueue constructor. It has
> > > the consequence that we need a separate constant for the no-flags case,
> > > as the constructor does not accept a literal 0. I named this constant
> > > "BOUND" to signify the opposite of UNBOUND.
> >
> > Maybe name it NONE or DUMMY? Doesn't affect this patch but [UN]BOUND are a
> > bit confusing and as a part of the effort to reduce unnecessary usage of
> > cpu-bound workqueues, there's a plan to flip the default and use PERCPU for
> > the cpu-bound workqueues.
>
> Happy with whatever you think is best, but what about naming the
> constant PERCPU, then? In fact, by adjusting how I declare the flags in
> Rust, it is possible to *force* the user to include exactly one of
> PERCPU, UNBOUND, or BH in the flags argument.

Oh yeah, if you can force a choice among those three, that sounds great.

Thanks.

--
tejun