Commit b905ee77 authored by Samuele Mariotti's avatar Samuele Mariotti Committed by Tejun Heo
Browse files

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: default avatarSamuele Mariotti <smariotti@disroot.org>
Signed-off-by: default avatarPaolo Valente <paolo.valente@unimore.it>
Reviewed-by: default avatarAndrea Righi <arighi@nvidia.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 94555ca6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
	}