Re: [PATCH 2/6 v2] sched/eevdf: Take into account current's lag when updating slice protection

From: Vincent Guittot

Date: Tue Jun 16 2026 - 08:25:03 EST


On Tue, 16 Jun 2026 at 05:52, K Prateek Nayak <kprateek.nayak@xxxxxxx> wrote:
>
> Hello Vincent,
>
> On 6/15/2026 9:54 PM, Vincent Guittot wrote:
> > @@ -1083,6 +1083,7 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
> > */
> > static inline void set_protect_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
> > {
> > + u64 vruntime = min_vruntime(se->vruntime, avg_vruntime(cfs_rq));
>
> set_protect_slice() is only called for set_next_entity(... first = true)
> which has to come from the pick where the entity has to be eligible and
> behind the avg_vruntime(cfs_rq) right?
>
> Is there a case where se->vruntime is ahead of the average here that
> I'm missing?

The use of avg_vruntime was originaly introduced in patch 6 and while
refactoring the patchset, I wrongly found "better" to introduce its
usage in patch 2 and use same code pattern for both update and
set_protect_slice but obviously the min_vrutime is useless for
set_protect as se->vruntime is earlier than avg_vruntime because it is
eligible




>
> > u64 slice = normalized_sysctl_sched_base_slice;
> > u64 vprot = se->deadline;
> >
> > @@ -1090,8 +1091,8 @@ static inline void set_protect_slice(struct cfs_rq *cfs_rq, struct sched_entity
> > slice = cfs_rq_min_slice(cfs_rq);
> >
> > slice = min(slice, se->slice);
> > - if (slice != se->slice)
> > - vprot = min_vruntime(vprot, se->vruntime + calc_delta_fair(slice, se));
> > + if (vruntime != se->vruntime || slice != se->slice)
> > + vprot = min_vruntime(vprot, vruntime + calc_delta_fair(slice, se));
> >
> > se->vprot = vprot;
> > }
> --
> Thanks and Regards,
> Prateek
>