History

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.

Peter Zijlstra committed 5 years ago

Commit 640f17c1 parent 5c25b5f1 file · +3 −6Browse files

Showing the changes to kernel/workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/workqueue.c+3−6
@@ -1848,12 +1848,6 @@ static void worker_attach_to_pool(struct worker *worker, · 1847 unmodified lines
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, · 4 unmodified lines
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