* [PATCH] sched/topology: Balance cluster static-key updates
@ 2026-10-21 3:43 Hui Su
2026-10-21 3:55 ` K Prateek Nayak
0 siblings, 1 reply; 3+ messages in thread
From: Hui Su @ 2026-10-21 3:43 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, K Prateek Nayak, Barry Song, Tim Chen,
Chen Yu, Yicong Yang, linux-kernel, Hui Su
build_sched_domains() increments sched_cluster_active once per newly
built partition that contains an SD_CLUSTER domain.
detach_destroy_domains() instead tested the global static key before
decrementing it, so destroying a cluster-less partition could drop a
reference owned by another partition and disable cluster-aware
scheduling while SD_CLUSTER domains remained installed.
Check the installed domains before detaching them and decrement only
when the removed partition contains an SD_CLUSTER domain.
With two cluster-bearing partitions installed, removing a singleton
partition left the baseline count at 1 where 2 partitions still
carried SD_CLUSTER; the fixed kernel correctly reports 2. On an
asymmetric cluster topology where the parent partition gains no
cluster domain, the baseline count drops to 0 while a cluster
partition remains installed; the fixed kernel keeps it at 1.
Fixes: 8881e1639f1f ("sched/fair: Scan cluster before scanning LLC in wake-up path")
Signed-off-by: Hui Su <sh_def@163.com>
---
kernel/sched/topology.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 3dab0253976fb..c9e10bfade6d0 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -3314,12 +3314,22 @@ int __init sched_init_domains(const struct cpumask *cpu_map)
static void detach_destroy_domains(const struct cpumask *cpu_map)
{
unsigned int cpu = cpumask_any(cpu_map);
+ bool has_cluster = false;
int i;
if (rcu_access_pointer(per_cpu(sd_asym_cpucapacity, cpu)))
static_branch_dec_cpuslocked(&sched_asym_cpucapacity);
- if (static_branch_unlikely(&sched_cluster_active))
+ rcu_read_lock();
+ for_each_cpu(i, cpu_map) {
+ if (lowest_flag_domain(i, SD_CLUSTER)) {
+ has_cluster = true;
+ break;
+ }
+ }
+ rcu_read_unlock();
+
+ if (has_cluster)
static_branch_dec_cpuslocked(&sched_cluster_active);
rcu_read_lock();
--
2.55.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/topology: Balance cluster static-key updates
2026-10-21 3:43 [PATCH] sched/topology: Balance cluster static-key updates Hui Su
@ 2026-10-21 3:55 ` K Prateek Nayak
2026-10-21 4:38 ` Hui Su
0 siblings, 1 reply; 3+ messages in thread
From: K Prateek Nayak @ 2026-10-21 3:55 UTC (permalink / raw)
To: Hui Su, Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, Barry Song, Tim Chen, Chen Yu, Yicong Yang,
linux-kernel
Hello Hui,
On 10/21/2026 9:13 AM, Hui Su wrote:
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 3dab0253976fb..c9e10bfade6d0 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -3314,12 +3314,22 @@ int __init sched_init_domains(const struct cpumask *cpu_map)
> static void detach_destroy_domains(const struct cpumask *cpu_map)
> {
> unsigned int cpu = cpumask_any(cpu_map);
> + bool has_cluster = false;
> int i;
>
> if (rcu_access_pointer(per_cpu(sd_asym_cpucapacity, cpu)))
> static_branch_dec_cpuslocked(&sched_asym_cpucapacity);
>
> - if (static_branch_unlikely(&sched_cluster_active))
> + rcu_read_lock();
> + for_each_cpu(i, cpu_map) {
> + if (lowest_flag_domain(i, SD_CLUSTER)) {
> + has_cluster = true;
> + break;
> + }
> + }
> + rcu_read_unlock();
nit.
This should be done only when sched_cluster_active is enabled to
avoid the extra loop on systems that don't have any cluster domain.
Apart from that, feel free to include:
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
> +
> + if (has_cluster)
> static_branch_dec_cpuslocked(&sched_cluster_active);
>
> rcu_read_lock();
--
Thanks and Regards,
Prateek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/topology: Balance cluster static-key updates
2026-10-21 3:55 ` K Prateek Nayak
@ 2026-10-21 4:38 ` Hui Su
0 siblings, 0 replies; 3+ messages in thread
From: Hui Su @ 2026-10-21 4:38 UTC (permalink / raw)
To: K Prateek Nayak
Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, Barry Song, Tim Chen, Chen Yu, Yicong Yang,
linux-kernel
> nit.
>
> This should be done only when sched_cluster_active is enabled to
> avoid the extra loop on systems that don't have any cluster domain.
Agreed. v2 guards the SD_CLUSTER scan with
static_branch_unlikely(&sched_cluster_active), so systems without cluster
domains skip the loop entirely.
Thanks for the review!
Hui
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-21 4:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21 3:43 [PATCH] sched/topology: Balance cluster static-key updates Hui Su
2026-10-21 3:55 ` K Prateek Nayak
2026-10-21 4:38 ` Hui Su
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®