workqueue: RCU protect wq->dfl_pwq and implement accessors for it
authorTejun Heo <tj@kernel.org>
Mon, 29 Jan 2024 18:11:24 +0000 (08:11 -1000)
committerTejun Heo <tj@kernel.org>
Mon, 29 Jan 2024 18:11:24 +0000 (08:11 -1000)
commit9f66cff212bb3c1cd25996aaa0dfd0c9e9d8baab
tree11eeb44d70cce5fc9b11078f9413a92748189e9f
parentc5404d4e6df6faba1007544b5f4e62c7c14416dd
workqueue: RCU protect wq->dfl_pwq and implement accessors for it

wq->cpu_pwq is RCU protected but wq->dfl_pwq isn't. This is okay because
currently wq->dfl_pwq is used only accessed to install it into wq->cpu_pwq
which doesn't require RCU access. However, we want to be able to access
wq->dfl_pwq under RCU in the future to access its __pod_cpumask and the code
can be made easier to read by making the two pwq fields behave in the same
way.

- Make wq->dfl_pwq RCU protected.

- Add unbound_pwq_slot() and unbound_pwq() which can access both ->dfl_pwq
  and ->cpu_pwq. The former returns the double pointer that can be used
  access and update the pwqs. The latter performs locking check and
  dereferences the double pointer.

- pwq accesses and updates are converted to use unbound_pwq[_slot]().

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Lai Jiangshan <jiangshanlai@gmail.com>
kernel/workqueue.c