sched/eevdf: Delayed dequeue task can't preempt

Load balancing can migrate delayed dequeue tasks to even the load between
CPUs.

sched_balance_rq()
  -> detach_task()
    -> deactivate_task(DEQUEUE_NOCLOCK)
    -> set_task_cpu(dst_cpu)

  -> attach_task()
    -> activate_task(ENQUEUE_NOCLOCK)
    -> wakeup_preempt()

A delayed task with shorter slice can be dequeued during pick_next_entity()
but then jump to preempt because eligible.

Always jump to update for delayed dequeue task even with shorter slice.

Fixes: ba0d3bf5f9 ("sched/eevdf: Cancel slice protection if short slice task is eligible")
Reported-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://patch.msgid.link/20260701164920.1571352-1-vincent.guittot@linaro.org
This commit is contained in:
Vincent Guittot
2026-07-02 09:43:17 +02:00
committed by Peter Zijlstra
parent 19b7bdc3a1
commit 04998aa548
+9 -4
View File
@@ -9948,6 +9948,13 @@ static void wakeup_preempt_fair(struct rq *rq, struct task_struct *p, int wake_f
if (unlikely(!normal_policy(p->policy)))
goto update;
/*
* Do not preempt for tasks that are sched_delayed as it would violate
* EEVDF to forcibly queue an ineligible task.
*/
if (pse->sched_delayed)
goto update;
/*
* If @p has a shorter slice than current and @p is eligible, override
* current's slice protection in order to allow preemption.
@@ -9959,11 +9966,9 @@ static void wakeup_preempt_fair(struct rq *rq, struct task_struct *p, int wake_f
/*
* Ignore wakee preemption on WF_FORK as it is less likely that
* there is shared data as exec often follow fork. Do not
* preempt for tasks that are sched_delayed as it would violate
* EEVDF to forcibly queue an ineligible task.
* there is shared data as exec often follow fork.
*/
if ((wake_flags & WF_FORK) || pse->sched_delayed)
if (wake_flags & WF_FORK)
goto update;
/* Prefer picking wakee soon if appropriate. */