sched/fair: Fix detection of per-CPU kthreads waking a task
authorVincent Donnefort <vincent.donnefort@arm.com>
Wed, 1 Dec 2021 14:34:50 +0000 (14:34 +0000)
committerPeter Zijlstra <peterz@infradead.org>
Sat, 4 Dec 2021 09:56:20 +0000 (10:56 +0100)
commit8b4e74ccb582797f6f0b0a50372ebd9fd2372a27
tree5cab618e8b82885b30fc9d00a42729e8e9a3fb23
parent8c92606ab81086db00cbb73347d124b4eb169b7e
sched/fair: Fix detection of per-CPU kthreads waking a task

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: 52262ee567ad ("sched/fair: Allow a per-CPU kthread waking a task to stack on the same CPU, to fix XFS performance regression")
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Link: https://lore.kernel.org/r/20211201143450.479472-1-vincent.donnefort@arm.com
kernel/sched/fair.c