提交 812289cc 编写于 作者: V Vincent Donnefort 提交者: Zheng Zengkai

sched/fair: Fix detection of per-CPU kthreads waking a task

stable inclusion
from stable-v5.10.94
commit d7d5b3bc5263cb82c5673e5972aba543f96199fa
bugzilla: https://gitee.com/openeuler/kernel/issues/I531X9

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d7d5b3bc5263cb82c5673e5972aba543f96199fa

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

[ Upstream commit 8b4e74cc ]

select_idle_sibling() has a special case for tasks woken up by a per-CPU
kthread, where the selected CPU is the previous one. However, the current
condition for this exit path is incomplete. A task can wake up from an
interrupt context (e.g. hrtimer), while a per-CPU kthread is running. A
such scenario would spuriously trigger the special case described above.
Also, a recent change made the idle task like a regular per-CPU kthread,
hence making that situation more likely to happen
(is_per_cpu_kthread(swapper) being true now).

Checking for task context makes sure select_idle_sibling() will not
interpret a wake up from any other context as a wake up by a per-CPU
kthread.

Fixes: 52262ee5 ("sched/fair: Allow a per-CPU kthread waking a task to stack on the same CPU, to fix XFS performance regression")
Signed-off-by: NVincent Donnefort <vincent.donnefort@arm.com>
Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: NVincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: NValentin Schneider <valentin.schneider@arm.com>
Link: https://lore.kernel.org/r/20211201143450.479472-1-vincent.donnefort@arm.comSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 d0990b28
...@@ -6407,6 +6407,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target) ...@@ -6407,6 +6407,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
* pattern is IO completions. * pattern is IO completions.
*/ */
if (is_per_cpu_kthread(current) && if (is_per_cpu_kthread(current) &&
in_task() &&
prev == smp_processor_id() && prev == smp_processor_id() &&
this_rq()->nr_running <= 1) { this_rq()->nr_running <= 1) {
SET_STAT(found_idle_cpu_easy); SET_STAT(found_idle_cpu_easy);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册