sched/topology: Avoid spurious asymmetry from CPU capacity noise
PATCH 1/1 sched/topology: Avoid spurious asymmetry from CPU capacity noise
On some platforms, the firmware may expose per-CPU performance differences (e.g., via ACPI CPPC highest_perf) even when the system is effectively symmetric. These small variations, typically due to silicon binning, are reflected in arch_scale_cpu_capacity() and end up being interpreted as real capacity asymmetry.
As a result, the scheduler incorrectly enables SD_ASYM_CPUCAPACITY, triggering asymmetry-specific behaviors, even though all CPUs have comparable performance.
Prevent this by treating CPU capacities within 20% of the maximum value as equivalent when building the asymmetry topology. This filters out firmware noise, while preserving correct behavior on real heterogeneous systems, where capacity differences are significantly larger.
--- kernel/sched/topology.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
kernel/sched/topology.c +16 -3
@@ -1432,9 +1432,8 @@ static void free_asym_cap_entry(struct rcu_head *head)kfree (entry); } -static inline void asym_cpu_capacity_update_data (int cpu) +static inline void asym_cpu_capacity_update_data (int cpu,unsigned long capacity) { -unsigned long capacity =arch_scale_cpu_capacity (cpu);struct asym_cap_data *insert_entry =NULL ;struct asym_cap_data *entry;
@@ -1471,13 +1470,27 @@ static inline void asym_cpu_capacity_update_data(int cpu)static void asym_cpu_capacity_scan (void ) {struct asym_cap_data *entry, *next; +unsigned long max_cap =0 ; +unsigned long capacity;int cpu;list_for_each_entry (entry, &asym_cap_list, link)cpumask_clear (cpu_capacity_span (entry));for_each_cpu_and (cpu, cpu_possible_mask,housekeeping_cpumask (HK_TYPE_DOMAIN )) -asym_cpu_capacity_update_data (cpu); + max_cap =max (max_cap,arch_scale_cpu_capacity (cpu)); + +/* +* Treat small capacity differences (< 20% max capacity) as noise, +* to prevent enabling SD_ASYM_CPUCAPACITY when it's not really +* needed. +*/ +for_each_cpu_and (cpu, cpu_possible_mask,housekeeping_cpumask (HK_TYPE_DOMAIN )) { + capacity =arch_scale_cpu_capacity (cpu); +if (capacity *5 >= max_cap *4 ) + capacity = max_cap; +asym_cpu_capacity_update_data (cpu, capacity); + }list_for_each_entry_safe (entry, next, &asym_cap_list, link) {if (cpumask_empty (cpu_capacity_span (entry))) {
Signature · 1 line
2.53.0
Vincent Guittot
maintainerQuoted 7 lines · Andrea Righi
On some platforms, the firmware may expose per-CPU performance differences (e.g., via ACPI CPPC
highest_perf) even when the system is effectively symmetric. These small variations, typically due to silicon binning, are reflected inarch_scale_cpu_capacity()and end up being interpreted as real capacity asymmetry.
Quoted 5 lines
As a result, the scheduler incorrectly enables
SD_ASYM_CPUCAPACITY, triggering asymmetry-specific behaviors, even though all CPUs have comparable performance.Prevent this by treating CPU capacities within 20% of the maximum value
20% is a bit high, my snapdragon rb5 has a mid CPU with a capacity of 871 but we still want to keep them different
Why would 5% not be enough?
Quoted 57 lines
as equivalent when building the asymmetry topology. This filters out firmware noise, while preserving correct behavior on real heterogeneous systems, where capacity differences are significantly larger.
Reported-by Felix Abecassis <[email protected]>Signed-off-by Andrea Righi <[email protected]>--- kernel/sched/topology.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)kernel/sched/topology.c +16
-4@@ -1432,9 +1432,8 @@ static void free_asym_cap_entry(struct rcu_head *head)kfree (entry); } -static inline void asym_cpu_capacity_update_data (int cpu) +static inline void asym_cpu_capacity_update_data (int cpu,unsigned long capacity) { -unsigned long capacity =arch_scale_cpu_capacity (cpu);struct asym_cap_data *insert_entry =NULL ;struct asym_cap_data *entry;@@ -1471,13 +1470,27 @@ static inline void asym_cpu_capacity_update_data(int cpu)static void asym_cpu_capacity_scan (void ) {struct asym_cap_data *entry, *next; +unsigned long max_cap =0 ; +unsigned long capacity;int cpu;list_for_each_entry (entry, &asym_cap_list, link)cpumask_clear (cpu_capacity_span (entry));for_each_cpu_and (cpu, cpu_possible_mask,housekeeping_cpumask (HK_TYPE_DOMAIN )) -asym_cpu_capacity_update_data (cpu); + max_cap =max (max_cap,arch_scale_cpu_capacity (cpu)); + +/* +* Treat small capacity differences (< 20% max capacity) as noise, +* to prevent enabling SD_ASYM_CPUCAPACITY when it's not really +* needed. +*/ +for_each_cpu_and (cpu, cpu_possible_mask,housekeeping_cpumask (HK_TYPE_DOMAIN )) { + capacity =arch_scale_cpu_capacity (cpu); +if (capacity *5 >= max_cap *4 ) + capacity = max_cap; +asym_cpu_capacity_update_data (cpu, capacity); + }list_for_each_entry_safe (entry, next, &asym_cap_list, link) {if (cpumask_empty (cpu_capacity_span (entry))) { --2.53.0
Quoted 12 lines · Vincent Guittot
Quoted 11 lines · Andrea Righi
On some platforms, the firmware may expose per-CPU performance differences (e.g., via ACPI CPPC
highest_perf) even when the system is effectively symmetric. These small variations, typically due to silicon binning, are reflected inarch_scale_cpu_capacity()and end up being interpreted as real capacity asymmetry.As a result, the scheduler incorrectly enables
SD_ASYM_CPUCAPACITY, triggering asymmetry-specific behaviors, even though all CPUs have comparable performance.
Quoted 6 lines
Quoted 1 line
Prevent this by treating CPU capacities within 20% of the maximum value
20% is a bit high, my snapdragon rb5 has a mid CPU with a capacity of 871 but we still want to keep them different
Why would 5% not be enough?
I've also used 5%, or rather the existing capacity_greater() macro.
Quoted 1 line
[snip]
Quoted 13 lines · Christian Loehle
Quoted 12 lines · Vincent Guittot
Quoted 11 lines · Andrea Righi
On some platforms, the firmware may expose per-CPU performance differences (e.g., via ACPI CPPC
highest_perf) even when the system is effectively symmetric. These small variations, typically due to silicon binning, are reflected inarch_scale_cpu_capacity()and end up being interpreted as real capacity asymmetry.As a result, the scheduler incorrectly enables
SD_ASYM_CPUCAPACITY, triggering asymmetry-specific behaviors, even though all CPUs have comparable performance.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Prevent this by treating CPU capacities within 20% of the maximum value
20% is a bit high, my snapdragon rb5 has a mid CPU with a capacity of 871 but we still want to keep them different
Why would 5% not be enough?
I've also used 5%, or rather the existing
capacity_greater()macro.
Also, given that this patch even mentions this as "noise" one might ask why the firmware wouldn't force-equalise this.
Anyway let me finally send out those asympacking patches which would make that issue obsolete because we actually make use of the highest_perf information from the firmware.
Quoted 3 lines
Quoted 2 lines
[snip]
Hi Christian,
Quoted 19 lines · Christian Loehle
Quoted 18 lines · Christian Loehle
Quoted 17 lines · Vincent Guittot
Quoted 7 lines · Andrea Righi
On some platforms, the firmware may expose per-CPU performance differences (e.g., via ACPI CPPC
highest_perf) even when the system is effectively symmetric. These small variations, typically due to silicon binning, are reflected inarch_scale_cpu_capacity()and end up being interpreted as real capacity asymmetry.Quoted 5 lines
As a result, the scheduler incorrectly enables
SD_ASYM_CPUCAPACITY, triggering asymmetry-specific behaviors, even though all CPUs have comparable performance.Prevent this by treating CPU capacities within 20% of the maximum value
20% is a bit high, my snapdragon rb5 has a mid CPU with a capacity of 871 but we still want to keep them different
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Why would 5% not be enough?
I've also used 5%, or rather the existing
capacity_greater()macro.Also, given that this patch even mentions this as "noise" one might ask why the firmware wouldn't force-equalise this.
I think it's reasonable to consider that as "noise" from a scheduler perspective, but from a hardware/firmware point of view I don't have strong arguments to propose equalizing the highest_perf values. At the end, at least in my case, it seems all compliant with the ACPI/CPPC specs and suggesting to equalize them because "the kernel doesn't handle it well" doesn't seem like a solid motivation...
Quoted 3 lines
Anyway let me finally send out those asympacking patches which would make that issue obsolete because we actually make use of the
highest_perfinformation from the firmware.
Looking forward to that. :)
Thanks,
-Andrea
Dietmar Eggemann
reviewerQuoted 6 lines · Andrea Righi
Hi Christian,
Quoted 3 lines · Christian Loehle
Quoted 2 lines · Christian Loehle
Quoted 1 line · Vincent Guittot
On Tue, 24 Mar 2026 at 01:55, Andrea Righi <[email protected]> wrote:
[...]
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
20% is a bit high, my snapdragon rb5 has a mid CPU with a capacity of 871 but we still want to keep them different
Why would 5% not be enough?
I've also used 5%, or rather the existing
capacity_greater()macro.Also, given that this patch even mentions this as "noise" one might ask why the firmware wouldn't force-equalise this.
Quoted 6 lines
I think it's reasonable to consider that as "noise" from a scheduler perspective, but from a hardware/firmware point of view I don't have strong arguments to propose equalizing the
highest_perfvalues. At the end, at least in my case, it seems all compliant with the ACPI/CPPC specs and suggesting to equalize them because "the kernel doesn't handle it well" doesn't seem like a solid motivation...
The first time we observed this on NVIDIA Grace, we wondered whether there might be functionality outside the task scheduler that makes use of these slightly heterogeneous CPU capacity values from CPPC—and whether the dependency on task scheduling was simply an overlooked phenomenon.
And then there was DCPerf Mediawiki on 72 CPUs system always scoring better with sched_asym_cpucap_active() = TRUE (mentioned already by Chris L. in:
https://lore.kernel.org/r/[email protected]
Quoted 8 lines
Quoted 3 lines
Anyway let me finally send out those asympacking patches which would make that issue obsolete because we actually make use of the
highest_perfinformation from the firmware.Looking forward to that. :)
Thanks,
-Andrea
Hi Dietmar,
Quoted 33 lines · Dietmar Eggemann
Quoted 6 lines · Andrea Righi
Hi Christian,
Quoted 3 lines · Christian Loehle
Quoted 2 lines · Christian Loehle
Quoted 1 line · Vincent Guittot
On Tue, 24 Mar 2026 at 01:55, Andrea Righi <[email protected]> wrote:
[...]
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
20% is a bit high, my snapdragon rb5 has a mid CPU with a capacity of 871 but we still want to keep them different
Why would 5% not be enough?
I've also used 5%, or rather the existing
capacity_greater()macro.Also, given that this patch even mentions this as "noise" one might ask why the firmware wouldn't force-equalise this.
Quoted 6 lines
I think it's reasonable to consider that as "noise" from a scheduler perspective, but from a hardware/firmware point of view I don't have strong arguments to propose equalizing the
highest_perfvalues. At the end, at least in my case, it seems all compliant with the ACPI/CPPC specs and suggesting to equalize them because "the kernel doesn't handle it well" doesn't seem like a solid motivation...The first time we observed this on NVIDIA Grace, we wondered whether there might be functionality outside the task scheduler that makes use of these slightly heterogeneous CPU capacity values from CPPC—and whether the dependency on task scheduling was simply an overlooked phenomenon.
Quoted 4 lines
And then there was DCPerf Mediawiki on 72 CPUs system always scoring better with
sched_asym_cpucap_active()= TRUE (mentioned already by Chris L. in:
https://lore.kernel.org/r/[email protected]
Yeah, I think Chris' asym-packing approach might be the safest thing to do.
At the same time it would be nice to improve asym-capacity to introduce some concept of SMT awareness, that was my original attempt with
https://lore.kernel.org/all/[email protected],
since we may see similar asym-capacity benefits on Vera (that has SMT, unlike Grace). What do you think?
Thanks,
-Andrea
Dietmar Eggemann
reviewerQuoted 10 lines · Andrea Righi
Hi Dietmar,
Quoted 7 lines · Dietmar Eggemann
Quoted 6 lines · Andrea Righi
Hi Christian,
Quoted 3 lines · Christian Loehle
Quoted 2 lines · Christian Loehle
Quoted 1 line · Vincent Guittot
On Tue, 24 Mar 2026 at 01:55, Andrea Righi <[email protected]> wrote:
[...]
Quoted 11 lines
Quoted 10 lines
The first time we observed this on NVIDIA Grace, we wondered whether there might be functionality outside the task scheduler that makes use of these slightly heterogeneous CPU capacity values from CPPC—and whether the dependency on task scheduling was simply an overlooked phenomenon.
And then there was DCPerf Mediawiki on 72 CPUs system always scoring better with
sched_asym_cpucap_active()= TRUE (mentioned already by Chris L. in:
https://lore.kernel.org/r/[email protected]
Quoted 7 lines
Yeah, I think Chris' asym-packing approach might be the safest thing to do.
At the same time it would be nice to improve asym-capacity to introduce some concept of SMT awareness, that was my original attempt with
https://lore.kernel.org/all/[email protected],
since we may see similar asym-capacity benefits on Vera (that has SMT, unlike Grace). What do you think?
We never found a good way to specify a CPU capacity in the SMT case (EAS and energy model included). So comparing CPU capacity w/ utilization, CPU overutilization detection etc. definitions get more blurry.
But in case you now want to hide these small CPU capacity differences from asym-cpucap setup you won't run into this 'SD_SHARE_CPUCAPACITY + SD_ASYM_CPUCAPACITY'.
You still will have small differences in sched group capacities but this is covered by load-balance.
BTW, you should have seen on Vera ?:
sd_int() [kernel/sched/.topology.c]
1720 WARN_ONCE((sd->flags & (SD_SHARE_CPUCAPACITY | SD_ASYM_CPUCAPACITY)) ==
1721 (SD_SHARE_CPUCAPACITY | SD_ASYM_CPUCAPACITY),
1722 "CPU capacity asymmetry not supported on SMT\n");
Quoted 33 lines · Dietmar Eggemann
Quoted 10 lines · Andrea Righi
Hi Dietmar,
Quoted 7 lines · Dietmar Eggemann
Quoted 6 lines · Andrea Righi
Hi Christian,
Quoted 3 lines · Christian Loehle
Quoted 2 lines · Christian Loehle
Quoted 1 line · Vincent Guittot
On Tue, 24 Mar 2026 at 01:55, Andrea Righi <[email protected]> wrote:
[...]
Quoted 11 lines
Quoted 10 lines
The first time we observed this on NVIDIA Grace, we wondered whether there might be functionality outside the task scheduler that makes use of these slightly heterogeneous CPU capacity values from CPPC—and whether the dependency on task scheduling was simply an overlooked phenomenon.
And then there was DCPerf Mediawiki on 72 CPUs system always scoring better with
sched_asym_cpucap_active()= TRUE (mentioned already by Chris L. in:
https://lore.kernel.org/r/[email protected]Quoted 7 lines
Yeah, I think Chris' asym-packing approach might be the safest thing to do.
At the same time it would be nice to improve asym-capacity to introduce some concept of SMT awareness, that was my original attempt with
https://lore.kernel.org/all/[email protected],
since we may see similar asym-capacity benefits on Vera (that has SMT, unlike Grace). What do you think?
Quoted 3 lines
We never found a good way to specify a CPU capacity in the SMT case (EAS and energy model included). So comparing CPU capacity w/ utilization, CPU overutilization detection etc. definitions get more blurry.
Hm... so should we just avoid calling select_idle_capacity() when SMT is enabled to prevent waking up tasks on both SMT siblings when there are fully-idle SMT cores?
Quoted 8 lines
But in case you now want to hide these small CPU capacity differences from asym-cpucap setup you won't run into this '
SD_SHARE_CPUCAPACITY+SD_ASYM_CPUCAPACITY'.You still will have small differences in sched group capacities but this is covered by load-balance.
Quoted 7 lines
BTW, you should have seen on Vera ?:
sd_int()[kernel/sched/.topology.c]1720 WARN_ONCE((sd->flags & (
SD_SHARE_CPUCAPACITY|SD_ASYM_CPUCAPACITY)) ==
1721 (SD_SHARE_CPUCAPACITY|SD_ASYM_CPUCAPACITY),
1722 "CPU capacity asymmetry not supported on SMT\n");
Yep, I've seen that. :)
Thanks,
-Andrea
Dietmar Eggemann
reviewerQuoted 34 lines · Andrea Righi
Quoted 33 lines · Dietmar Eggemann
Quoted 10 lines · Andrea Righi
Hi Dietmar,
Quoted 7 lines · Dietmar Eggemann
Quoted 6 lines · Andrea Righi
Hi Christian,
Quoted 3 lines · Christian Loehle
Quoted 2 lines · Christian Loehle
Quoted 1 line · Vincent Guittot
On Tue, 24 Mar 2026 at 01:55, Andrea Righi <[email protected]> wrote:
[...]
Quoted 18 lines
Quoted 10 lines
The first time we observed this on NVIDIA Grace, we wondered whether there might be functionality outside the task scheduler that makes use of these slightly heterogeneous CPU capacity values from CPPC—and whether the dependency on task scheduling was simply an overlooked phenomenon.
And then there was DCPerf Mediawiki on 72 CPUs system always scoring better with
sched_asym_cpucap_active()= TRUE (mentioned already by Chris L. in:
https://lore.kernel.org/r/[email protected]Yeah, I think Chris' asym-packing approach might be the safest thing to do.
At the same time it would be nice to improve asym-capacity to introduce some concept of SMT awareness, that was my original attempt with
https://lore.kernel.org/all/[email protected],
since we may see similar asym-capacity benefits on Vera (that has SMT, unlike Grace). What do you think?
Quoted 7 lines
Quoted 3 lines
We never found a good way to specify a CPU capacity in the SMT case (EAS and energy model included). So comparing CPU capacity w/ utilization, CPU overutilization detection etc. definitions get more blurry.
Hm... so should we just avoid calling
select_idle_capacity()when SMT is enabled to prevent waking up tasks on both SMT siblings when there are fully-idle SMT cores?
Yeah, pretty much. So prefer (2) over (1).
IMHO, we do have a similar issue here. Can we say that a logical CPU is idle if its SMT sibling isn't? But at least we don't have to use any CPU cap/util comparison there.
select_idle_sibling()
8132 if (sched_smt_active()) {
8133 has_idle_core = test_idle_cores(target);
8134
8135 if (!has_idle_core && cpus_share_cache(prev, target)) { <-- (1)
8136 i = select_idle_smt(p, sd, prev);
8137 if ((unsigned int)i < nr_cpumask_bits)
8138 return i;
8139 }
8140 }
8141
8142 i = select_idle_cpu(p, sd, has_idle_core, target); <-- (2a)
8143 if ((unsigned)i < nr_cpumask_bits)
8144 return i
select_idle_cpu()
7926 for_each_cpu_wrap(cpu, cpus, target + 1) {
7927 if (has_idle_core) {
7928 i = select_idle_core(p, cpu, cpus, &idle_cpu); <-- (2b)
7929 if ((unsigned int)i < nr_cpumask_bits)
7930 return i;
7931
7932 } else {
7933 if (--nr <= 0)
7934 return -1;
7935 idle_cpu = __select_idle_cpu(cpu, p);
7936 if ((unsigned int)idle_cpu < nr_cpumask_bits)
7937 break;
7938 }
7939 }
[...]
Quoted 67 lines · Dietmar Eggemann
Quoted 34 lines · Andrea Righi
Quoted 33 lines · Dietmar Eggemann
Quoted 10 lines · Andrea Righi
Hi Dietmar,
Quoted 7 lines · Dietmar Eggemann
Quoted 6 lines · Andrea Righi
Hi Christian,
Quoted 3 lines · Christian Loehle
Quoted 2 lines · Christian Loehle
Quoted 1 line · Vincent Guittot
On Tue, 24 Mar 2026 at 01:55, Andrea Righi <[email protected]> wrote:
[...]
Quoted 18 lines
Quoted 10 lines
The first time we observed this on NVIDIA Grace, we wondered whether there might be functionality outside the task scheduler that makes use of these slightly heterogeneous CPU capacity values from CPPC—and whether the dependency on task scheduling was simply an overlooked phenomenon.
And then there was DCPerf Mediawiki on 72 CPUs system always scoring better with
sched_asym_cpucap_active()= TRUE (mentioned already by Chris L. in:
https://lore.kernel.org/r/[email protected]Yeah, I think Chris' asym-packing approach might be the safest thing to do.
At the same time it would be nice to improve asym-capacity to introduce some concept of SMT awareness, that was my original attempt with
https://lore.kernel.org/all/[email protected],
since we may see similar asym-capacity benefits on Vera (that has SMT, unlike Grace). What do you think?Quoted 7 lines
Quoted 3 lines
We never found a good way to specify a CPU capacity in the SMT case (EAS and energy model included). So comparing CPU capacity w/ utilization, CPU overutilization detection etc. definitions get more blurry.
Hm... so should we just avoid calling
select_idle_capacity()when SMT is enabled to prevent waking up tasks on both SMT siblings when there are fully-idle SMT cores?Yeah, pretty much. So prefer (2) over (1).
IMHO, we do have a similar issue here. Can we say that a logical CPU is idle if its SMT sibling isn't? But at least we don't have to use any CPU cap/util comparison there.
select_idle_sibling()8132 if (
sched_smt_active()) {
8133has_idle_core=test_idle_cores(target);
8134
8135 if (!has_idle_core &&cpus_share_cache(prev, target)) { <-- (1)
8136 i =select_idle_smt(p, sd, prev);
8137 if ((unsigned int)i <nr_cpumask_bits)
8138 return i;
8139 }
8140 }
8141
8142 i =select_idle_cpu(p, sd, has_idle_core, target); <-- (2a)
8143 if ((unsigned)i <nr_cpumask_bits)
8144 return i
select_idle_cpu()
Quoted 14 lines
7926
for_each_cpu_wrap(cpu, cpus, target + 1){
7927 if (has_idle_core) {
7928 i =select_idle_core(p, cpu, cpus, &idle_cpu); <-- (2b)
7929 if ((unsigned int)i <nr_cpumask_bits)
7930 return i;
7931
7932 } else {
7933 if (--nr <= 0)
7934 return -1;
7935idle_cpu=__select_idle_cpu(cpu, p);
7936 if ((unsigned int)idle_cpu <nr_cpumask_bits)
7937 break;
7938 }
7939 }
Exactly, we already prefer fully-idle cores over partially-idle cores with asym-capacity disabled, but in that case the idle selection logic stays in a world of idle bits, without cap/util math, so it's a bit easier. And it's probably fine also when we have both asym-capacity + SMT (at least it seems better than what we have now, ignoring the SMT part).
Essentially having somethig like the following (which already gives better performance on Vera):
kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -8086,7 +8086,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)* For asymmetric CPU capacity systems, our domain of interest is * sd_asym_cpucapacity rather than sd_llc. */ -if (sched_asym_cpucap_active ()) { +if (sched_asym_cpucap_active () && !sched_smt_active ()) { sd =rcu_dereference_all (per_cpu (sd_asym_cpucapacity, target));/* * On an asymmetric CPU capacity system where an exclusive
Thanks,
-Andrea
Dietmar Eggemann
reviewerQuoted 14 lines · Andrea Righi
Quoted 13 lines · Dietmar Eggemann
Quoted 12 lines · Andrea Righi
Quoted 11 lines · Dietmar Eggemann
Quoted 10 lines · Andrea Righi
Hi Dietmar,
Quoted 7 lines · Dietmar Eggemann
Quoted 6 lines · Andrea Righi
Hi Christian,
Quoted 3 lines · Christian Loehle
Quoted 2 lines · Christian Loehle
Quoted 1 line · Vincent Guittot
On Tue, 24 Mar 2026 at 01:55, Andrea Righi <[email protected]> wrote:
[...]
Quoted 17 lines
Exactly, we already prefer fully-idle cores over partially-idle cores with asym-capacity disabled, but in that case the idle selection logic stays in a world of idle bits, without cap/util math, so it's a bit easier. And it's probably fine also when we have both asym-capacity + SMT (at least it seems better than what we have now, ignoring the SMT part).
Essentially having somethig like the following (which already gives better performance on Vera):
kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/fair.c +0
-0
kernel/sched/fair.c static int select_idle_sibling(struct task_struct *p, int prev, int target) · line 8092
Quoted 8 lines
kernel/sched/fair.c +1
-1@@ -8086,7 +8086,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)* For asymmetric CPU capacity systems, our domain of interest is * sd_asym_cpucapacity rather than sd_llc. */ -if (sched_asym_cpucap_active ()) { +if (sched_asym_cpucap_active () && !sched_smt_active ()) { sd =rcu_dereference_all (per_cpu (sd_asym_cpucapacity, target));/* * On an asymmetric CPU capacity system where an exclusive
Ah, I thought we were talking !sched_asym_cpucap_active() case, either by letting CPPC return the same value for all CPUs or by introducing this 20%/5% threshold into asym_cpu_capacity_scan().
ASYM_CPUCAP + SHARE_CPUCAP vs SHARE_CPUCAP would still behave slightly differently because of asym_fits_cpu() in all those early bailout conditions (1) in sis().
select_idle_sibling()
if (choose_idle_cpu(target, p) &&
asym_fits_cpu(task_util, util_min, util_max, target)) <-- (1)
return target;
...And you would still have misfit_task load balance enabled.
Those subtle differences may influence behavior compared to a simpler homogeneous CPU capacity model, but it’s unclear whether they justify introducing yet another variant alongside the existing homogeneous and fully heterogeneous (non-SMT) approaches.
IMHO, we should only consider allowing this if there is clear evidence of significant benefits across a representative range of benchmarks and workloads.
[...]
Quoted 39 lines · Dietmar Eggemann
Quoted 14 lines · Andrea Righi
Quoted 13 lines · Dietmar Eggemann
Quoted 12 lines · Andrea Righi
Quoted 11 lines · Dietmar Eggemann
Quoted 10 lines · Andrea Righi
Hi Dietmar,
Quoted 7 lines · Dietmar Eggemann
Quoted 6 lines · Andrea Righi
Hi Christian,
Quoted 3 lines · Christian Loehle
Quoted 2 lines · Christian Loehle
Quoted 1 line · Vincent Guittot
On Tue, 24 Mar 2026 at 01:55, Andrea Righi <[email protected]> wrote:
[...]
Quoted 21 lines
Exactly, we already prefer fully-idle cores over partially-idle cores with asym-capacity disabled, but in that case the idle selection logic stays in a world of idle bits, without cap/util math, so it's a bit easier. And it's probably fine also when we have both asym-capacity + SMT (at least it seems better than what we have now, ignoring the SMT part).
Essentially having somethig like the following (which already gives better performance on Vera):
kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/fair.c +0
-1@@ -8086,7 +8086,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)* For asymmetric CPU capacity systems, our domain of interest is * sd_asym_cpucapacity rather than sd_llc. */ -if (sched_asym_cpucap_active ()) {
Quoted 8 lines
kernel/sched/fair.c static int select_idle_sibling(struct task_struct *p, int prev, int target) · line 8092
Quoted 4 lines
kernel/sched/fair.c +1
-0+if (sched_asym_cpucap_active () && !sched_smt_active ()) { sd =rcu_dereference_all (per_cpu (sd_asym_cpucapacity, target));/* * On an asymmetric CPU capacity system where an exclusive Ah, I thought we were talking !sched_asym_cpucap_active() case, either by letting CPPC return the same value for all CPUs or by introducing this 20%/5% threshold into
asym_cpu_capacity_scan().
Sure, we can also equalize capacity via CPPC, but I tought we were worried about potential regressions with other systems that don't have SMT and may actually benefit from the asym-capacity logic.
Moreover, if any other platform with SMT enables asym CPU by slightly exceeding the 5% margin, we may face the same issue again.
Quoted 5 lines
ASYM_CPUCAP+SHARE_CPUCAPvsSHARE_CPUCAPwould still behave slightly differently because ofasym_fits_cpu()in all those early bailout conditions (1) insis().
Quoted 7 lines
select_idle_sibling()if (choose_idle_cpu(target, p) && asym_fits_cpu(task_util, util_min, util_max, target)) <-- (1) return target; ...
Ah yes, this also needs to be changed...
Quoted 2 lines
And you would still have
misfit_taskload balance enabled.
Correct, in fact to get the optimal performance on Vera with asym-capacity enabled, I also need to fix the misfit logic to prioritize fully-idle SMT cores. Same with find_new_ilb() and potentially other places. With these I get almost 2x improvement in some cases, which is pretty big.
But I get similar results also disabling asym-capacity via the 5% threshold.
Quoted 9 lines
Those subtle differences may influence behavior compared to a simpler homogeneous CPU capacity model, but it’s unclear whether they justify introducing yet another variant alongside the existing homogeneous and fully heterogeneous (non-SMT) approaches.
IMHO, we should only consider allowing this if there is clear evidence of significant benefits across a representative range of benchmarks and workloads.
Totally agree. But there's still the fact that select_idle_capacity() is not compatible with SMT, so it should be avoided when SMT is enabled, in a way or another.
Thanks,
-Andrea
Quoted 34 lines · On Wed, Mar 25, 2026 at 10:32:28AM +0100 Andrea Righi wrote:
Quoted 33 lines · Dietmar Eggemann
Quoted 10 lines · Andrea Righi
Hi Dietmar,
Quoted 7 lines · Dietmar Eggemann
Quoted 6 lines · Andrea Righi
Hi Christian,
Quoted 3 lines · Christian Loehle
Quoted 2 lines · Christian Loehle
Quoted 1 line · Vincent Guittot
On Tue, 24 Mar 2026 at 01:55, Andrea Righi <[email protected]> wrote:
[...]
Quoted 18 lines
Quoted 10 lines
The first time we observed this on NVIDIA Grace, we wondered whether there might be functionality outside the task scheduler that makes use of these slightly heterogeneous CPU capacity values from CPPC—and whether the dependency on task scheduling was simply an overlooked phenomenon.
And then there was DCPerf Mediawiki on 72 CPUs system always scoring better with
sched_asym_cpucap_active()= TRUE (mentioned already by Chris L. in:
https://lore.kernel.org/r/[email protected]Yeah, I think Chris' asym-packing approach might be the safest thing to do.
At the same time it would be nice to improve asym-capacity to introduce some concept of SMT awareness, that was my original attempt with
https://lore.kernel.org/all/[email protected],
since we may see similar asym-capacity benefits on Vera (that has SMT, unlike Grace). What do you think?
Quoted 8 lines
Quoted 3 lines
We never found a good way to specify a CPU capacity in the SMT case (EAS and energy model included). So comparing CPU capacity w/ utilization, CPU overutilization detection etc. definitions get more blurry.
Hm... so should we just avoid calling
select_idle_capacity()when SMT is enabled to prevent waking up tasks on both SMT siblings when there are fully-idle SMT cores?
That might be a good idea. Especially if it's general and not tied to EAS/ASYM. I'm getting some requests for something like that.
CHeers,
Phil
Quoted 21 lines
Quoted 8 lines
But in case you now want to hide these small CPU capacity differences from asym-cpucap setup you won't run into this '
SD_SHARE_CPUCAPACITY+SD_ASYM_CPUCAPACITY'.You still will have small differences in sched group capacities but this is covered by load-balance.
Quoted 7 lines
BTW, you should have seen on Vera ?:
sd_int()[kernel/sched/.topology.c]1720 WARN_ONCE((sd->flags & (
SD_SHARE_CPUCAPACITY|SD_ASYM_CPUCAPACITY)) ==
1721 (SD_SHARE_CPUCAPACITY|SD_ASYM_CPUCAPACITY),
1722 "CPU capacity asymmetry not supported on SMT\n");Yep, I've seen that. :)
Thanks,
-Andrea
Hi Vincent,
Quoted 12 lines · Vincent Guittot
Quoted 11 lines · Andrea Righi
On some platforms, the firmware may expose per-CPU performance differences (e.g., via ACPI CPPC
highest_perf) even when the system is effectively symmetric. These small variations, typically due to silicon binning, are reflected inarch_scale_cpu_capacity()and end up being interpreted as real capacity asymmetry.As a result, the scheduler incorrectly enables
SD_ASYM_CPUCAPACITY, triggering asymmetry-specific behaviors, even though all CPUs have comparable performance.
Quoted 6 lines
Quoted 1 line
Prevent this by treating CPU capacities within 20% of the maximum value
20% is a bit high, my snapdragon rb5 has a mid CPU with a capacity of 871 but we still want to keep them different
Why would 5% not be enough?
Sure, 5% seems a more reasonable margin. I'll just reuse capacity_greater() as suggested by Christian.
Thanks,
-Andrea
Quoted 60 lines
Quoted 60 lines
as equivalent when building the asymmetry topology. This filters out firmware noise, while preserving correct behavior on real heterogeneous systems, where capacity differences are significantly larger.
Reported-by Felix Abecassis <[email protected]>Signed-off-by Andrea Righi <[email protected]>--- kernel/sched/topology.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)kernel/sched/topology.c +16
-4@@ -1432,9 +1432,8 @@ static void free_asym_cap_entry(struct rcu_head *head)kfree (entry); } -static inline void asym_cpu_capacity_update_data (int cpu) +static inline void asym_cpu_capacity_update_data (int cpu,unsigned long capacity) { -unsigned long capacity =arch_scale_cpu_capacity (cpu);struct asym_cap_data *insert_entry =NULL ;struct asym_cap_data *entry;@@ -1471,13 +1470,27 @@ static inline void asym_cpu_capacity_update_data(int cpu)static void asym_cpu_capacity_scan (void ) {struct asym_cap_data *entry, *next; +unsigned long max_cap =0 ; +unsigned long capacity;int cpu;list_for_each_entry (entry, &asym_cap_list, link)cpumask_clear (cpu_capacity_span (entry));for_each_cpu_and (cpu, cpu_possible_mask,housekeeping_cpumask (HK_TYPE_DOMAIN )) -asym_cpu_capacity_update_data (cpu); + max_cap =max (max_cap,arch_scale_cpu_capacity (cpu)); + +/* +* Treat small capacity differences (< 20% max capacity) as noise, +* to prevent enabling SD_ASYM_CPUCAPACITY when it's not really +* needed. +*/ +for_each_cpu_and (cpu, cpu_possible_mask,housekeeping_cpumask (HK_TYPE_DOMAIN )) { + capacity =arch_scale_cpu_capacity (cpu); +if (capacity *5 >= max_cap *4 ) + capacity = max_cap; +asym_cpu_capacity_update_data (cpu, capacity); + }list_for_each_entry_safe (entry, next, &asym_cap_list, link) {if (cpumask_empty (cpu_capacity_span (entry))) { --2.53.0
Quoted 20 lines · Andrea Righi
Hi Vincent,
Quoted 17 lines · Vincent Guittot
Quoted 7 lines · Andrea Righi
On some platforms, the firmware may expose per-CPU performance differences (e.g., via ACPI CPPC
highest_perf) even when the system is effectively symmetric. These small variations, typically due to silicon binning, are reflected inarch_scale_cpu_capacity()and end up being interpreted as real capacity asymmetry.Quoted 5 lines
As a result, the scheduler incorrectly enables
SD_ASYM_CPUCAPACITY, triggering asymmetry-specific behaviors, even though all CPUs have comparable performance.Prevent this by treating CPU capacities within 20% of the maximum value
20% is a bit high, my snapdragon rb5 has a mid CPU with a capacity of 871 but we still want to keep them different
Quoted 8 lines
Quoted 1 line
Why would 5% not be enough?
Sure, 5% seems a more reasonable margin. I'll just reuse
capacity_greater()as suggested by Christian.Thanks,
-Andrea
How about modifying asym_cpu_capacity_update_data to group all CPUs within 5% capacity difference into the same group?
```
+#define capacity_greater(cap1, cap2) ((cap1) * 1024 > (cap2) * 1078)
list_for_each_entry(entry, &asym_cap_list, link) {
- if (capacity == entry->capacity)
+ if (!capacity_greater(capacity, entry->capacity) &&
+ !capacity_greater(entry->capacity, capacity))
```Quoted 60 lines
Quoted 60 lines
Quoted 60 lines
as equivalent when building the asymmetry topology. This filters out firmware noise, while preserving correct behavior on real heterogeneous systems, where capacity differences are significantly larger.
Reported-by Felix Abecassis <[email protected]>Signed-off-by Andrea Righi <[email protected]>--- kernel/sched/topology.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)kernel/sched/topology.c +16
-4@@ -1432,9 +1432,8 @@ static void free_asym_cap_entry(struct rcu_head *head)kfree (entry); } -static inline void asym_cpu_capacity_update_data (int cpu) +static inline void asym_cpu_capacity_update_data (int cpu,unsigned long capacity) { -unsigned long capacity =arch_scale_cpu_capacity (cpu);struct asym_cap_data *insert_entry =NULL ;struct asym_cap_data *entry;@@ -1471,13 +1470,27 @@ static inline void asym_cpu_capacity_update_data(int cpu)static void asym_cpu_capacity_scan (void ) {struct asym_cap_data *entry, *next; +unsigned long max_cap =0 ; +unsigned long capacity;int cpu;list_for_each_entry (entry, &asym_cap_list, link)cpumask_clear (cpu_capacity_span (entry));for_each_cpu_and (cpu, cpu_possible_mask,housekeeping_cpumask (HK_TYPE_DOMAIN )) -asym_cpu_capacity_update_data (cpu); + max_cap =max (max_cap,arch_scale_cpu_capacity (cpu)); + +/* +* Treat small capacity differences (< 20% max capacity) as noise, +* to prevent enabling SD_ASYM_CPUCAPACITY when it's not really +* needed. +*/ +for_each_cpu_and (cpu, cpu_possible_mask,housekeeping_cpumask (HK_TYPE_DOMAIN )) { + capacity =arch_scale_cpu_capacity (cpu); +if (capacity *5 >= max_cap *4 ) + capacity = max_cap; +asym_cpu_capacity_update_data (cpu, capacity); + }list_for_each_entry_safe (entry, next, &asym_cap_list, link) {if (cpumask_empty (cpu_capacity_span (entry))) { --2.53.0
Hi Koba,
Quoted 32 lines · Koba Ko
Quoted 20 lines · Andrea Righi
Hi Vincent,
Quoted 17 lines · Vincent Guittot
Quoted 7 lines · Andrea Righi
On some platforms, the firmware may expose per-CPU performance differences (e.g., via ACPI CPPC
highest_perf) even when the system is effectively symmetric. These small variations, typically due to silicon binning, are reflected inarch_scale_cpu_capacity()and end up being interpreted as real capacity asymmetry.Quoted 5 lines
As a result, the scheduler incorrectly enables
SD_ASYM_CPUCAPACITY, triggering asymmetry-specific behaviors, even though all CPUs have comparable performance.Prevent this by treating CPU capacities within 20% of the maximum value
20% is a bit high, my snapdragon rb5 has a mid CPU with a capacity of 871 but we still want to keep them different
Quoted 8 lines
Quoted 1 line
Why would 5% not be enough?
Sure, 5% seems a more reasonable margin. I'll just reuse
capacity_greater()as suggested by Christian.Thanks,
-AndreaHow about modifying
asym_cpu_capacity_update_datato group all CPUs within 5% capacity difference into the same group? ```
Review
Quoted 6 lines
(quoted diff) +3
-1+#define capacity_greater(cap1, cap2) ((cap1) * 1024 > (cap2) * 1078) list_for_each_entry(entry, &asym_cap_list, link) { - if (capacity == entry->capacity) + if (!capacity_greater(capacity, entry->capacity) && + !capacity_greater(entry->capacity, capacity))
Yeah, makes sense, I like this better than mine. But there's still the concern of potentially regressing other systems, nullifying the small asym-capacity benefits (as Chris mentioned here:
https://lore.kernel.org/r/[email protected]).
Thanks,
-Andrea