Re: [PATCH] sched/fair: Restart hrtick after same-task repicks

From: Vincent Guittot

Date: Fri Sep 11 2026 - 10:23:32 EST


On Fri, 11 Sept 2026 at 15:59, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Fri, Sep 11, 2026 at 02:36:41PM +0200, Vincent Guittot wrote:
>
> > > @@ -15293,11 +15297,12 @@ static void set_next_task_fair(struct rq *rq, struct task_struct *p, bool first)
> > >
> > > WARN_ON_ONCE(se->sched_delayed);
> > >
> > > - if (hrtick_enabled_fair(rq))
> > > - hrtick_start_fair(rq, p);
> > > -
> > > update_misfit_status(p, rq);
> > > sched_fair_update_stop_tick(rq, p);
> > > +
> > > +repick:
> > > + if (hrtick_enabled_fair(rq))
> > > + hrtick_start_fair(rq, p);
> >
> > While at it, you might want to replace:
> > vdelta = se->deadline - se->vruntime;
> > by
> > vdelta = se->vprot - se->vruntime;
> > in hrtick_start_fair()
>
> That should be a separate patch.

ok

>
> >
> > > }
> > >
> > > void init_cfs_rq(struct cfs_rq *cfs_rq)
>
> But that made me thing; do we want something like so folded in here?
>
> Since we got picked again, we should set vprot again, no?

No, because we want to allow picking another task as soon as the
current task has run at least its "min" slice and a new eligible task
is enqueued instead of waiting the end of the next period of slice

This also means that we can't simply replace deadline by vprot as i
proposed above because once we are after vprot we need deadline

>
> ---
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -15279,11 +15279,8 @@ static void set_next_task_fair(struct rq
> se = &p->se;
> cfs_rq->curr = se;
>
> - if (on_rq) {
> + if (on_rq)
> reweight_eevdf(cfs_rq, se, weight, se->on_rq);
> - if (first)
> - set_protect_slice(cfs_rq, se);
> - }
>
> if (task_on_rq_queued(p)) {
> /*
> @@ -15301,6 +15298,9 @@ static void set_next_task_fair(struct rq
> sched_fair_update_stop_tick(rq, p);
>
> repick:
> + if (on_rq)
> + set_protect_slice(cfs_rq, se);
> +
> if (hrtick_enabled_fair(rq))
> hrtick_start_fair(rq, p);
> }