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. Verification: Compared the affinity of workqueue thread between before and after the fix, the affinity was 0xff before this commit that mean the thread could be bound to cpu0-7, the affinity was 0x3 after the fix with "kthread_cpus=0, 1", which only could be bound to cpu0, 1. Also checked unbound workqueue such as "writeback" whose affinity also was 0x3 with "kthread_cpus=0, 1". We did not find the commit break anything else. Closes-Bug: #1948639 Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com> Change-Id: I8afd56c8d0d0526d523accf3ea45ee02635b1602
This commit is contained in:
@@ -787,6 +787,7 @@ Patch7: 0008-Allow-dmar-quirks-for-broken-bioses.patch
|
||||
Patch8: 0009-tpm-ignore-burstcount-to-improve-tpm_tis-send-perfor.patch
|
||||
Patch9: 0010-restrict-iSCSI-kthreads-to-CPUs-in-cpu_kthread_mask.patch
|
||||
Patch10: 0011-scsi-smartpqi-Enable-sas_address-sysfs-for-SATA-dev.patch
|
||||
Patch11: 0012-workqueue-Affine-rescuer-threads-and-unbound-wqs.patch
|
||||
|
||||
# END OF PATCH DEFINITIONS
|
||||
%endif
|
||||
|
@@ -0,0 +1,55 @@
|
||||
From 9c5c44019a17897c46a2579a50abcd69f1bcb4a8 Mon Sep 17 00:00:00 2001
|
||||
From: "M. Vefa Bicakci" <vefa.bicakci@windriver.com>
|
||||
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 <vefa.bicakci@windriver.com>
|
||||
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
|
||||
---
|
||||
kernel/workqueue.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
|
||||
index 1e2ca744dadb..f208096f28f1 100644
|
||||
--- a/kernel/workqueue.c
|
||||
+++ b/kernel/workqueue.c
|
||||
@@ -4235,7 +4235,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;
|
||||
@@ -5927,7 +5927,7 @@ void __init workqueue_init_early(void)
|
||||
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
|
||||
|
@@ -820,6 +820,7 @@ Patch7: 0008-Allow-dmar-quirks-for-broken-bioses.patch
|
||||
Patch8: 0009-tpm-ignore-burstcount-to-improve-tpm_tis-send-perfor.patch
|
||||
Patch9: 0010-bpf-cgroups-Fix-cgroup-v2-fallback-on-v1-v2-mixed-mo.patch
|
||||
Patch10: 0011-scsi-smartpqi-Enable-sas_address-sysfs-for-SATA-dev.patch
|
||||
Patch11: 0012-workqueue-Affine-rescuer-threads-and-unbound-wqs.patch
|
||||
|
||||
# END OF PATCH DEFINITIONS
|
||||
%endif
|
||||
|
@@ -0,0 +1,55 @@
|
||||
From 9c5c44019a17897c46a2579a50abcd69f1bcb4a8 Mon Sep 17 00:00:00 2001
|
||||
From: "M. Vefa Bicakci" <vefa.bicakci@windriver.com>
|
||||
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 <vefa.bicakci@windriver.com>
|
||||
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
|
||||
---
|
||||
kernel/workqueue.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
|
||||
index 1e2ca744dadb..f208096f28f1 100644
|
||||
--- a/kernel/workqueue.c
|
||||
+++ b/kernel/workqueue.c
|
||||
@@ -4235,7 +4235,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;
|
||||
@@ -5927,7 +5927,7 @@ void __init workqueue_init_early(void)
|
||||
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
|
||||
|
Reference in New Issue
Block a user