Re: [PATCH v4 1/6] x86,sched: Add support for frequency invariance

From: Giovanni Gherdovich
Date: Thu Dec 19 2019 - 15:22:03 EST


On Wed, 2019-12-18 at 20:34 +0100, Peter Zijlstra wrote:
> On Fri, Dec 06, 2019 at 12:57:46PM +0100, Giovanni Gherdovich wrote:
> > > On Wednesday 13 Nov 2019 at 13:46:49 (+0100), Giovanni Gherdovich wrote:
> > > I see above that you enable the static key (and therefore frequency
> > > invariance before setting the max frequency ratio (if possible) and
> > > before you initialise the counter references. Is there any reason for
> > > doing this?
> > This is a fair point; mine was a deliberate choice but you're the second
> > person making this remark (Peter Zijlstra also suggested I find the max
> > frequency before I set the static key), so it appears this design is
> > unpopular
> > enough to warrant a change in v5.
>
> You actually 'fix' this in the next patch. I thought it was a patch
> management 'fail' that it didn't end up in this patch.

Uhm. I'm not sure I agree; let me paste the function intel_set_cpu_max_freq
after the entire series is applied:

> static void intel_set_cpu_max_freq(void)
> {
> u64 ratio = 1, turbo_ratio = 1;
>
> if (slv_set_cpu_max_freq(&ratio, &turbo_ratio))
> goto set_value;
>
> if (glm_set_cpu_max_freq(&ratio, &turbo_ratio))
> goto set_value;
>
> if (knl_set_cpu_max_freq(&ratio, &turbo_ratio))
> goto set_value;
>
> if (skx_set_cpu_max_freq(&ratio, &turbo_ratio))
> goto set_value;
>
> core_set_cpu_max_freq(&ratio, &turbo_ratio);
>

let's say that all functions return false; as I don't check the return value of
the last one, you can very well end up here with 'ratio' and 'turbo_ratio'
that are still untouched, =1 since their initialization, and I would go on and
set the static key anyway (because I previously checked X86_FEATURE_APERFMPERF).

Right?

> set_value:
> arch_max_turbo_freq = div_u64(turbo_ratio * SCHED_CAPACITY_SCALE,
> ratio);
> set_arch_max_freq(turbo_disabled());
> static_branch_enable(&arch_scale_freq_key);
> }

But again, not only people disagree with this behavior, it's probably a little
misleading too in how it's written. Changing in v5.

Giovanni