Re: [PATCH] sched/pelt: avoid underestimate of task utilization

From: Vincent Guittot
Date: Fri Nov 24 2023 - 07:05:08 EST


On Fri, 24 Nov 2023 at 11:44, Hongyan Xia <hongyan.xia2@xxxxxxx> wrote:
>
> On 22/11/2023 14:01, Vincent Guittot wrote:
> > [...]
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 07f555857698..eeb505d28905 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -4774,6 +4774,11 @@ static inline unsigned long task_util(struct task_struct *p)
> > return READ_ONCE(p->se.avg.util_avg);
> > }
> >
> > +static inline unsigned long task_runnable(struct task_struct *p)
> > +{
> > + return READ_ONCE(p->se.avg.runnable_avg);
> > +}
> > +
> > static inline unsigned long _task_util_est(struct task_struct *p)
> > {
> > struct util_est ue = READ_ONCE(p->se.avg.util_est);
> > @@ -4892,6 +4897,14 @@ static inline void util_est_update(struct cfs_rq *cfs_rq,
> > if (task_util(p) > arch_scale_cpu_capacity(cpu_of(rq_of(cfs_rq))))
> > return;
> >
> > + /*
> > + * To avoid underestimate of task utilization, skip updates of ewma if
> > + * we cannot grant that thread got all CPU time it wanted.
> > + */
> > + if ((ue.enqueued + UTIL_EST_MARGIN) < task_runnable(p))
> > + goto done;
> > +
> > +
>
> Actually, does this also skip util_est increases as well, assuming no
> FASTUP? When a task is ramping up, another task could join and then
> blocks this task from ramping up its util_est.
>
> Or do we think this is intended behavior for !FASTUP?

sched_feat(UTIL_EST_FASTUP) has been there to disable faster ramp up
in case of regression but I'm not aware of anybody having to disable
it during the last 3 year so we should just delete the sched_feat()
and make faster ramp up permanent.

>
> > /*
> > * Update Task's estimated utilization
> > *