[lkml]   [2022]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH 5.10 134/563] sched/fair: Fix detection of per-CPU kthreads waking a task
    From: Vincent Donnefort <>

    [ Upstream commit 8b4e74ccb582797f6f0b0a50372ebd9fd2372a27 ]

    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

    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 <>
    Signed-off-by: Peter Zijlstra (Intel) <>
    Reviewed-by: Vincent Guittot <>
    Reviewed-by: Valentin Schneider <>
    Signed-off-by: Sasha Levin <>
    kernel/sched/fair.c | 1 +
    1 file changed, 1 insertion(+)

    diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
    index c004e3b89c324..a7589552be5fc 100644
    --- a/kernel/sched/fair.c
    +++ b/kernel/sched/fair.c
    @@ -6284,6 +6284,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
    * pattern is IO completions.
    if (is_per_cpu_kthread(current) &&
    + in_task() &&
    prev == smp_processor_id() &&
    this_rq()->nr_running <= 1) {
    return prev;

     \ /
      Last update: 2022-01-25 01:20    [W:2.189 / U:0.164 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site