* [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
@ 2025-11-25 3:24 Kaushlendra Kumar
2025-11-25 8:37 ` Christian Loehle
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Kaushlendra Kumar @ 2025-11-25 3:24 UTC (permalink / raw)
To: rafael, viresh.kumar, mingo, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, bsegall, mgorman, vschneid
Cc: linux-pm, Kaushlendra Kumar
In sugov_next_freq_shared(), the CPU capacity is retrieved only
for the CPU that triggered the update (sg_cpu->cpu) and then
incorrectly applied to all CPUs in the shared frequency domain
during the loop.On heterogeneous systems with CPUs of different
capacities sharing a frequency domain, this causes incorrect
frequency selection.
Calculate per-CPU capacity in the loop and track maximum across
all CPUs for proper frequency calculation.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
kernel/sched/cpufreq_schedutil.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 0ab5f9d4bc59..9fdbc7a6063d 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -492,15 +492,15 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
{
struct sugov_policy *sg_policy = sg_cpu->sg_policy;
struct cpufreq_policy *policy = sg_policy->policy;
- unsigned long util = 0, max_cap;
+ unsigned long util = 0, max_cap = 0;
unsigned int j;
- max_cap = arch_scale_cpu_capacity(sg_cpu->cpu);
-
for_each_cpu(j, policy->cpus) {
struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j);
- unsigned long boost;
+ unsigned long boost, j_max_cap;
+ j_max_cap = arch_scale_cpu_capacity(j);
+ max_cap = max(max_cap, j_max_cap);
boost = sugov_iowait_apply(j_sg_cpu, time, max_cap);
sugov_get_util(j_sg_cpu, boost);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
2025-11-25 3:24 [PATCH] sched/cpufreq: Fix capacity calc in shared policy update Kaushlendra Kumar
@ 2025-11-25 8:37 ` Christian Loehle
2025-11-25 9:28 ` Kumar, Kaushlendra
2025-11-25 9:04 ` Lukasz Luba
2025-11-25 12:09 ` Rafael J. Wysocki
2 siblings, 1 reply; 11+ messages in thread
From: Christian Loehle @ 2025-11-25 8:37 UTC (permalink / raw)
To: Kaushlendra Kumar, rafael, viresh.kumar, mingo, peterz,
juri.lelli, vincent.guittot, dietmar.eggemann, bsegall, mgorman,
vschneid
Cc: linux-pm, Beata Michalska, Ionela Voinescu
On 11/25/25 03:24, Kaushlendra Kumar wrote:
> In sugov_next_freq_shared(), the CPU capacity is retrieved only
> for the CPU that triggered the update (sg_cpu->cpu) and then
> incorrectly applied to all CPUs in the shared frequency domain
> during the loop.On heterogeneous systems with CPUs of different
> capacities sharing a frequency domain, this causes incorrect
> frequency selection.
Then this needs a fixes tag?
Maybe even the intel_pstate setup changes? I think the
policy <=> capacity assumption made here was true before that?
>
> Calculate per-CPU capacity in the loop and track maximum across
> all CPUs for proper frequency calculation.
s/all CPUs/all policy CPUs/ maybe?
>
> Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
> ---
> kernel/sched/cpufreq_schedutil.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index 0ab5f9d4bc59..9fdbc7a6063d 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -492,15 +492,15 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
> {
> struct sugov_policy *sg_policy = sg_cpu->sg_policy;
> struct cpufreq_policy *policy = sg_policy->policy;
> - unsigned long util = 0, max_cap;
> + unsigned long util = 0, max_cap = 0;
> unsigned int j;
>
> - max_cap = arch_scale_cpu_capacity(sg_cpu->cpu);
> -
> for_each_cpu(j, policy->cpus) {
> struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j);
> - unsigned long boost;
> + unsigned long boost, j_max_cap;
>
> + j_max_cap = arch_scale_cpu_capacity(j);
nit: j_max_cap is only used once...
> + max_cap = max(max_cap, j_max_cap);
> boost = sugov_iowait_apply(j_sg_cpu, time, max_cap);
I find this a bit strange, you might as well argue that this
sets the wrong frequency with your patch (boost being determined by the
highest frequency seen in this loop so far?)
My understanding was that this "different capacity, same cluster" was just
a technicality and because the capacities are still really close (1-2%?) we
essentially don't care about the difference. Why do we care here/now?
> sugov_get_util(j_sg_cpu, boost);
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
2025-11-25 3:24 [PATCH] sched/cpufreq: Fix capacity calc in shared policy update Kaushlendra Kumar
2025-11-25 8:37 ` Christian Loehle
@ 2025-11-25 9:04 ` Lukasz Luba
2025-11-25 9:23 ` Kumar, Kaushlendra
2025-11-25 12:09 ` Rafael J. Wysocki
2 siblings, 1 reply; 11+ messages in thread
From: Lukasz Luba @ 2025-11-25 9:04 UTC (permalink / raw)
To: Kaushlendra Kumar
Cc: linux-pm, rafael, vschneid, mgorman, dietmar.eggemann, juri.lelli,
peterz, viresh.kumar, mingo, vincent.guittot, bsegall
Hi Kaushlendra,
On 11/25/25 03:24, Kaushlendra Kumar wrote:
> In sugov_next_freq_shared(), the CPU capacity is retrieved only
> for the CPU that triggered the update (sg_cpu->cpu) and then
> incorrectly applied to all CPUs in the shared frequency domain
> during the loop.On heterogeneous systems with CPUs of different
> capacities sharing a frequency domain, this causes incorrect
> frequency selection.
How is this possible?
Is it old or new Intel SoC (a chip name would be also welcome)?
I would like to hear Rafael's view on such platform configuration.
It looks like a hack and the next needed step would be a similar
hack to calm down EAS and EM in the energy estimation code...
Do we really want to support such configuration in the generic code?
>
> Calculate per-CPU capacity in the loop and track maximum across
> all CPUs for proper frequency calculation.
I've changed that loop to speed-up the hot code path triggered
from the scheduler. For most platforms (till now) it's fine
to get the cpu capacity once for all cpus in the policy.
A lot of code is based on this assumption.
>
> Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
> ---
> kernel/sched/cpufreq_schedutil.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index 0ab5f9d4bc59..9fdbc7a6063d 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -492,15 +492,15 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
> {
> struct sugov_policy *sg_policy = sg_cpu->sg_policy;
> struct cpufreq_policy *policy = sg_policy->policy;
> - unsigned long util = 0, max_cap;
> + unsigned long util = 0, max_cap = 0;
> unsigned int j;
>
> - max_cap = arch_scale_cpu_capacity(sg_cpu->cpu);
> -
> for_each_cpu(j, policy->cpus) {
> struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j);
> - unsigned long boost;
> + unsigned long boost, j_max_cap;
>
> + j_max_cap = arch_scale_cpu_capacity(j);
> + max_cap = max(max_cap, j_max_cap);
> boost = sugov_iowait_apply(j_sg_cpu, time, max_cap);
> sugov_get_util(j_sg_cpu, boost);
>
My gut feeling tells me that it won't be the last needed code change
if we go that path...
Regards,
Lukasz
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
2025-11-25 9:04 ` Lukasz Luba
@ 2025-11-25 9:23 ` Kumar, Kaushlendra
2025-11-25 9:38 ` Vincent Guittot
0 siblings, 1 reply; 11+ messages in thread
From: Kumar, Kaushlendra @ 2025-11-25 9:23 UTC (permalink / raw)
To: Lukasz Luba
Cc: linux-pm@vger.kernel.org, rafael@kernel.org, vschneid@redhat.com,
mgorman@suse.de, dietmar.eggemann@arm.com, juri.lelli@redhat.com,
peterz@infradead.org, viresh.kumar@linaro.org, mingo@redhat.com,
vincent.guittot@linaro.org, bsegall@google.com
Hi Lukasz,
On 11/25/25 XX:XX, Lukasz Luba wrote:
> Hi Kaushlendra,
>
> On 11/25/25 03:24, Kaushlendra Kumar wrote:
>> In sugov_next_freq_shared(), the CPU capacity is retrieved only for
>> the CPU that triggered the update (sg_cpu->cpu) and then incorrectly
>> applied to all CPUs in the shared frequency domain during the loop.On
>> heterogeneous systems with CPUs of different capacities sharing a
>> frequency domain, this causes incorrect frequency selection.
>
> How is this possible?
> Is it old or new Intel SoC (a chip name would be also welcome)?
This is with respect to intel platforms which has E-cores and P-cores.
>
> I would like to hear Rafael's view on such platform configuration.
>
> It looks like a hack and the next needed step would be a similar hack
> to calm down EAS and EM in the energy estimation code...
>
> Do we really want to support such configuration in the generic code?
I understand the concern about maintaining the optimization in the hot path.
Lets hear Rafael.
>
>> Calculate per-CPU capacity in the loop and track maximum across all
>> CPUs for proper frequency calculation.
>
> I've changed that loop to speed-up the hot code path triggered from the
> scheduler. For most platforms (till now) it's fine to get the cpu
> capacity once for all cpus in the policy.
> A lot of code is based on this assumption.
Agreed, the hot path performance is critical.
>
> My gut feeling tells me that it won't be the last needed code change
> if we go that path...
You're right to be cautious. Let's investigate the EAS/EM implications and
have more complete assessment of this change.
Thanks for the feedback.
Regards,
Kaushlendra
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
2025-11-25 8:37 ` Christian Loehle
@ 2025-11-25 9:28 ` Kumar, Kaushlendra
0 siblings, 0 replies; 11+ messages in thread
From: Kumar, Kaushlendra @ 2025-11-25 9:28 UTC (permalink / raw)
To: Christian Loehle, rafael@kernel.org, viresh.kumar@linaro.org,
mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
bsegall@google.com, mgorman@suse.de, vschneid@redhat.com
Cc: linux-pm@vger.kernel.org, Beata Michalska, Ionela Voinescu
Hi Dietmar,
On 11/25/25 XX:XX, Dietmar Eggemann wrote:
> On 11/25/25 03:24, Kaushlendra Kumar wrote:
>> In sugov_next_freq_shared(), the CPU capacity is retrieved only for
>> the CPU that triggered the update (sg_cpu->cpu) and then incorrectly
>> applied to all CPUs in the shared frequency domain during the loop.On
>> heterogeneous systems with CPUs of different capacities sharing a
>> frequency domain, this causes incorrect frequency selection.
>
> Then this needs a fixes tag?
> Maybe even the intel_pstate setup changes? I think the policy <=>
> capacity assumption made here was true before that?
You're right, I'll add a Fixes tag.
>
>>
>> Calculate per-CPU capacity in the loop and track maximum across all
>> CPUs for proper frequency calculation.
>
> s/all CPUs/all policy CPUs/ maybe?
Agreed.
>
>>
>> Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
>> ---
>> kernel/sched/cpufreq_schedutil.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/kernel/sched/cpufreq_schedutil.c
>> b/kernel/sched/cpufreq_schedutil.c
>> index 0ab5f9d4bc59..9fdbc7a6063d 100644
>> --- a/kernel/sched/cpufreq_schedutil.c
>> +++ b/kernel/sched/cpufreq_schedutil.c
>> @@ -492,15 +492,15 @@ static unsigned int
>> sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time) {
>> struct sugov_policy *sg_policy = sg_cpu->sg_policy;
>> struct cpufreq_policy *policy = sg_policy->policy;
>> - unsigned long util = 0, max_cap;
>> + unsigned long util = 0, max_cap = 0;
>> unsigned int j;
>>
>> - max_cap = arch_scale_cpu_capacity(sg_cpu->cpu);
>> -
>> for_each_cpu(j, policy->cpus) {
>> struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j);
>> - unsigned long boost;
>> + unsigned long boost, j_max_cap;
>>
>> + j_max_cap = arch_scale_cpu_capacity(j);
>
> nit: j_max_cap is only used once...
Will inline it: max_cap = max(max_cap, arch_scale_cpu_capacity(j));
>
>> + max_cap = max(max_cap, j_max_cap);
>> boost = sugov_iowait_apply(j_sg_cpu, time, max_cap);
>
> I find this a bit strange, you might as well argue that this sets the
> wrong frequency with your patch (boost being determined by the highest
> frequency seen in this loop so far?) My understanding was that this
> "different capacity, same cluster" was just a technicality and because
> the capacities are still really close (1-2%?) we essentially don't care
> about the difference. Why do we care here/now?
Good point about the boost calculation using intermediate max_cap values.
If the capacity differences are indeed only 1-2%, perhaps this needs further investigation.
Let me investigate the actual capacity deltas.
Thanks for the review.
Regards,
Kaushlendra
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
2025-11-25 9:23 ` Kumar, Kaushlendra
@ 2025-11-25 9:38 ` Vincent Guittot
2025-11-25 9:46 ` Christian Loehle
0 siblings, 1 reply; 11+ messages in thread
From: Vincent Guittot @ 2025-11-25 9:38 UTC (permalink / raw)
To: Kumar, Kaushlendra
Cc: Lukasz Luba, linux-pm@vger.kernel.org, rafael@kernel.org,
vschneid@redhat.com, mgorman@suse.de, dietmar.eggemann@arm.com,
juri.lelli@redhat.com, peterz@infradead.org,
viresh.kumar@linaro.org, mingo@redhat.com, bsegall@google.com
On Tue, 25 Nov 2025 at 10:23, Kumar, Kaushlendra
<kaushlendra.kumar@intel.com> wrote:
>
> Hi Lukasz,
>
> On 11/25/25 XX:XX, Lukasz Luba wrote:
> > Hi Kaushlendra,
> >
> > On 11/25/25 03:24, Kaushlendra Kumar wrote:
> >> In sugov_next_freq_shared(), the CPU capacity is retrieved only for
> >> the CPU that triggered the update (sg_cpu->cpu) and then incorrectly
> >> applied to all CPUs in the shared frequency domain during the loop.On
> >> heterogeneous systems with CPUs of different capacities sharing a
> >> frequency domain, this causes incorrect frequency selection.
> >
> > How is this possible?
> > Is it old or new Intel SoC (a chip name would be also welcome)?
>
> This is with respect to intel platforms which has E-cores and P-cores.
Do you mean that they share the same frequency domains ?
>
> >
> > I would like to hear Rafael's view on such platform configuration.
> >
> > It looks like a hack and the next needed step would be a similar hack
> > to calm down EAS and EM in the energy estimation code...
> >
> > Do we really want to support such configuration in the generic code?
>
> I understand the concern about maintaining the optimization in the hot path.
> Lets hear Rafael.
> >
> >> Calculate per-CPU capacity in the loop and track maximum across all
> >> CPUs for proper frequency calculation.
> >
> > I've changed that loop to speed-up the hot code path triggered from the
> > scheduler. For most platforms (till now) it's fine to get the cpu
> > capacity once for all cpus in the policy.
> > A lot of code is based on this assumption.
>
> Agreed, the hot path performance is critical.
>
>
> >
> > My gut feeling tells me that it won't be the last needed code change
> > if we go that path...
>
> You're right to be cautious. Let's investigate the EAS/EM implications and
> have more complete assessment of this change.
>
> Thanks for the feedback.
>
> Regards,
> Kaushlendra
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
2025-11-25 9:38 ` Vincent Guittot
@ 2025-11-25 9:46 ` Christian Loehle
2025-11-25 9:57 ` Vincent Guittot
2025-11-25 12:41 ` Rafael J. Wysocki
0 siblings, 2 replies; 11+ messages in thread
From: Christian Loehle @ 2025-11-25 9:46 UTC (permalink / raw)
To: Vincent Guittot, Kumar, Kaushlendra
Cc: Lukasz Luba, linux-pm@vger.kernel.org, rafael@kernel.org,
vschneid@redhat.com, mgorman@suse.de, dietmar.eggemann@arm.com,
juri.lelli@redhat.com, peterz@infradead.org,
viresh.kumar@linaro.org, mingo@redhat.com, bsegall@google.com
On 11/25/25 09:38, Vincent Guittot wrote:
> On Tue, 25 Nov 2025 at 10:23, Kumar, Kaushlendra
> <kaushlendra.kumar@intel.com> wrote:
>>
>> Hi Lukasz,
>>
>> On 11/25/25 XX:XX, Lukasz Luba wrote:
>>> Hi Kaushlendra,
>>>
>>> On 11/25/25 03:24, Kaushlendra Kumar wrote:
>>>> In sugov_next_freq_shared(), the CPU capacity is retrieved only for
>>>> the CPU that triggered the update (sg_cpu->cpu) and then incorrectly
>>>> applied to all CPUs in the shared frequency domain during the loop.On
>>>> heterogeneous systems with CPUs of different capacities sharing a
>>>> frequency domain, this causes incorrect frequency selection.
>>>
>>> How is this possible?
>>> Is it old or new Intel SoC (a chip name would be also welcome)?
>>
>> This is with respect to intel platforms which has E-cores and P-cores.
>
> Do you mean that they share the same frequency domains ?
Just to get everybody on the same page:
Intel has what's called "favored cores", P-cores that allow for slightly
higher frequencies than the other (same uArch) P-cores.
Rafael's EAS series decided that it wouldn't be worth the effort make EAS
always iterate over an extra cluster (overhead on every wakeup hot-path)
for CPUs where in the bigger picture the difference is negligible.
https://lore.kernel.org/lkml/1592aa65-9dfb-47d6-9bcf-17afd3184a0a@arm.com/
(capacities are 623, 1009 and 1024 here, 1009 and 1024 are lumped into one
cluster.)
I think this isn't unreasonable, as long as this technicality lives inside
of intel_pstate setup code and doesn't escape, like proposed here.
Obviously EAS heavily relies on "1 cluster => 1 capacity" assumption as
mentioned before, even just for max-spare-cap in feec().
Breaking this assumption would require a huge rework, which AFAIU specifically
wasn't was Rafael intended, but I'm sure he'll chime in himself.
So if you really have issues with the different capacities within a cluster
trick that Rafael went with, please just reconsider that instead of trying
to patch things up outside of intel_pstate.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
2025-11-25 9:46 ` Christian Loehle
@ 2025-11-25 9:57 ` Vincent Guittot
2025-11-25 12:41 ` Rafael J. Wysocki
1 sibling, 0 replies; 11+ messages in thread
From: Vincent Guittot @ 2025-11-25 9:57 UTC (permalink / raw)
To: Christian Loehle
Cc: Kumar, Kaushlendra, Lukasz Luba, linux-pm@vger.kernel.org,
rafael@kernel.org, vschneid@redhat.com, mgorman@suse.de,
dietmar.eggemann@arm.com, juri.lelli@redhat.com,
peterz@infradead.org, viresh.kumar@linaro.org, mingo@redhat.com,
bsegall@google.com
On Tue, 25 Nov 2025 at 10:46, Christian Loehle <christian.loehle@arm.com> wrote:
>
> On 11/25/25 09:38, Vincent Guittot wrote:
> > On Tue, 25 Nov 2025 at 10:23, Kumar, Kaushlendra
> > <kaushlendra.kumar@intel.com> wrote:
> >>
> >> Hi Lukasz,
> >>
> >> On 11/25/25 XX:XX, Lukasz Luba wrote:
> >>> Hi Kaushlendra,
> >>>
> >>> On 11/25/25 03:24, Kaushlendra Kumar wrote:
> >>>> In sugov_next_freq_shared(), the CPU capacity is retrieved only for
> >>>> the CPU that triggered the update (sg_cpu->cpu) and then incorrectly
> >>>> applied to all CPUs in the shared frequency domain during the loop.On
> >>>> heterogeneous systems with CPUs of different capacities sharing a
> >>>> frequency domain, this causes incorrect frequency selection.
> >>>
> >>> How is this possible?
> >>> Is it old or new Intel SoC (a chip name would be also welcome)?
> >>
> >> This is with respect to intel platforms which has E-cores and P-cores.
> >
> > Do you mean that they share the same frequency domains ?
>
> Just to get everybody on the same page:
> Intel has what's called "favored cores", P-cores that allow for slightly
> higher frequencies than the other (same uArch) P-cores.
Okay so it's not E-core and P-core in the same domain but P-cores and
favored P-cores
> Rafael's EAS series decided that it wouldn't be worth the effort make EAS
> always iterate over an extra cluster (overhead on every wakeup hot-path)
> for CPUs where in the bigger picture the difference is negligible.
> https://lore.kernel.org/lkml/1592aa65-9dfb-47d6-9bcf-17afd3184a0a@arm.com/
> (capacities are 623, 1009 and 1024 here, 1009 and 1024 are lumped into one
> cluster.)
> I think this isn't unreasonable, as long as this technicality lives inside
> of intel_pstate setup code and doesn't escape, like proposed here.
I agree
> Obviously EAS heavily relies on "1 cluster => 1 capacity" assumption as
> mentioned before, even just for max-spare-cap in feec().
> Breaking this assumption would require a huge rework, which AFAIU specifically
> wasn't was Rafael intended, but I'm sure he'll chime in himself.
> So if you really have issues with the different capacities within a cluster
> trick that Rafael went with, please just reconsider that instead of trying
> to patch things up outside of intel_pstate.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
2025-11-25 3:24 [PATCH] sched/cpufreq: Fix capacity calc in shared policy update Kaushlendra Kumar
2025-11-25 8:37 ` Christian Loehle
2025-11-25 9:04 ` Lukasz Luba
@ 2025-11-25 12:09 ` Rafael J. Wysocki
2 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2025-11-25 12:09 UTC (permalink / raw)
To: Kaushlendra Kumar
Cc: rafael, viresh.kumar, mingo, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, bsegall, mgorman, vschneid, linux-pm
On Tue, Nov 25, 2025 at 4:27 AM Kaushlendra Kumar
<kaushlendra.kumar@intel.com> wrote:
>
> In sugov_next_freq_shared(), the CPU capacity is retrieved only
> for the CPU that triggered the update (sg_cpu->cpu) and then
> incorrectly applied to all CPUs in the shared frequency domain
> during the loop.On heterogeneous systems with CPUs of different
> capacities sharing a frequency domain, this causes incorrect
> frequency selection.
No, this is not what happens. sugov_next_freq_shared() is for the
cases when the frequency *needs* to be set for all CPUs in the domain
in one go.
Your patch is invalid, please be more careful.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
2025-11-25 9:46 ` Christian Loehle
2025-11-25 9:57 ` Vincent Guittot
@ 2025-11-25 12:41 ` Rafael J. Wysocki
2025-11-25 14:05 ` Kumar, Kaushlendra
1 sibling, 1 reply; 11+ messages in thread
From: Rafael J. Wysocki @ 2025-11-25 12:41 UTC (permalink / raw)
To: Christian Loehle
Cc: Vincent Guittot, Kumar, Kaushlendra, Lukasz Luba,
linux-pm@vger.kernel.org, rafael@kernel.org, vschneid@redhat.com,
mgorman@suse.de, dietmar.eggemann@arm.com, juri.lelli@redhat.com,
peterz@infradead.org, viresh.kumar@linaro.org, mingo@redhat.com,
bsegall@google.com
On Tue, Nov 25, 2025 at 10:46 AM Christian Loehle
<christian.loehle@arm.com> wrote:
>
> On 11/25/25 09:38, Vincent Guittot wrote:
> > On Tue, 25 Nov 2025 at 10:23, Kumar, Kaushlendra
> > <kaushlendra.kumar@intel.com> wrote:
> >>
> >> Hi Lukasz,
> >>
> >> On 11/25/25 XX:XX, Lukasz Luba wrote:
> >>> Hi Kaushlendra,
> >>>
> >>> On 11/25/25 03:24, Kaushlendra Kumar wrote:
> >>>> In sugov_next_freq_shared(), the CPU capacity is retrieved only for
> >>>> the CPU that triggered the update (sg_cpu->cpu) and then incorrectly
> >>>> applied to all CPUs in the shared frequency domain during the loop.On
> >>>> heterogeneous systems with CPUs of different capacities sharing a
> >>>> frequency domain, this causes incorrect frequency selection.
> >>>
> >>> How is this possible?
> >>> Is it old or new Intel SoC (a chip name would be also welcome)?
> >>
> >> This is with respect to intel platforms which has E-cores and P-cores.
So this is all misguided.
P-cores and E-cores don't even share frequency, so why would they be
there in the same domain?
On P-cores, frequency can be controlled independently per-core.
E-cores technically go in modules of 4 and the frequency is shared
within a module, but the interface to control it (HWP or CPPC if you
will) is per-CPU and intel_pstate treans them as independent.
For this reason, sugov_next_freq_shared() should never be used on
Intel hardware.
> >
> > Do you mean that they share the same frequency domains ?
>
> Just to get everybody on the same page:
> Intel has what's called "favored cores", P-cores that allow for slightly
> higher frequencies than the other (same uArch) P-cores.
Yes, but they don't share the frequency level with any other cores.
> Rafael's EAS series decided that it wouldn't be worth the effort make EAS
> always iterate over an extra cluster (overhead on every wakeup hot-path)
> for CPUs where in the bigger picture the difference is negligible.
> https://lore.kernel.org/lkml/1592aa65-9dfb-47d6-9bcf-17afd3184a0a@arm.com/
> (capacities are 623, 1009 and 1024 here, 1009 and 1024 are lumped into one
> cluster.)
Frequency control is still per-CPU though and from the schedutil
perspective it is always the single CPU case.
> I think this isn't unreasonable, as long as this technicality lives inside
> of intel_pstate setup code and doesn't escape, like proposed here.
> Obviously EAS heavily relies on "1 cluster => 1 capacity" assumption as
> mentioned before, even just for max-spare-cap in feec().
> Breaking this assumption would require a huge rework, which AFAIU specifically
> wasn't was Rafael intended, but I'm sure he'll chime in himself.
The EAS considerations are kind of a separate thing and they have
never changed the intel_pstate's assumptions regarding the performance
control granularity.
> So if you really have issues with the different capacities within a cluster
> trick that Rafael went with, please just reconsider that instead of trying
> to patch things up outside of intel_pstate.
Honestly, I think that trying to patch things at all without
sufficient understanding is antisocial and wrong.
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
2025-11-25 12:41 ` Rafael J. Wysocki
@ 2025-11-25 14:05 ` Kumar, Kaushlendra
0 siblings, 0 replies; 11+ messages in thread
From: Kumar, Kaushlendra @ 2025-11-25 14:05 UTC (permalink / raw)
To: Rafael J. Wysocki, Christian Loehle
Cc: Vincent Guittot, Lukasz Luba, linux-pm@vger.kernel.org,
vschneid@redhat.com, mgorman@suse.de, dietmar.eggemann@arm.com,
juri.lelli@redhat.com, peterz@infradead.org,
viresh.kumar@linaro.org, mingo@redhat.com, bsegall@google.com
Hi Rafael,
On 11/25/25 XX:XX, Rafael J. Wysocki wrote:
> On Tue, Nov 25, 2025 at 10:46 AM Christian Loehle
> <christian.loehle@arm.com> wrote:
>>
>> On 11/25/25 09:38, Vincent Guittot wrote:
>> > On Tue, 25 Nov 2025 at 10:23, Kumar, Kaushlendra
>> > <kaushlendra.kumar@intel.com> wrote:
>> >>
>> >> This is with respect to intel platforms which has E-cores and P-cores.
>
> So this is all misguided.
>
> P-cores and E-cores don't even share frequency, so why would they be
> there in the same domain?
>
> On P-cores, frequency can be controlled independently per-core.
>
> E-cores technically go in modules of 4 and the frequency is shared
> within a module, but the interface to control it (HWP or CPPC if you
> will) is per-CPU and intel_pstate treans them as independent.
>
> For this reason, sugov_next_freq_shared() should never be used on Intel
> hardware.
Thank you for the clarification.
BR,
Kaushlendra
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-11-25 14:05 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25 3:24 [PATCH] sched/cpufreq: Fix capacity calc in shared policy update Kaushlendra Kumar
2025-11-25 8:37 ` Christian Loehle
2025-11-25 9:28 ` Kumar, Kaushlendra
2025-11-25 9:04 ` Lukasz Luba
2025-11-25 9:23 ` Kumar, Kaushlendra
2025-11-25 9:38 ` Vincent Guittot
2025-11-25 9:46 ` Christian Loehle
2025-11-25 9:57 ` Vincent Guittot
2025-11-25 12:41 ` Rafael J. Wysocki
2025-11-25 14:05 ` Kumar, Kaushlendra
2025-11-25 12:09 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox