From 6039b821dbe26c7708537e07276316dca36c1c0f Mon Sep 17 00:00:00 2001 From: "M. Vefa Bicakci" Date: Thu, 9 Sep 2021 04:56:46 -0400 Subject: [PATCH] workqueue: Affine rescuer threads and unbound wqs This commit ensures that workqueue rescuer threads are affined to the platform CPUs specified by the "kthread_cpus" kernel argument. Prior to this commit, rescuer threads could be bound to any CPU. Rescuer threads are described in "kernel/workqueue.c" as follows: "Regular work processing on a pool may block trying to create a new worker which uses GFP_KERNEL allocation which has slight chance of developing into deadlock if some works currently on the same queue need to be processed to satisfy the GFP_KERNEL allocation. This is the problem rescuer solves. When such condition is possible, the pool summons rescuers of all workqueues which have works queued on the pool and let them process those works so that forward progress can be guaranteed." This commit also affines unbound workqueues to the platform CPUs instead of the housekeeping CPUs, because the latter can be a superset of the former. Signed-off-by: M. Vefa Bicakci Signed-off-by: Jiping Ma --- kernel/workqueue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 1a4151c6faa6..3e3bd8d75f3c 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -4242,7 +4242,7 @@ static int init_rescuer(struct workqueue_struct *wq) } wq->rescuer = rescuer; - kthread_bind_mask(rescuer->task, cpu_possible_mask); + kthread_bind_mask(rescuer->task, cpu_kthread_mask); wake_up_process(rescuer->task); return 0; @@ -5941,13 +5941,12 @@ static void __init wq_numa_init(void) void __init workqueue_init_early(void) { int std_nice[NR_STD_WORKER_POOLS] = { 0, HIGHPRI_NICE_LEVEL }; - int hk_flags = HK_FLAG_DOMAIN | HK_FLAG_WQ; int i, cpu; BUILD_BUG_ON(__alignof__(struct pool_workqueue) < __alignof__(long long)); BUG_ON(!alloc_cpumask_var(&wq_unbound_cpumask, GFP_KERNEL)); - cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(hk_flags)); + cpumask_copy(wq_unbound_cpumask, cpu_kthread_mask); pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC); -- 2.29.2