Re: [PATCH] workqueue: rust: add creation of workqueues
From: Danilo Krummrich
Date: Thu Apr 17 2025 - 16:36:26 EST
On Thu, Apr 17, 2025 at 10:26:04PM +0200, Alice Ryhl wrote:
> On Thu, Apr 17, 2025 at 9:28 AM Tejun Heo <tj@xxxxxxxxxx> wrote:
> >
> > On Thu, Apr 17, 2025 at 09:22:40AM +0200, Philipp Stanner wrote:
> > > I assume you, ultimately, mean that the list of delayed_work's would be
> > > accessible through workqueue_struct, correct?
> > >
> > > And then destroy_workqueue() could loop over all of them with
> > > cancel_delayed_work_sync()?
> >
> > Yeap, I was thinking flush_delayed_work() but maybe
> > cancel_delayed_work_sync() is better.
>
> But doesn't that have a cleanup problem? If the work item owns an
> allocation or a refcount that's cleared by the work item's run
> function, then using cancel_delayed_work_sync() will fail to clean
> that up. Whereas flush_delayed_work() avoids this problem.
I also think it may be a bit unexpected to users if pending "normal" work "will
be done first", but delayed work is canceled instead.
That sounds like a good source for wrong use. :(