mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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: Thu, 3 Dec 2026 08:26:34 +0530	[thread overview]
Message-ID: <892e8f3e-5b29-43f8-8cfa-04ff4f8fdad3@amd.com> (raw)
In-Reply-To: <e05e418d-d650-4d88-88a9-b974fbf6095d@amd.com>

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


  reply	other threads:[~2026-12-03  2:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 17:20 [PATCH v2 0/3] cpufreq: amd-pstate: Capacity Aware Scheduling " 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
2026-12-02 11:23         ` Badole, Vishal
2026-12-03  2:56           ` 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=892e8f3e-5b29-43f8-8cfa-04ff4f8fdad3@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

all inboxes | Powered by JetHome®