Re: çå: [PATCH V4] sched/cpufreq: initialize iowait_boost_max and iowait_boost with cpu capacity

From: Peter Zijlstra
Date: Mon Mar 04 2019 - 12:40:39 EST


On Mon, Mar 04, 2019 at 04:48:16PM +0000, Quentin Perret wrote:

> > @@ -837,7 +818,9 @@ static int sugov_start(struct cpufreq_policy *policy)
> > memset(sg_cpu, 0, sizeof(*sg_cpu));
> > sg_cpu->cpu = cpu;
> > sg_cpu->sg_policy = sg_policy;
> > - sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq;
> > + sg_cpu->min =
> > + (SCHED_CAPACITY_SCALE * policy->cpuinfo.min_freq) /
> > + policy->cpuinfo.max_freq;
>
> The 'funny' thing is that on big little this 'min' can end up being
> larger than 'max' ...
>
> On juno r0 for example, min_freq and max_freq for little CPUs are
> respectively 450MHz and 850MHz. So you get sg_cpu->min=542, but
> sg_cpu->max=446 ... So you'll max out after the first IO wakeup.
> And since iowait_boost is reset whenever it is smaller than sg_cpu->min,
> you end up with something that can either force max freq or apply no
> boost at all ...
>
> Perhaps you could keep the 'util' and 'max' pointers in
> sugov_iowait_apply() and overwrite them like before, but in the
> SCHED_CAPACITY_SCALE scale as you suggest ?

Urgh; but then we're back to having that boostrap problem.

Now; at this time; @max is in fact scale_cpu_capacity, so can't we
change this:

- /*
- * Apply the current boost value: a CPU is boosted only if its current
- * utilization is smaller then the current IO boost level.
- */
- boost_util = sg_cpu->iowait_boost;
- boost_max = sg_cpu->iowait_boost_max;
- if (*util * boost_max < *max * boost_util) {
- *util = boost_util;
- *max = boost_max;
- }
+ sg_cpu->iowait_boost_pending = false;
+
+ return min(max(util, sg_cpu->iowait_boost), max);
}

to something like:

/*
* @util is already in capacity scale, convert iowait_boost
* into the same scale so we can compare.
*/
boost = (sg_cpu->iowait_boost * max) >> SCHED_CAPACITY_SHIFT;
util = max(boost, util);
return min(util, max);