From: K Prateek Nayak <kprateek.nayak@amd.com>
To: "Badole, Vishal" <vishal.badole@amd.com>, <ray.huang@amd.com>,
<mario.limonciello@amd.com>, <rafael@kernel.org>,
<viresh.kumar@linaro.org>, <perry.yuan@amd.com>,
<hansg@kernel.org>, <ilpo.jarvinen@linux.intel.com>,
<platform-driver-x86@vger.kernel.org>, <linux-pm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] cpufreq: amd-pstate: Set asymmetric CPU capacity on hybrid platforms
Date: Tue, 1 Dec 2026 15:10:37 +0530 [thread overview]
Message-ID: <3aea8e22-6721-4dfe-8429-a22d59085fed@amd.com> (raw)
In-Reply-To: <955f1ea8-65da-4100-93dd-11bfebc4954c@amd.com>
Hello Vishal,
On 12/1/2026 2:48 PM, Badole, Vishal wrote:
>>> +static void amd_pstate_update_cpu_capacity(struct amd_cpudata *data,
>>> + bool highest_freq_available)
>>> +{
>>> + unsigned long capacity, max_capacity, capacity_freq, base_freq;
>>> + int cpu = data->cpu;
>>> +
>>> + lockdep_assert_held(&sched_domains_mutex);
>>> +
>>> + if (highest_freq_available && amd_pstate_ref_freq_khz) {
>>> + capacity = data->max_freq;
>>> + max_capacity = amd_pstate_ref_freq_khz;
>>> + capacity_freq = capacity;
>>> + base_freq = max_capacity;
>>> + } else {
>>> + union perf_cached perf = READ_ONCE(data->perf);
>>> +
>>> + capacity = perf.highest_perf;
>>> + max_capacity = amd_pstate_ref_highest_perf;
>>> + capacity_freq = perf_to_freq(perf, data->nominal_freq, perf.highest_perf);
>>
>> So this is literally "data->max_freq"
>>
>>> + base_freq = perf_to_freq(perf, data->nominal_freq, max_capacity);
>>
>> And this would likely be equal to "amd_pstate_ref_freq_khz"
>>
>>> + }
>>
>> Making both those branch pretty much the same. Why isn't just the
>> frequency reference enough?
>>
> Yes, when maximum-frequency data is unavailable for this CPU, this expression is equivalent to data->max_freq, which was calculated using perf_to_freq().
>
> However, that is a frequency estimate derived from CPPC performance values, not necessarily the CPU’s actual maximum attainable frequency. In the frequency-based branch, data->max_freq comes from amd_get_max_frequency() and represents the maximum attainable frequency independently of those performance values.
>
> On older hardware, the highest-performance values of 196 for performance cores and 130 for efficiency cores aligned reasonably with their relative maximum frequencies. On newer hardware, these values are 255 and 252, which no longer reflect the Fmax difference between the core types. Performance-based scaling therefore gives almost equal capacities, whereas using the maximum attainable frequencies gives capacities of 1024 and 718.
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?
>
> 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 and Regards,
Prateek
next prev parent reply other threads:[~2026-12-01 9:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 17:20 [PATCH v2 0/3] cpufreq: amd-pstate: Capacity Aware Scheduling on hybrid platforms Vishal Badole
2026-11-25 17:20 ` [PATCH v2 1/3] cpufreq: amd-pstate: Finalize prefcore before registration Vishal Badole
2026-11-30 15:38 ` Mario Limonciello
2026-11-25 17:20 ` [PATCH v2 2/3] cpufreq: amd-pstate: Set asymmetric CPU capacity on hybrid platforms Vishal Badole
2026-11-30 8:24 ` K Prateek Nayak
2026-11-30 15:40 ` Mario Limonciello
2026-12-01 9:18 ` Badole, Vishal
2026-12-01 9:40 ` K Prateek Nayak [this message]
2026-11-25 17:20 ` [PATCH v2 3/3] platform/x86/amd: hfi: Stand down when amd-pstate CAS is active Vishal Badole
2026-11-30 15:39 ` Mario Limonciello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3aea8e22-6721-4dfe-8429-a22d59085fed@amd.com \
--to=kprateek.nayak@amd.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=perry.yuan@amd.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=ray.huang@amd.com \
--cc=viresh.kumar@linaro.org \
--cc=vishal.badole@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox