The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v3] sched_ext: Don't warn on core-sched forced idle in put_prev_task_scx()
@ 2026-06-29 22:55 Tejun Heo
  2026-06-30  4:40 ` Andrea Righi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tejun Heo @ 2026-06-29 22:55 UTC (permalink / raw)
  To: David Vernet, Andrea Righi, Changwoo Min, sched-ext
  Cc: Tejun Heo, Emil Tsalapatis, linux-kernel, Kuba Piecuch

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.

v3: Gate the warning on sched_cpu_cookie_match() so it is suppressed only on
    the forced-idle CPU instead of whenever core scheduling is enabled, so a
    genuine missing-ENQ_LAST drop is still caught (Andrea Righi).
v2: Reworded the description (Kuba Piecuch).

Fixes: 7c65ae81ea86 ("sched_ext: Don't call put_prev_task_scx() before picking the next task")
Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/sched/ext/ext.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 3b2e13bc924b..e75e2fd5ab7e 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -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);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] sched_ext: Don't warn on core-sched forced idle in put_prev_task_scx()
  2026-06-29 22:55 [PATCH v3] sched_ext: Don't warn on core-sched forced idle in put_prev_task_scx() Tejun Heo
@ 2026-06-30  4:40 ` Andrea Righi
  2026-06-30  9:54 ` Aiqun(Maria) Yu
  2026-06-30 14:24 ` Tejun Heo
  2 siblings, 0 replies; 4+ messages in thread
From: Andrea Righi @ 2026-06-30  4:40 UTC (permalink / raw)
  To: Tejun Heo
  Cc: David Vernet, Changwoo Min, sched-ext, Emil Tsalapatis,
	linux-kernel, Kuba Piecuch

On Mon, Jun 29, 2026 at 12:55:48PM -1000, Tejun Heo wrote:
> 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.
> 
> v3: Gate the warning on sched_cpu_cookie_match() so it is suppressed only on
>     the forced-idle CPU instead of whenever core scheduling is enabled, so a
>     genuine missing-ENQ_LAST drop is still caught (Andrea Righi).
> v2: Reworded the description (Kuba Piecuch).
> 
> Fixes: 7c65ae81ea86 ("sched_ext: Don't call put_prev_task_scx() before picking the next task")
> Signed-off-by: Tejun Heo <tj@kernel.org>

Looks good.

Reviewed-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

> ---
>  kernel/sched/ext/ext.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index 3b2e13bc924b..e75e2fd5ab7e 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -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);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] sched_ext: Don't warn on core-sched forced idle in put_prev_task_scx()
  2026-06-29 22:55 [PATCH v3] sched_ext: Don't warn on core-sched forced idle in put_prev_task_scx() Tejun Heo
  2026-06-30  4:40 ` Andrea Righi
@ 2026-06-30  9:54 ` Aiqun(Maria) Yu
  2026-06-30 14:24 ` Tejun Heo
  2 siblings, 0 replies; 4+ messages in thread
From: Aiqun(Maria) Yu @ 2026-06-30  9:54 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Andrea Righi, Changwoo Min, sched-ext
  Cc: Emil Tsalapatis, linux-kernel, Kuba Piecuch

On 6/30/2026 6:55 AM, Tejun Heo wrote:
> 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.
> 
> v3: Gate the warning on sched_cpu_cookie_match() so it is suppressed only on
>     the forced-idle CPU instead of whenever core scheduling is enabled, so a
>     genuine missing-ENQ_LAST drop is still caught (Andrea Righi).
> v2: Reworded the description (Kuba Piecuch).


The version change log information don't need to be present here.
Usually those kind of information will be present under --- and don't
need to be added in the real commit message.

> 
> Fixes: 7c65ae81ea86 ("sched_ext: Don't call put_prev_task_scx() before picking the next task")
> Signed-off-by: Tejun Heo <tj@kernel.org>
> ---
>  kernel/sched/ext/ext.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index 3b2e13bc924b..e75e2fd5ab7e 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -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);
> 


-- 
Thx and BRs,
Aiqun(Maria) Yu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] sched_ext: Don't warn on core-sched forced idle in put_prev_task_scx()
  2026-06-29 22:55 [PATCH v3] sched_ext: Don't warn on core-sched forced idle in put_prev_task_scx() Tejun Heo
  2026-06-30  4:40 ` Andrea Righi
  2026-06-30  9:54 ` Aiqun(Maria) Yu
@ 2026-06-30 14:24 ` Tejun Heo
  2 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2026-06-30 14:24 UTC (permalink / raw)
  To: David Vernet, Andrea Righi, Changwoo Min, sched-ext
  Cc: Emil Tsalapatis, linux-kernel, Kuba Piecuch, Aiqun(Maria) Yu

Applied to sched_ext/for-7.2-fixes.

Thanks.
--
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-30 14:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 22:55 [PATCH v3] sched_ext: Don't warn on core-sched forced idle in put_prev_task_scx() Tejun Heo
2026-06-30  4:40 ` Andrea Righi
2026-06-30  9:54 ` Aiqun(Maria) Yu
2026-06-30 14:24 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox