Re: [PATCH v2 2/3] cpufreq: amd-pstate: Set asymmetric CPU capacity on hybrid platforms
From: K Prateek Nayak
Date: Wed Dec 02 2026 - 21:57:05 EST
Hello Vishal,
On 12/2/2026 4:53 PM, Badole, Vishal wrote:
>> So in amd_pstate_init_freq() we have:
>>
>> max_freq = amd_get_max_frequency(cpudata->cpu) * 1000;
>> if (!max_freq)
>> max_freq = perf_to_freq(perf, nominal_freq, perf.highest_perf);
>> WRITE_ONCE(cpudata->max_freq, max_freq);
>>
>>
>> "cpudata->max_freq" calculation already accounts for this branching and
>> looking at the max_freq across all CPU is enough to capture the new and
>> old systems right?
>>
>> New systems will have "max_freq" set based on amd_get_max_frequency().
>> Ols systems will use the difference in "perf.highest_perf" to calculate
>> it differently between performance and efficiency cores.
>>
>> What am I missing?
>>
>
> On older systems, frequency is calculated from the CPU performance
> values, which remain unchanged. On newer systems, these values have
> changed across CPU types, so the maximum frequency is obtained using
> amd_get_max_frequency().
And that value per-CPU is cached as "cpudata->max_freq". You find the
largest max_freq across the system as the reference and you use the
current CPUs "max_freq" to set it up:
arch_set_cpu_capacity(cpu,
cpudata->max_freq, reference_max_freq,
cpudata->max_freq, reference_max_freq);
Why will this not work?
>
>>>
>>> Also, the fallback branch can be entered when only the reference CPU lacks frequency data. In that case, the current CPU’s data->max_freq may contain an actual Fmax, so it is not always interchangeable with this perf_to_freq() calculation.
>>>
>>>>> +
>>>>> + arch_set_cpu_capacity(cpu, capacity, max_capacity, capacity_freq, base_freq);
>>>>
>>>> ...
>>>>
>>>> And that means they'll have same capacity, but different frequency scale.
>>>> That reads a bit wrong to me. Different frequency scale will help cap the
>>>> PELT tracking but the CPUs themself will appear as same capacity which
>>>> would do the wrong thing.
>>>>
>>>> What do these highest_perf numbers look like on real hardware btw?
>>>>
>>> 255/254 for performance core and 252 efficiency core.
>>>
>>>>> + topology_set_cpu_scale(cpu, arch_scale_cpu_capacity(cpu));
>>>>> +}
>>>>> +
>>>>> +static void amd_pstate_set_cpu_capacity(struct amd_cpudata *cpudata,
>>>>> + bool highest_freq_available)
>>>>> +{
>>>>> + union perf_cached perf = READ_ONCE(cpudata->perf);
>>>>> + int cpu;
>>>>> +
>>>>> + lockdep_assert_cpus_held();
>>>>> +
>>>>> + guard(mutex)(&sched_domains_mutex);
>>>>> +
>>>>> + if (perf.highest_perf > amd_pstate_ref_highest_perf) {
>>>>
>>>> Btw there is other side to this where all CPUs of the highest
>>>> capacity are offlined and you'll need to recaliberate the
>>>> reference again if you have efficiency and low-power cores.
>>>>
>>> If performance cores are kept offline at boot using maxcpus=, the current logic already handles this by selecting the highest-performance online CPU as the reference.
>>>
>>> For runtime offlining, I don't think recalibration is necessary. Offlining performance cores does not change the maximum capabilities of the remaining efficiency and low-power cores. Keeping the existing reference preserves their relative capacities, even if no online CPU then has a capacity of 1024.
>>>
>>> Is there a scheduler requirement that the highest-capacity online CPU must always be normalized to 1024?
>>
>> I think so: task_util() can reach 1024 as its maximum independent of
>> CPU capacity and the misfit check does:
>>
>> fits = fits_capacity(util, capacity);
>> ^ ^
>> Task util CPU capacity
>>
>> CPU capacity is derived from arch_scale_cpu_capacity(). You'll always
>> trigger a misfit but won't find any better CPU to migrate to if all
>> your reference cores are offline and you've not updated your
>> efficiency cores to 1024 capacity.
>>
> Thanks for sharing this information.
>
> On the AMD platforms CPU0 is a performance core
I clearly remember you saying that might not be the case.
If BSP is indeed the most powerful core always, you can
skip all the for_each_online_cpu() loop and just consider
the CPU0's max_freq as reference throughout.
--
Thanks and Regards,
Prateek