Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Samuele Mariotti and committed by
Tejun Heo
b905ee77 94555ca6

+2 -1
+2 -1
kernel/sched/ext.c
··· 3538 3538 warn = prev_state != SCX_TASK_READY; 3539 3539 break; 3540 3540 default: 3541 - warn = true; 3541 + WARN_ONCE(1, "sched_ext: Invalid task state %d -> %d for %s[%d]", 3542 + prev_state, state, p->comm, p->pid); 3542 3543 return; 3543 3544 } 3544 3545