summaryrefslogtreecommitdiffstats
path: root/kernel/sched
diff options
context:
space:
mode:
authorAndrea Righi <arighi@nvidia.com>2025-01-04 10:00:09 +0100
committerTejun Heo <tj@kernel.org>2025-01-06 08:48:38 -1000
commitd9071ecb313940fe1d8827fef48bbf9fdaf28a4c (patch)
tree7f36ed983fe31c70978b80a7c988d00572664bde /kernel/sched
parentc0cf3530098bc13578bd4d0692351a2c4a57425d (diff)
downloadlinux-stable-d9071ecb313940fe1d8827fef48bbf9fdaf28a4c.tar.gz
linux-stable-d9071ecb313940fe1d8827fef48bbf9fdaf28a4c.tar.bz2
linux-stable-d9071ecb313940fe1d8827fef48bbf9fdaf28a4c.zip
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>
Diffstat (limited to 'kernel/sched')
-rw-r--r--kernel/sched/ext.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 926579624c41..0ce116e0f67c 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -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);