]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Don't warn on core-sched forced idle in put_prev_task_scx()
authorTejun Heo <tj@kernel.org>
Mon, 29 Jun 2026 22:55:48 +0000 (12:55 -1000)
committerTejun Heo <tj@kernel.org>
Tue, 30 Jun 2026 14:08:18 +0000 (04:08 -1000)
put_prev_task_scx() warns when a runnable task drops to a lower sched_class
without SCX_OPS_ENQ_LAST, on the assumption that balance_one() would have
kept it running. Core scheduling breaks that: a forced-idle SMT sibling
reschedules through the core_pick fast path in pick_next_task(), which skips
pick_task_scx() and thus balance_one(), so a runnable task can drop to idle
with ENQ_LAST unset.

Gate the warning on sched_cpu_cookie_match(): a cookie mismatch means core
scheduling forced the idle, while a match (or core scheduling off) still
catches a genuine missing-ENQ_LAST drop.

Fixes: 7c65ae81ea86 ("sched_ext: Don't call put_prev_task_scx() before picking the next task")
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
kernel/sched/ext/ext.c

index 3b2e13bc924bcce1c17cb71bd639d07a448f55a7..e75e2fd5ab7e33cfbea9504a32e2081aea952ff6 100644 (file)
@@ -3090,9 +3090,14 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
                 * sched_class, %SCX_OPS_ENQ_LAST must be set. Tell
                 * ops.enqueue() that @p is the only one available for this cpu,
                 * which should trigger an explicit follow-up scheduling event.
+                *
+                * Core scheduling can force this CPU idle while @p stays
+                * runnable. @p's cookie then won't match the core's, so skip
+                * the warning in that case.
                 */
                if (next && sched_class_above(&ext_sched_class, next->sched_class)) {
-                       WARN_ON_ONCE(!(sch->ops.flags & SCX_OPS_ENQ_LAST));
+                       WARN_ON_ONCE(sched_cpu_cookie_match(rq, p) &&
+                                    !(sch->ops.flags & SCX_OPS_ENQ_LAST));
                        do_enqueue_task(rq, p, SCX_ENQ_LAST, -1);
                } else {
                        do_enqueue_task(rq, p, 0, -1);