Re: [PATCH] workqueue: Use private WQ for schedule_on_each_cpu() API

From: Tejun Heo
Date: Wed Feb 23 2022 - 17:29:08 EST


On Thu, Feb 24, 2022 at 07:26:30AM +0900, Tetsuo Handa wrote:
> > The patch seems pretty wrong. What's problematic is system workqueue flushes
> > (which flushes the entire workqueue), not work item flushes.
>
> Why? My understanding is that
>
> flushing a workqueue waits for completion of all work items in that workqueue
>
> flushing a work item waits for for completion of that work item using
> a workqueue specified as of queue_work()
>
> and
>
> if a work item in some workqueue is blocked by other work in that workqueue
> (e.g. max_active limit, work items on that workqueue and locks they need),
> it has a risk of deadlock
>
> . Then, how can flushing a work item using system-wide workqueues be free of deadlock risk?
> Isn't it just "unlikely to deadlock" rather than "impossible to deadlock"?

If we're jamming system_wq with a combination of work items which need more
than max_active to make forward progress, we're stuck regardless of flushes.
What's needed at that point is increasing max_active (or something along
that line).

Thanks.

--
tejun