]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched/fair: Drop useless cpumask_empty() in find_energy_efficient_cpu()
authorYury Norov (NVIDIA) <yury.norov@gmail.com>
Sun, 7 Dec 2025 04:05:42 +0000 (23:05 -0500)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 8 Jan 2026 11:43:56 +0000 (12:43 +0100)
cpumask_empty() call is O(N) and useless because the previous
cpumask_and() returns false for empty 'cpus'. Drop it.

Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://patch.msgid.link/20251207040543.407695-1-yury.norov@gmail.com
kernel/sched/fair.c

index 7377f91175010b4ed3afcbc82b365aaa1242de96..64275d75a964d9071bfb18adfadd9a4a83063cec 100644 (file)
@@ -8359,9 +8359,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
                int max_spare_cap_cpu = -1;
                int fits, max_fits = -1;
 
-               cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask);
-
-               if (cpumask_empty(cpus))
+               if (!cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask))
                        continue;
 
                /* Account external pressure for the energy estimation */