diff options
| author | Samuele Mariotti <smariotti@disroot.org> | 2026-04-02 19:00:25 +0200 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2026-04-02 09:22:03 -1000 |
| commit | b905ee77d5f557a83a485b4146210f54f13365fc (patch) | |
| tree | bc388af7e009f0eb76c4c65a54917d68eb926808 /kernel/sched | |
| parent | 94555ca6d0bb41a7cb3c12ad2a7cacb6fdbdca0b (diff) | |
sched_ext: Fix missing warning in scx_set_task_state() default case
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>
Reviewed-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.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index 9628c64e5592..0253887e63c0 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -3538,7 +3538,8 @@ static void scx_set_task_state(struct task_struct *p, u32 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; } |
