Skip to contentSkip to conversation

workqueue: Restrict kworker in the offline CPU pool running on housekeeping CPUs

PATCH Superseded Zqiang 2 participants 2 messages Mar 29, 2022 – Mar 31, 2022 Workqueue

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zqiang

author
#0 lore raw

PATCH 1/1 workqueue: Restrict kworker in the offline CPU pool running on housekeeping CPUs

When CPU going offline, all workers in this CPU pool will lose affinity to this CPU, and may run to isolated CPU. like kworker in unbound pool, set CPU affinity of these kworker is housekeeping cpumask.

---
 kernel/workqueue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/workqueue.c +2 -1
index abcc9a2ac319..c509ce73a783 100644
@@ -5023,7 +5023,8 @@ static void unbind_workers(int cpu)
 
 		for_each_pool_worker(worker, pool) {
 			kthread_set_per_cpu(worker->task, -1);
-			WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, cpu_possible_mask) < 0);
+			WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task,
+						housekeeping_cpumask(HK_TYPE_WQ)) < 0);
 		}
 
 		mutex_unlock(&wq_pool_attach_mutex);
Signature · 1 line
2.25.1
reviewer Acked-by on v1 1/1
#1 lore raw

I don't think the patch can be applied to the wq tree due to the change
https://lore.kernel.org/lkml/164512420798.16921.1042432342597886877.tip-bot2@tip-bot2/
which did the rename of HK_TYPE_WQ has not been merged into Linus's tree.

Quoted 28 lines · Zqiang

When CPU going offline, all workers in this CPU pool will lose affinity to this CPU, and may run to isolated CPU. like kworker in unbound pool, set CPU affinity of these kworker is housekeeping cpumask.

---
 kernel/workqueue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/workqueue.c +2 -2
index abcc9a2ac319..c509ce73a783 100644
@@ -5023,7 +5023,8 @@ static void unbind_workers(int cpu)
 
                for_each_pool_worker(worker, pool) {
                        kthread_set_per_cpu(worker->task, -1);
-                       WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, cpu_possible_mask) < 0);
+                       WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task,
+                                               housekeeping_cpumask(HK_TYPE_WQ)) < 0);
                }
 
                mutex_unlock(&wq_pool_attach_mutex);
--

2.25.1