Re: [PATCH] sched/topology: Balance cluster static-key updates
From: K Prateek Nayak
Date: Tue Oct 20 2026 - 23:56:54 EST
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@xxxxxxx>
> +
> + if (has_cluster)
> static_branch_dec_cpuslocked(&sched_cluster_active);
>
> rcu_read_lock();
--
Thanks and Regards,
Prateek