提交 ba640420 编写于 作者: P Peter Zijlstra 提交者: Zheng Zengkai

workqueue: Restrict affinity change to rescuer

stable inclusion
from stable-5.10.14
commit b80df6517d350df10449a8fff755f24e847214db
bugzilla: 48051

--------------------------------

[ Upstream commit 640f17c8 ]

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: NPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: NValentin Schneider <valentin.schneider@arm.com>
Tested-by: NValentin Schneider <valentin.schneider@arm.com>
Link: https://lkml.kernel.org/r/20210121103506.826629830@infradead.orgSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 0eb1b04a
...@@ -1845,12 +1845,6 @@ static void worker_attach_to_pool(struct worker *worker, ...@@ -1845,12 +1845,6 @@ static void worker_attach_to_pool(struct worker *worker,
{ {
mutex_lock(&wq_pool_attach_mutex); 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 * The wq_pool_attach_mutex ensures %POOL_DISASSOCIATED remains
* stable across this function. See the comments above the flag * stable across this function. See the comments above the flag
...@@ -1859,6 +1853,9 @@ static void worker_attach_to_pool(struct worker *worker, ...@@ -1859,6 +1853,9 @@ static void worker_attach_to_pool(struct worker *worker,
if (pool->flags & POOL_DISASSOCIATED) if (pool->flags & POOL_DISASSOCIATED)
worker->flags |= WORKER_UNBOUND; worker->flags |= WORKER_UNBOUND;
if (worker->rescue_wq)
set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask);
list_add_tail(&worker->node, &pool->workers); list_add_tail(&worker->node, &pool->workers);
worker->pool = pool; worker->pool = pool;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册