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
1848{1848{
1849 mutex_lock(&wq_pool_attach_mutex);1849 mutex_lock(&wq_pool_attach_mutex);
1850 1850
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
1857 /*1851 /*
1858 * The wq_pool_attach_mutex ensures %POOL_DISASSOCIATED remains1852 * The wq_pool_attach_mutex ensures %POOL_DISASSOCIATED remains
1859 * stable across this function. See the comments above the flag1853 * 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
1864 else1858 else
1865 kthread_set_per_cpu(worker->task, pool->cpu);1859 kthread_set_per_cpu(worker->task, pool->cpu);
1866 1860
1861 if (worker->rescue_wq)
1862 set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask);
1863
1867 list_add_tail(&worker->node, &pool->workers);1864 list_add_tail(&worker->node, &pool->workers);
1868 worker->pool = pool;1865 worker->pool = pool;
1869 1866