Skip to content

Commit d9071ec

Browse files
arighihtejun
authored andcommitted
sched_ext: idle: small CPU iteration refactoring
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>
1 parent c0cf353 commit d9071ec

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

kernel/sched/ext.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,10 +3671,8 @@ void __scx_update_idle(struct rq *rq, bool idle)
36713671
* idle_masks.smt handling is racy but that's fine as
36723672
* it's only for optimization and self-correcting.
36733673
*/
3674-
for_each_cpu(cpu, smt) {
3675-
if (!cpumask_test_cpu(cpu, idle_masks.cpu))
3676-
return;
3677-
}
3674+
if (!cpumask_subset(smt, idle_masks.cpu))
3675+
return;
36783676
cpumask_or(idle_masks.smt, idle_masks.smt, smt);
36793677
} else {
36803678
cpumask_andnot(idle_masks.smt, idle_masks.smt, smt);

0 commit comments

Comments
 (0)