Messages in this thread | | | Date | Fri, 31 Mar 2017 13:38:55 +0200 | From | Peter Zijlstra <> | Subject | Re: [RESEND PATCH 2/2] sched/fair: Optimize __update_sched_avg() |
| |
On Fri, Mar 31, 2017 at 03:55:40AM -0700, Paul Turner wrote:
> > I'm thinking that we can compute the middle segment, by taking the max > > value and chopping off the ends, like: > > > > > > > p > > c2 = 1024 \Sum y^n > > n=1 > > > > inf inf > > = 1024 ( \Sum y^n - \Sum y^n - y^0 ) > > n=0 n=p > > > > Very nice! > Minor nit: Second sum needs to be from n=p+1
Correct.
> > +static u32 __accumulate_pelt_segments(u64 periods, u32 d1, u32 d3) > > { > > + u32 c1, c2, c3 = d3; /* y^0 == 1 */ > > > > /* > > * c1 = d1 y^(p+1) > > */ > > + c1 = decay_load((u64)d1, periods); > > > > /* > > + * p > > + * c2 = 1024 \Sum y^n > > + * n=1 > > * > > + * inf inf > > + * = 1024 ( \Sum y^n - \Sum y^n - y^0 ) > > + * n=0 n=p+1 > > */ > > + c2 = LOAD_AVG_MAX - decay_load(LOAD_AVG_MAX, periods) - 1024; > > decay_load(LOAD_AVG_MAX, periods + 1)
So here, @periods == p+1, see also c1. Yes, this is confusing [*].
In particular, I think the decay terms for c1 and this should be the same. We cut off this tail end of the series to replace it with c1 after all.
[*] hysterically p used to be off by 1, which is where the p+1 came from, but now periods includes it. I was thinking of doing a patch correcting all the comments to fully eradicate the whole +1 business.
> I computed all the values vs true value that the old/new computations > result in, and it's very close. Absolutely it's approximately 2x off > the previous computation, e.g. if the old value was -15 (relative to > true value) than the new computation is -30. > > This is definitely more than good enough. If we want more precision, > then the correction factor of: > +clamp(periods, 0, 45)
Can you do a patch with coherent comment explaining where that correction term comes from?
| |