workqueue: Use a kthread_worker to release pool_workqueues
authorTejun Heo <tj@kernel.org>
Tue, 8 Aug 2023 01:57:23 +0000 (15:57 -1000)
committerTejun Heo <tj@kernel.org>
Tue, 8 Aug 2023 01:57:23 +0000 (15:57 -1000)
commit967b494e2fd143a9c1a3201422aceadb5fa9fbfc
tree896fa6d0a2c178c6b8b1abab214b812cc04e3af0
parentfcecfa8f271acdf130acbb30842e7848a138af0f
workqueue: Use a kthread_worker to release pool_workqueues

pool_workqueue release path is currently bounced to system_wq; however, this
is a bit tricky because this bouncing occurs while holding a pool lock and
thus has risk of causing a A-A deadlock. This is currently addressed by the
fact that only unbound workqueues use this bouncing path and system_wq is a
per-cpu workqueue.

While this works, it's brittle and requires a work-around like setting the
lockdep subclass for the lock of unbound pools. Besides, future changes will
use the bouncing path for per-cpu workqueues too making the current approach
unusable.

Let's just use a dedicated kthread_worker to untangle the dependency. This
is just one more kthread for all workqueues and makes the pwq release logic
simpler and more robust.

Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c