Re: [RFC PATCH v4 0/6] sched/cpufreq: Make schedutil energy aware

From: Peter Zijlstra
Date: Fri Feb 14 2020 - 07:21:36 EST


On Thu, Feb 13, 2020 at 05:49:48PM +0000, Douglas Raillard wrote:

> > So even when:
> >
> > boost = util_avg - util_est
> >
> > is small, despite util_avg being huge (~1024), due to large util_est,
> > we'll still get an effective boost to max_cost ASSUMING cs[].cost and
> > cost_margin have the same curve.
>
> I'm not sure to follow, cs[].cost can be plotted against cs[].freq, but
> cost_margin is a time-based signal (the boost value), so it would be
> plotted against time.

Suppose we have the normalized energy vs frequency curve: x^3

( P ~ V^2 * f, due to lack of better: V ~ f -> P ~ f^3 )

1 +--------------------------------------------------------------------+
| + + + + *|
| x**3 ******* |
| ** |
0.8 |-+ ** +-|
| ** |
| * |
| ** |
0.6 |-+ ** +-|
| ** |
| ** |
| *** |
0.4 |-+ *** +-|
| ** |
| *** |
| *** |
0.2 |-+ **** +-|
| **** |
| ****** |
| + ********** + + |
0 +--------------------------------------------------------------------+
0 0.2 0.4 0.6 0.8 1


where x is our normalized frequency and y is the normalized energy.

Further, remember that schedutil does (per construction; for lack of
better):

f ~ u

So at u=0.6, we're at f=0.6 and P=0.2

+ boost = util_avg - util_est_enqueued;

So for util_est = 0.6, we're limited to: boost = 0.4.

+ max_cost = pd->table[pd->nr_cap_states - 1].cost;
+ cost_margin = (cost_margin * max_cost) / EM_COST_MARGIN_SCALE;

Which then gives:

cost_margin = boost = 0.4

And we find that:

P' = P + cost_margin = 0.2 + 0.4 = 0.6 < 1

So even though set out to allow a 100% boost in energy usage, we were in
fact incapable of achieving this, because our cost_margin is linear in u
while the energy (or cost) curve is cubic in u.

That was my argument; but I think that now that I've expanded on it, I
see a flaw, because when we do have boost = 0.4, this means util_avg =
1, and we would've selected f = 1, and boosting would've been pointless.

So let me try again:

f = util_avg, P = f^3, boost = util_avg - util_est

P' = util_avg ^ 3 + util_avg - util_est

And I'm then failing to make further sense of that; it of course means
that P'(u) is larger than P(2u) for some u, but I don't think we set
that as a goal either.

Let me ponder this a little more while I go read the rest of your email.