summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAndrea Righi <arighi@nvidia.com>2026-08-03 08:08:12 +0200
committerTejun Heo <tj@kernel.org>2026-08-03 06:20:51 -1000
commitba190ed3f47f0e177e4be525d4a6330bd2fbd1f1 (patch)
tree0f0d0ef2c9541082ec4ce4a5896ac2b4593f77a7 /kernel
parentc5b9316cf3d5371d53022352c7c9d248e14b801f (diff)
sched_ext: Initialize idle masks as busy
The built-in idle masks are reset with all online CPUs marked idle before sched_ext is enabled. Busy CPUs can therefore be incorrectly advertised as idle until their next idle transition. Initialize the masks empty so that the initial state is conservative. When bypass is lifted, every CPU is rescheduled and idle-to-idle re-picks populate the masks with CPUs that are actually idle. Later idle transitions keep the masks up to date. Suggested-by: Tejun Heo <tj@kernel.org> Signed-off-by: Andrea Righi <arighi@nvidia.com> Reviewed-by: Kuba Piecuch <jpiecuch@google.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched/ext/idle.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/kernel/sched/ext/idle.c b/kernel/sched/ext/idle.c
index 3e9d6a44bf43..33bd51ab3ced 100644
--- a/kernel/sched/ext/idle.c
+++ b/kernel/sched/ext/idle.c
@@ -838,20 +838,20 @@ static void reset_idle_masks(struct sched_ext_ops *ops)
int node;
/*
- * Consider all online cpus idle. Should converge to the actual state
- * quickly.
+ * Start with all CPUs marked busy. The idle masks are populated when
+ * bypass is lifted and each idle CPU is forced through an idle re-pick.
+ * This may temporarily omit idle CPUs but never advertises a busy CPU as
+ * idle.
*/
if (!(ops->flags & SCX_OPS_BUILTIN_IDLE_PER_NODE)) {
- cpumask_copy(idle_cpumask(NUMA_NO_NODE)->cpu, cpu_online_mask);
- cpumask_copy(idle_cpumask(NUMA_NO_NODE)->smt, cpu_online_mask);
+ cpumask_clear(idle_cpumask(NUMA_NO_NODE)->cpu);
+ cpumask_clear(idle_cpumask(NUMA_NO_NODE)->smt);
return;
}
for_each_node(node) {
- const struct cpumask *node_mask = cpumask_of_node(node);
-
- cpumask_and(idle_cpumask(node)->cpu, cpu_online_mask, node_mask);
- cpumask_and(idle_cpumask(node)->smt, cpu_online_mask, node_mask);
+ cpumask_clear(idle_cpumask(node)->cpu);
+ cpumask_clear(idle_cpumask(node)->smt);
}
}