From: Christian Loehle <christian.loehle@arm.com>
To: Yaxiong Tian <tianyaxiong@kylinos.cn>, rafael@kernel.org
Cc: dietmar.eggemann@arm.com, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org, lukasz.luba@arm.com,
srinivas.pandruvada@linux.intel.com
Subject: Re: [PATCH v2 3/3] cpufreq: intel_pstate: hybrid: Adjust energy model rules
Date: Thu, 16 Oct 2025 10:00:24 +0100 [thread overview]
Message-ID: <f48b80d5-0098-424d-9a7c-ae07017ab2bb@arm.com> (raw)
In-Reply-To: <20251016074849.1046580-1-tianyaxiong@kylinos.cn>
On 10/16/25 08:48, Yaxiong Tian wrote:
> 在 2025/10/15 21:48, Rafael J. Wysocki 写道:> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>
>> Instead of using HWP-to-frequency scaling factors for computing cost
>> coefficients in the energy model used on hybrid systems, which is
>> fragile, rely on CPU type information that is easily accessible now and
>> the information on whether or not L3 cache is present for this purpose.
>>
>> This also allows the cost coefficients for P-cores to be adjusted so
>> that they start to be populated somewhat earlier (that is, before
>> E-cores are loaded up to their full capacity).
>>
>> In addition to the above, replace an inaccurate comment regarding the
>> reason why the freq value is added to the cost in hybrid_get_cost().
>>
>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> ---
>> drivers/cpufreq/intel_pstate.c | 37 +++++++++++++++----------------------
>> 1 file changed, 15 insertions(+), 22 deletions(-)
>>
>> --- a/drivers/cpufreq/intel_pstate.c
>> +++ b/drivers/cpufreq/intel_pstate.c
>> @@ -933,11 +933,8 @@ static int hybrid_active_power(struct de
>> unsigned long *freq)
>> {
>> /*
>> - * Create "utilization bins" of 0-40%, 40%-60%, 60%-80%, and 80%-100%
>> - * of the maximum capacity such that two CPUs of the same type will be
>> - * regarded as equally attractive if the utilization of each of them
>> - * falls into the same bin, which should prevent tasks from being
>> - * migrated between them too often.
>> + * Create four "states" corresponding to 40%, 60%, 80%, and 100% of the
>> + * full capacity.
>> *
>> * For this purpose, return the "frequency" of 2 for the first
>> * performance level and otherwise leave the value set by the caller.
>> @@ -970,26 +967,22 @@ static bool hybrid_has_l3(unsigned int c
>> static int hybrid_get_cost(struct device *dev, unsigned long freq,
>> unsigned long *cost)
>> {
>> - struct pstate_data *pstate = &all_cpu_data[dev->id]->pstate;
>> -
>> + /* Facilitate load balancing between CPUs of the same type. */
>> + *cost = freq;
>> /*
>> - * The smaller the perf-to-frequency scaling factor, the larger the IPC
>> - * ratio between the given CPU and the least capable CPU in the system.
>> - * Regard that IPC ratio as the primary cost component and assume that
>> - * the scaling factors for different CPU types will differ by at least
>> - * 5% and they will not be above INTEL_PSTATE_CORE_SCALING.
>> + * Adjust the cost depending on CPU type.
>> *
>> - * Add the freq value to the cost, so that the cost of running on CPUs
>> - * of the same type in different "utilization bins" is different.
>> - */
>> - *cost = div_u64(100ULL * INTEL_PSTATE_CORE_SCALING, pstate->scaling) + freq;
>> - /*
>> - * Increase the cost slightly for CPUs able to access L3 to avoid
>> - * touching it in case some other CPUs of the same type can do the work
>> - * without it.
>> + * The idea is to start loading up LPE-cores before E-cores and start
>> + * to populate E-cores when LPE-cores are utilized above 60% of the
>> + * capacity. Similarly, P-cores start to be populated when E-cores are
>> + * utilized above 60% of the capacity.
>> */
>> - if (hybrid_has_l3(dev->id))
>> - *cost += 2;
>> + if (hybrid_get_cpu_type(dev->id) == INTEL_CPU_TYPE_ATOM) {
>> + if (hybrid_has_l3(dev->id)) /* E-core */
>> + *cost += 2;
>> + } else { /* P-core */
>> + *cost += 4;
>> + }
>>
>> return 0;
>> }
>
> Hi Rafael J. Wysocki:
>
> Is the increment of this cost for different types of CPUs by one instead
> of two?
>
> cost by increment of 2:
> 0~40% 40%~60% 60%~80% 80%~100
> LPE-core 2 3 4 5
> E-core 4 5 6 7
> P-core 6 7 8 9
>
> So, tasks only start being allocated to more powerful CPUs when
> utilization exceeds 80%, but by that point the system is already in an
> overloaded state.
>
> cost by increment of 1:
> 0~40% 40%~60% 60%~80% 80%~100
> LPE-core 2 3 4 5
> E-core 3 4 5 6
> P-core 4 5 6 7
>
> This situation aligns with the description in your patch.
>
> The idea of this patch looks good to me.
Agreed if you want the threshold to be 60% for both it should be +1 for l3
and +2 for P-core.
Good catch!
next prev parent reply other threads:[~2025-10-16 9:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 13:45 [PATCH v2 0/3] cpufreq: intel_pstate: Adjust the energy model for hybrid systems Rafael J. Wysocki
2025-10-15 13:46 ` [PATCH v2 1/3] cpufreq: intel_pstate: Add and use hybrid_get_cpu_type() Rafael J. Wysocki
2025-10-15 13:47 ` [PATCH v2 2/3] cpufreq: intel_pstate: Add and use hybrid_has_l3() Rafael J. Wysocki
2025-10-15 13:48 ` [PATCH v2 3/3] cpufreq: intel_pstate: hybrid: Adjust energy model rules Rafael J. Wysocki
2025-10-15 15:13 ` Christian Loehle
2025-10-15 15:16 ` Rafael J. Wysocki
2025-10-16 7:48 ` Yaxiong Tian
2025-10-16 9:00 ` Christian Loehle [this message]
2025-10-16 9:52 ` Rafael J. Wysocki
2025-10-16 13:59 ` Dietmar Eggemann
2025-10-16 16:22 ` [PATCH v3 " Rafael J. Wysocki
2025-10-17 1:15 ` Yaxiong Tian
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=f48b80d5-0098-424d-9a7c-ae07017ab2bb@arm.com \
--to=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=tianyaxiong@kylinos.cn \
/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®