Re: [PATCH] sched/eevdf: Fix vprot across reweighting

From: Vincent Guittot

Date: Mon Oct 12 2026 - 10:20:29 EST


On Mon, 12 Oct 2026 at 15:59, Kayra Cizmeci <kayracizmeci@xxxxxxxxx> wrote:
>
> > I don't get why you need to a se->rel_vprot and all these changes . If
> > we want to ensure that protection will not be re enabled because of
> > rescale, we just need the below
>
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 5c98d8dfce5d..e83836fe44ef 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -4951,12 +4951,15 @@ static void reweight_eevdf(struct cfs_rq
> > *cfs_rq, struct sched_entity *se,
> > update_load_set(&se->h_load, weight);
> >
> > if (on_rq) {
> > - if (rel_vprot)
> > - se->vprot += avruntime;
> > se->deadline += avruntime;
> > se->rel_deadline = 0;
> > se->vruntime = avruntime - se->vlag;
> >
> > + if (rel_vprot)
> > + se->vprot += avruntime;
> > + else if (curr)
> > + se->vprot = se->vruntime;
> > +
> > if (!curr)
> > __enqueue_entity(cfs_rq, se);
> > cfs_rq->h_nr_queued++;
>
> > or the below which is even simpler because vprot, vlag and deadline
> > are rescaled with the same ratio but it implies useless div64_long()
> > when the protection is already canceled
>
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 5c98d8dfce5d..5d1b16780b52 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -4936,7 +4936,7 @@ static void reweight_eevdf(struct cfs_rq
> > *cfs_rq, struct sched_entity *se,
> > se->vlag = entity_lag(cfs_rq, se, avruntime);
> > se->deadline -= avruntime;
> > se->rel_deadline = 1;
> > - if (curr && protect_slice(se)) {
> > + if (curr) {
> > se->vprot -= avruntime;
> > rel_vprot = true;
> > }
>
> Here:
>
> https://lore.kernel.org/all/20261001164609.244156-1-kayracizmeci@xxxxxxxxx/
> https://lore.kernel.org/all/e4700a93-ebd5-4c7e-88b5-d606437a13c0@xxxxxxx/
>
> Because on_rq can get false. And alive protection complicates things.
> And this diff alone wouldn't work.
>
> IDK what else we could do to fix this both cases cleanly tbh.
> But there could be a cleaner way.

Before 819224e506bc ("sched/fair: Remove dead code on
enqueue_task_fair()"), the reweight_eevdf() was not called for curr so
the false was always true. If we can finally have enqueue curr then we
should skip this case

>
> Thanks,
>
> Kayra
>
>