workqueue: Protects wq_unbound_cpumask with wq_pool_attach_mutex
authorLai Jiangshan <jiangshan.ljs@antgroup.com>
Thu, 12 Jan 2023 16:14:27 +0000 (16:14 +0000)
committerTejun Heo <tj@kernel.org>
Thu, 12 Jan 2023 16:21:48 +0000 (06:21 -1000)
commit99c621ef243bda726fb8d982a274ded96570b410
tree8867dcce2a589037d7f7d9dbfdcb506738485b44
parentc76feb0d5dfdb90b70fa820bb3181142bb01e980
workqueue: Protects wq_unbound_cpumask with wq_pool_attach_mutex

When unbind_workers() reads wq_unbound_cpumask to set the affinity of
freshly-unbound kworkers, it only holds wq_pool_attach_mutex. This isn't
sufficient as wq_unbound_cpumask is only protected by wq_pool_mutex.

Make wq_unbound_cpumask protected with wq_pool_attach_mutex and also
remove the need of temporary saved_cpumask.

Fixes: 10a5a651e3af ("workqueue: Restrict kworker in the offline CPU pool running on housekeeping CPUs")
Reported-by: Valentin Schneider <vschneid@redhat.com>
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c