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

From: Quentin Perret
Date: Mon Mar 04 2019 - 11:48:22 EST


On Monday 04 Mar 2019 at 16:26:16 (+0100), Peter Zijlstra wrote:
> On Mon, Mar 04, 2019 at 01:58:12PM +0000, Quentin Perret wrote:
> > You could also update the values in sugov_get_util() at the cost of a
> > small overhead to compute 'min'. I'm not sure what's preferable since
> > we wanted to avoid that kind of overhead in the first place ...
>
> Or,... we could actually make things simpler.
>
> How's the below? I have a feq questions wrt min, mostly:
>
> - what's the difference between policy->min and
> policy->cpuinfo.min_freq; it used to be the former, the below uses
> the latter.

As mentioned on IRC, IIRC policy->min is something that can be written
from userspace (for example) to cap the min freq. OTOH, cpuinfo.min_freq
is read-only and just reports the lowest OPP.

Rafael is this correct ?

> - should we have a min_freq based value, instead of a constant; the
> difference being that with this the actual boost speed depends in the
> gap between min/max.

If the above is correct, then I agree. Looking at min_freq simplifies
things quite a bit since it doesn't need to be updated all the time,
and the whole policy->min stuff is dealt with at the CPUFreq core level
so it's not obvious sugov should care.

> Anyway; the below converts iowait_boost to capacity scale (from kHz), it
> side-steps the whole issue you guys are bickering about by limiting it
> to SCHED_CAPACITY_SCALE (aka. 1024) on the boost path, and then limiting
> it to @max by the time we figured out we ought to use it.
>
> And since that means we never change @max anymore; we can simplify whole
> return value thing.

[...]

> @@ -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 ?

Thanks,
Quentin