Re: [PATCH v4 1/2] sched: make __update_cpu_load() handle active tickless case

From: Peter Zijlstra
Date: Tue Oct 20 2015 - 05:49:05 EST


On Tue, Oct 20, 2015 at 09:49:32AM +0900, Byungchul Park wrote:
> > > = A^i * cpu_load(n-i) + (A^(i-1) + A^(i-2) + ... + 1) * B
> > > , where i = pending_updates - 1
> >
> > You missed an opportunity here, if you take i==n you avoid the need for
> > i entirely.
>
> i don't think so. as i said, _n_ is the current tick -1 and _i_ is
> pending_updates - 1. we cannot take i == n, but should keep (n-i).

Just think relative; it doesn't matter when in time we do this.
So 0 to n is identical to any other interval.

> > > = A^i * cpu_load(n-i) + B * (A^i - 1) / (A - 1)
> > > , by geometric series formula for sum
> >
> > That's wrong; the limited geometric series expands to:
>
> NO, that's not wrong. it doesn't matter at all.
>
> a * (1 - r^n) / (1 - r)
> = a * (-1)(r^n - 1) / (-1)(r - 1)
> = a * (r^n - 1) / (r - 1)
>
> i mean these two are exactly same.

Ah indeed! Sorry for that. I clearly didn't think beyond the series
expansion I found.

> > I've rewritten the things a little; does this look good to you?
>
> however, your expressions and descriptions below look better than me,
> except some logical errors. could you keep my logical flow unchagned?

> > + * load[i]_n = (1 - 1/2^i) * load[i]_n-1 + (1/2^i) * load_n-1
> > + * = A * load[i]_n-1 + B ; A := (1 - 1/2^i), B := (1/2^i) * load
> > + * = A * (A * load[i]_n-2 + B) + B
> > + * = A * (A * (A * load[i]_n-3 + B) + B) + B
> > + * = A^3 * load[i]_n-3 + (A^2 + A + 1) * B
> > + * = A^n * load[i]_0 + (A^(n-1) + A^(n-2) + ... + 1) * B
> > + * = A^n * load[i]_0 + ((1 - A^n) / (1 - A)) * B
> > + * = (1 - 1/2^i)^n * (load[i]_0 - load) + load

That is the same logic, right?

Please be more specific as to what you'd like restored.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/