]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched_ext: idle: small CPU iteration refactoring
authorAndrea Righi <arighi@nvidia.com>
Sat, 4 Jan 2025 09:00:09 +0000 (10:00 +0100)
committerTejun Heo <tj@kernel.org>
Mon, 6 Jan 2025 18:48:38 +0000 (08:48 -1000)
Replace the loop to check if all SMT CPUs are idle with
cpumask_subset(). This simplifies the code and slightly improves
efficiency, while preserving the original behavior.

Note that idle_masks.smt handling remains racy, which is acceptable as
it serves as an optimization and is self-correcting.

Suggested-and-reviewed-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c

index 926579624c41da98d8205a223e6eb667410a6db5..0ce116e0f67cd6a2a171dff9203e9d42b411cbb3 100644 (file)
@@ -3671,10 +3671,8 @@ void __scx_update_idle(struct rq *rq, bool idle)
                         * idle_masks.smt handling is racy but that's fine as
                         * it's only for optimization and self-correcting.
                         */
-                       for_each_cpu(cpu, smt) {
-                               if (!cpumask_test_cpu(cpu, idle_masks.cpu))
-                                       return;
-                       }
+                       if (!cpumask_subset(smt, idle_masks.cpu))
+                               return;
                        cpumask_or(idle_masks.smt, idle_masks.smt, smt);
                } else {
                        cpumask_andnot(idle_masks.smt, idle_masks.smt, smt);