Re: [PATCH 4/6 v3] sched/eevdf: Cancel slice protection if short slice task is eligible

From: Vincent Guittot

Date: Thu Jun 25 2026 - 08:40:37 EST


On Thu, 25 Jun 2026 at 08:00, K Prateek Nayak <kprateek.nayak@xxxxxxx> wrote:
>
> Hello Vincent,
>
> On 6/24/2026 8:42 PM, Vincent Guittot wrote:
> > @@ -9896,16 +9891,23 @@ static void wakeup_preempt_fair(struct rq *rq, struct task_struct *p, int wake_f
> > if (!nse && cfs_rq->nr_queued)
> > goto pick;
> >
> > + /*
> > + * If @p is eligible but not the next task to run then cancel protection
> > + * to prevent large scheduling latency
> > + */
> > + if (preempt_action == PREEMPT_WAKEUP_SHORT && entity_eligible(cfs_rq, pse))
> > + goto preempt;
>
> We handle "pse->slice < se->slice" case before "pse->sched_delayed" case
> and jump to "pick", but pse can get dequeued as a part of
> pick_next_entity() if it was delayed and picked.

yes

>
> I think we can reach here for PREEMPT_WAKEUP_SHORT after pse is
> completely dequeued from cfs_rq. If p is a task on root cfs_rq, we could
> have blocked the task entirely and ideally it shouldn't be referenced
> here.

I tried to find which use case calls wakeup_preempt_fair() for a
sched_delayed task but can't find it

>
> Since a wakeup of delayed entity / on delayed hierarchy will call
> wakeup_preempt() anyways, I think we should return early if we should
> directly jump to update if we see "pse->sched_delayed".

Fair enough. But we still need to consider the FORK case

>
> > +
> > if (sched_feat(RUN_TO_PARITY))
> > update_protect_slice(cfs_rq, se);
> >
> > return;
> >
> > preempt:
> > - if (preempt_action == PREEMPT_WAKEUP_SHORT) {
> > - cancel_protect_slice(se);
> > + cancel_protect_slice(se);
> > +
> > + if (preempt_action == PREEMPT_WAKEUP_SHORT && nse == pse)
> > set_next_buddy(&p->se);
> > - }
> >
> > resched_curr_lazy(rq);
> > }
>
> --
> Thanks and Regards,
> Prateek
>