Skip to content

Commit 640f17c

Browse files
author
Peter Zijlstra
committed
workqueue: Restrict affinity change to rescuer
create_worker() will already set the right affinity using kthread_bind_mask(), this means only the rescuer will need to change it's affinity. Howveer, while in cpu-hot-unplug a regular task is not allowed to run on online&&!active as it would be pushed away quite agressively. We need KTHREAD_IS_PER_CPU to survive in that environment. Therefore set the affinity after getting that magic flag. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Valentin Schneider <[email protected]> Tested-by: Valentin Schneider <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 5c25b5f commit 640f17c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

kernel/workqueue.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,12 +1848,6 @@ static void worker_attach_to_pool(struct worker *worker,
18481848
{
18491849
mutex_lock(&wq_pool_attach_mutex);
18501850

1851-
/*
1852-
* set_cpus_allowed_ptr() will fail if the cpumask doesn't have any
1853-
* online CPUs. It'll be re-applied when any of the CPUs come up.
1854-
*/
1855-
set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask);
1856-
18571851
/*
18581852
* The wq_pool_attach_mutex ensures %POOL_DISASSOCIATED remains
18591853
* stable across this function. See the comments above the flag
@@ -1864,6 +1858,9 @@ static void worker_attach_to_pool(struct worker *worker,
18641858
else
18651859
kthread_set_per_cpu(worker->task, pool->cpu);
18661860

1861+
if (worker->rescue_wq)
1862+
set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask);
1863+
18671864
list_add_tail(&worker->node, &pool->workers);
18681865
worker->pool = pool;
18691866

0 commit comments

Comments
 (0)