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

From: Vincent Guittot

Date: Tue Jun 16 2026 - 08:52:16 EST


On Tue, 16 Jun 2026 at 07:34, K Prateek Nayak <kprateek.nayak@xxxxxxx> wrote:
>
> Hello Vincent,
>
> On 6/15/2026 9:54 PM, Vincent Guittot wrote:
> > @@ -9897,16 +9892,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;
>
> Can't we do this independent of the "pick" path if we are going to
> resched anyways?

This is for the case where the task is not the next one to be picked
(nse != pse) .i.e. pse is eligible, has a shorter slice than current
but doesn't have the earliest deadline

>
> I suppose it is for set_next_buddy() bits but, if nse == pse, we cancel
> the slice protection and resched anyways and the pick will naturally
> go to pse so does set_next_buddy() even matter?

We will not set_next_buddy in this case but only try to speed up the
scheduling of tasks with earlier deadlines.

>
> Instead, can PREEMPT_WAKEUP_SHORT path just do a set_preempt_buddy()
> beforehand to ensure the task with the smallest deadline is already
> the ->next and pick_next_entity() readily returns that?
>
> > +
> > 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
>