Re: [PATCH 3/4] workqueue: Tag bound workers with KTHREAD_IS_PER_CPU

From: Peter Zijlstra
Date: Sat Jan 16 2021 - 12:11:12 EST


On Sat, Jan 16, 2021 at 10:45:04PM +0800, Lai Jiangshan wrote:
> On Sat, Jan 16, 2021 at 8:45 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> > It is also the exact sequence normal per-cpu threads (smpboot) use to
> > preserve affinity.
>
> Other per-cpu threads normally do short-live works. wq's work can be
> lengthy, cpu-intensive, heavy-lock-acquiring or even call
> get_online_cpus() which might result in a deadlock with kthread_park().

kthread_park() is called by the migration thread running the
workqueue_online_cpu() callback.

kthread_parkme() is called by the worker thread, after it completes a
work and has no locks held from that context.