Re: [RFC v3 6/6] arm64/amu: use capacity_ref_freq to set AMU ratio

From: Dietmar Eggemann
Date: Thu Oct 26 2023 - 07:20:00 EST


On 24/10/2023 11:58, Vincent Guittot wrote:
> On Mon, 23 Oct 2023 at 22:58, Ionela Voinescu <ionela.voinescu@xxxxxxx> wrote:
>>
>> Hi,
>>
>> On Wednesday 18 Oct 2023 at 18:25:40 (+0200), Vincent Guittot wrote:
>>> Use the new capacity_ref_freq to set the ratio that is used by AMU for
>>> computing the arch_scale_freq_capacity().
>>> This helps to keep everything aligned using the same reference for
>>> computing CPUs capacity.
>>>
>>> The default value of the ratio ensures that arch_scale_freq_capacity()
>>> returns max capacity until it is set to its correct value with the
>>> cpu capacity and capacity_ref_freq.

Nitpick: Could you mention that arch_max_freq_scale is the default value
for this ratio? Took me a while to recreate the (not so simple) story
for this change, i.e. make the connection between ratio and
arch_max_freq_scale.

init_cpu_capacity_callback()

freq_inv_set_max_ratio()

u64 ratio
...
per_cpu(arch_max_freq_scale, cpu) = (unsigned long)ratio
^^^^^^^^^^^^^^^^^^^


static struct scale_freq_data amu_sfd = {
.set_freq_scale = amu_scale_freq_tick,
}

#define arch_scale_freq_tick topology_scale_freq_tick

topology_scale_freq_tick()

sfd->set_freq_scale()


amu_scale_freq_tick()

...
scale *= this_cpu_read(arch_max_freq_scale)
^^^^^^^^^^^^^^^^^^^
...
this_cpu_write(arch_freq_scale, (unsigned long)scale);


#define arch_scale_freq_capacity topology_get_freq_scale

topology_get_freq_scale(cpu)

return per_cpu(arch_freq_scale, cpu)

[...]