[RFC PATCH v2 0/2] workqueue: destroy_worker() vs isolated CPUs

From: Valentin Schneider
Date: Wed Jul 27 2022 - 07:54:20 EST


Hi folks,

Using a work struct from within the workqueue code itself is a bit scary, but
I've done more rigorous testing than for v1 and it's looking OK (at the very
least locking-wise).

Note that this affects all kworkers (not just percpu ones) for the sake of
consistency and to prevent adding extra corner cases. kthread_set_per_cpu(p, -1)
is a no-op for unbound kworkers, and IIUC the affinity change is not required
since unbound workers have to be affined to a subset of wq_unbound_cpumask, but
it shouldn't be harmful either.

2/2 is a simple and stupid stresser that forces extra pcpu kworkers to be
spawned on a specific CPU - I can then quickly test this on QEMU by making sure
said CPU is isolated on the cmdline.

Thanks to Tejun & Lai for the discussion thus far.

Revisions
=========

RFCv1 -> RFCv2
++++++++++++++

o Change the pool->timer into a delayed_work to have a sleepable context for
unbinding kworkers

Cheers,
Valentin

Valentin Schneider (2):
workqueue: Unbind workers before sending them to exit()
DEBUG: workqueue: kworker spawner

kernel/Makefile | 2 +-
kernel/workqueue.c | 118 ++++++++++++++++++++++++++++++++++-----------
kernel/wqstress.c | 69 ++++++++++++++++++++++++++
3 files changed, 159 insertions(+), 30 deletions(-)
create mode 100644 kernel/wqstress.c

--
2.31.1