Re: [RFC PATCH 1/7] sched/pelt: Add a new function to approximate the future util_avg value

From: Qais Yousef
Date: Sat Sep 16 2023 - 15:53:20 EST


On 09/16/23 20:49, Qais Yousef wrote:
> On 09/13/23 19:22, Dietmar Eggemann wrote:
> > On 10/09/2023 21:58, Qais Yousef wrote:
> > > On 09/07/23 13:12, Dietmar Eggemann wrote:
> > >> On 06/09/2023 23:19, Qais Yousef wrote:
> > >>> On 09/06/23 14:56, Dietmar Eggemann wrote:
> > >>>> On 28/08/2023 01:31, Qais Yousef wrote:
> >
> > [...]
> >
> > >> Another thing ... I guess if you call accumulate_sum with delta the PELT
> > >> machinery assumes `delta = now - sa->last_update_time` which means you
> > >> would have to use `clock_pelt + TICK_USEC` as delta.
> > >
> > > Right.
> > >
> > > The way I understood it is that at TICK we should do update_load_avg() which
> > > would call __update_load_sum() which uses
> > >
> > > delta = now - sa->last_update_time
> > >
> > > which passes this delta to accumulate_sum()
> > >
> > > I can see we are not very accurate since there will be a small additional time
> > > besides TICK_USEC that we are not accounting for. But I can't see how this can
> > > cause a big error.
> > >
> > > predicted (assumed) tick time/delta
> > >
> > > sa->last_update_time = now
> > > tick_time = TICK_USEC + now
> > >
> > > delta = tick_time - sa->last_update_time
> > > delta = TICK_USEC + now - now
> > > delta = TICK_USEC
> > >
> > > but actual tick time/delta
> > >
> > > sa->last_update_time = now - x
> > > tick_time = TICK_USEC + now
> > >
> > > delta = tick_time - sa->last_update_time
> > > delta = TICK_USEC + now - (now - x)
> > > delta = TICK_USEC + x
> > >
> > > So the delta I am using might be slightly shorter than it should be.
> > >
> > > IIUC, what you're saying that the `x` in my equation above is clock_pelt,
> > > right?
> >
> > No, I was wrong here. Calling accumulate_sum with `delta = TICK_USEC` is
> > fine.
> >
> > accumulate_sum() will accrue `sa->util.sum` and ___update_load_avg()
> > will then adjust `sa->util_avg` accordingly.
> >
> > delta should be 4000 on Arm64 boards so you will cross period
> > boundaries. In case `delta < 1024` you might want to not call
> > ___update_load_avg() to be in pair with __update_load_avg_cfs_rq().
>
> You mean *not* call, or actually *do* call ___update_load_avg() if delta
> < 1024? I am certainly not calling it now and I think you're suggesting to
> actually call it when period is less than 1024.

Oops my bad, I got confused. I am calling it. Ignore me!


Cheers

--
Qais Yousef