diff options
author | Peter Zijlstra <peterz@infradead.org> | 2021-01-15 21:08:36 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-02-07 16:48:38 +0300 |
commit | 1746d1dcae9a960052b7a956523cc1719f71513c (patch) | |
tree | b94081c84507d97bbe5f95fc23c2045f32d82db8 | |
parent | fbad32181af9c8c76698b16115c28a493c26a2ee (diff) | |
download | linux-1746d1dcae9a960052b7a956523cc1719f71513c.tar.xz |
workqueue: Restrict affinity change to rescuer
[ Upstream commit 640f17c82460e9724fd256f0a1f5d99e7ff0bda4 ]
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) <peterz@infradead.org>
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Tested-by: Valentin Schneider <valentin.schneider@arm.com>
Link: https://lkml.kernel.org/r/20210121103506.826629830@infradead.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | kernel/workqueue.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index cd98ef48345e..78600f97ffa7 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1729,12 +1729,6 @@ static void worker_attach_to_pool(struct worker *worker, mutex_lock(&wq_pool_attach_mutex); /* - * set_cpus_allowed_ptr() will fail if the cpumask doesn't have any - * online CPUs. It'll be re-applied when any of the CPUs come up. - */ - set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask); - - /* * The wq_pool_attach_mutex ensures %POOL_DISASSOCIATED remains * stable across this function. See the comments above the flag * definition for details. @@ -1742,6 +1736,9 @@ static void worker_attach_to_pool(struct worker *worker, if (pool->flags & POOL_DISASSOCIATED) worker->flags |= WORKER_UNBOUND; + if (worker->rescue_wq) + set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask); + list_add_tail(&worker->node, &pool->workers); worker->pool = pool; |