Re: [PATCH] sched/eevdf: Delayed dequeue task can't preempt
From: Vincent Guittot
Date: Thu Jul 02 2026 - 04:08:20 EST
On Thu, 2 Jul 2026 at 06:56, K Prateek Nayak <kprateek.nayak@xxxxxxx> wrote:
>
> Hello Vincent,
>
> On 7/1/2026 10:19 PM, Vincent Guittot wrote:
> > 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: ba0d3bf5f97b ("sched/eevdf: Cancel slice protection if short slice task is eligible")
> > Reported-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
> > Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
>
> Thank you for fixing this! Feel free to include:
>
> Reviewed-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
> Tested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
>
> > ---
> > kernel/sched/fair.c | 13 +++++++++----
> > 1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index fc6cd55f9d22..df8c9c2c7918 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -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;
> > +
>
> Small question: Are we updating the protect slice just to maintain the
> lag bounds with delayed entities?
Yes, maintaining the lag for delayed entities also helps to maintain
lag for other entities
>
> Otherwise, it might be okay to return early here and keep the current
> running for a bit longer and wait until the delayed entity gets a wakeup
> which does a wakeup_preempt().
>
> /me goes and checks
>
> My hackbench run says:
>
> Test: vanilla early_return
> 1-groups: 4.75 (0.00 pct) 4.46 ( 6.10 pct)
> 2-groups: 4.52 (0.00 pct) 4.57 (-1.10 pct)
> 4-groups: 4.67 (0.00 pct) 4.73 (-1.28 pct)
> 8-groups: 7.09 (0.00 pct) 6.85 ( 3.38 pct)
> 16-groups: 12.07 (0.00 pct) 12.03 ( 0.33 pct)
>
> but there is enough variance in the improved runs that it could all be
> noise so your patch should be good as is.
>
> --
> Thanks and Regards,
> Prateek
>