[PATCH 3/6] sched/topology: Account asym capacities number
From: Frederic Weisbecker
Date: Thu Jun 25 2026 - 12:43:20 EST
The timer migration code will need to know the number of capacities
in the system and the maximum number of CPUs a capacity can contain
in order to build the tree accordingly.
Prepare the relevant APIs.
Signed-off-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
---
include/linux/sched/topology.h | 2 ++
kernel/sched/topology.c | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
index b5d9d7c2b8ad..88632825136e 100644
--- a/include/linux/sched/topology.h
+++ b/include/linux/sched/topology.h
@@ -50,6 +50,8 @@ extern const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl,
extern const struct cpumask *tl_pkg_mask(struct sched_domain_topology_level *tl, int cpu);
extern int arch_asym_cpu_priority(int cpu);
+extern int sched_asym_count(void);
+extern int sched_asym_max_cpus(void);
struct sched_domain_attr {
int relax_domain_level;
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 622e2e01974c..3b3bd32aea40 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1746,6 +1746,20 @@ static inline void asym_cpu_capacity_update_data(int cpu)
__cpumask_set_cpu(cpu, cpu_capacity_span(entry));
}
+static int asym_capacity_nr;
+
+int sched_asym_count(void)
+{
+ return asym_capacity_nr;
+}
+
+static int asym_capacity_max_cpus;
+
+int sched_asym_max_cpus(void)
+{
+ return asym_capacity_max_cpus;
+}
+
/*
* Build-up/update list of CPUs grouped by their capacities
* An update requires explicit request to rebuild sched domains
@@ -1756,6 +1770,9 @@ static void asym_cpu_capacity_scan(void)
struct asym_cap_data *entry, *next;
int cpu;
+ asym_capacity_nr = 0;
+ asym_capacity_max_cpus = 0;
+
list_for_each_entry(entry, &asym_cap_list, link)
cpumask_clear(cpu_capacity_span(entry));
@@ -1766,6 +1783,13 @@ static void asym_cpu_capacity_scan(void)
if (cpumask_empty(cpu_capacity_span(entry))) {
list_del_rcu(&entry->link);
call_rcu(&entry->rcu, free_asym_cap_entry);
+ } else {
+ int weight;
+
+ asym_capacity_nr++;
+ weight = cpumask_weight(cpu_capacity_span(entry));
+ if (weight > asym_capacity_max_cpus)
+ asym_capacity_max_cpus = weight;
}
}
--
2.53.0