Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/fair: Simplify SIS_UTIL handling in select_idle_cpu()

Use the "sd_llc" passed to select_idle_cpu() to obtain the
"sd_llc_shared" instead of dereferencing the per-CPU variable.

Since "sd->shared" is always reclaimed at the same time as "sd" via
call_rcu() and update_top_cache_domain() always ensures a valid
"sd->shared" assignment when "sd_llc" is present, "sd_llc->shared" can
always be dereferenced without needing an additional check.

While at it move the cpumask_and() operation after the SIS_UTIL bailout
check to avoid unnecessarily computing the cpumask.

Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Chen Yu <yu.c.chen@intel.com>
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Link: https://patch.msgid.link/20260312044434.1974-10-kprateek.nayak@amd.com

authored by

K Prateek Nayak and committed by
Peter Zijlstra
fe7171d0 f1320a8d

+16 -11
+16 -11
kernel/sched/fair.c
··· 7876 7876 { 7877 7877 struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_rq_mask); 7878 7878 int i, cpu, idle_cpu = -1, nr = INT_MAX; 7879 - struct sched_domain_shared *sd_share; 7880 - 7881 - cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr); 7882 7879 7883 7880 if (sched_feat(SIS_UTIL)) { 7884 - sd_share = rcu_dereference_all(per_cpu(sd_llc_shared, target)); 7885 - if (sd_share) { 7886 - /* because !--nr is the condition to stop scan */ 7887 - nr = READ_ONCE(sd_share->nr_idle_scan) + 1; 7888 - /* overloaded LLC is unlikely to have idle cpu/core */ 7889 - if (nr == 1) 7890 - return -1; 7891 - } 7881 + /* 7882 + * Increment because !--nr is the condition to stop scan. 7883 + * 7884 + * Since "sd" is "sd_llc" for target CPU dereferenced in the 7885 + * caller, it is safe to directly dereference "sd->shared". 7886 + * Topology bits always ensure it assigned for "sd_llc" abd it 7887 + * cannot disappear as long as we have a RCU protected 7888 + * reference to one the associated "sd" here. 7889 + */ 7890 + nr = READ_ONCE(sd->shared->nr_idle_scan) + 1; 7891 + /* overloaded LLC is unlikely to have idle cpu/core */ 7892 + if (nr == 1) 7893 + return -1; 7892 7894 } 7895 + 7896 + if (!cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr)) 7897 + return -1; 7893 7898 7894 7899 if (static_branch_unlikely(&sched_cluster_active)) { 7895 7900 struct sched_group *sg = sd->groups;