public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BUGFIX] sched_ext: Fix missing warning in scx_set_task_state() default case
@ 2026-04-02 17:00 Samuele Mariotti
  2026-04-02 19:23 ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: Samuele Mariotti @ 2026-04-02 17:00 UTC (permalink / raw)
  To: arighi, tj, void, changwoo
  Cc: sched-ext, linux-kernel, Samuele Mariotti, Paolo Valente

In scx_set_task_state(), the default case was setting the
warn flag, but then returning immediately. This is problematic
because the only purpose of the warn flag is to trigger
WARN_ONCE, but the early return prevented it from ever firing,
leaving invalid task states undetected and untraced.

To fix this, a WARN_ONCE call is now added directly in the
default case.

The fix addresses two aspects:

 - Guarantees the invalid task states are properly logged
   and traced.

 - Provides a distinct warning message
   ("sched_ext: Invalid task state") specifically for
   states outside the defined scx_task_state enum values,
   making it easier to distinguish from other transition
   warnings.

This ensures proper detection and reporting of invalid states.

Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")

Signed-off-by: Samuele Mariotti <smariotti@disroot.org>
Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
---
 kernel/sched/ext.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 1594987d637b..10683ce4e415 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -2863,7 +2863,8 @@ static void scx_set_task_state(struct task_struct *p, enum scx_task_state state)
 		warn = prev_state != SCX_TASK_READY;
 		break;
 	default:
-		warn = true;
+		WARN_ONCE(1, "sched_ext: Invalid task state %d -> %d for %s[%d]",
+			  prev_state, state, p->comm, p->pid);
 		return;
 	}
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH BUGFIX] sched_ext: Fix missing warning in scx_set_task_state() default case
@ 2026-04-02 11:23 Samuele Mariotti
  0 siblings, 0 replies; 3+ messages in thread
From: Samuele Mariotti @ 2026-04-02 11:23 UTC (permalink / raw)
  To: arighi, tj, void, changwoo
  Cc: sched-ext, linux-kernel, Samuele Mariotti, Paolo Valente

In scx_set_task_state(), the default case was setting the
warn flag, but then returning immediately. This is problematic
because the only purpose of the warn flag is to trigger
WARN_ONCE, but the early return prevented it from ever firing,
leaving invalid task states undetected and untraced.

To fix this, a WARN_ONCE call is now added directly in the
default case.

The fix addresses two aspects:

 - Guarantees the invalid task states are properly logged
   and traced.

 - Provides a distinct warning message
   ("sched_ext: Invalid task state") specifically for
   states outside the defined scx_task_state enum values,
   making it easier to distinguish from other transition
   warnings.

This ensures proper detection and reporting of invalid states.

Signed-off-by: Samuele Mariotti <smariotti@disroot.org>
Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
---
 kernel/sched/ext.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 1594987d637b..10683ce4e415 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -2863,7 +2863,8 @@ static void scx_set_task_state(struct task_struct *p, enum scx_task_state state)
 		warn = prev_state != SCX_TASK_READY;
 		break;
 	default:
-		warn = true;
+		WARN_ONCE(1, "sched_ext: Invalid task state %d -> %d for %s[%d]",
+			  prev_state, state, p->comm, p->pid);
 		return;
 	}
 
-- 
2.47.3


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

end of thread, other threads:[~2026-04-02 19:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 17:00 [PATCH BUGFIX] sched_ext: Fix missing warning in scx_set_task_state() default case Samuele Mariotti
2026-04-02 19:23 ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2026-04-02 11:23 Samuele Mariotti

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