]> git.ipfire.org Git - thirdparty/linux.git/commit
sched_ext: Short-circuit sched_class operations on dead tasks
authorTejun Heo <tj@kernel.org>
Wed, 4 Feb 2026 20:07:55 +0000 (10:07 -1000)
committerTejun Heo <tj@kernel.org>
Wed, 4 Feb 2026 22:22:11 +0000 (12:22 -1000)
commit0eca95cba2b7bf7b7b4f2fa90734a85fcaa72782
tree737d3de2746ccc49a270fccfb2826bafffb4a153
parentc9894e6f0160414b57e895332c580cf5c8da6780
sched_ext: Short-circuit sched_class operations on dead tasks

7900aa699c34 ("sched_ext: Fix cgroup exit ordering by moving sched_ext_free()
to finish_task_switch()") moved sched_ext_free() to finish_task_switch() and
renamed it to sched_ext_dead() to fix cgroup exit ordering issues. However,
this created a race window where certain sched_class ops may be invoked on
dead tasks leading to failures - e.g. sched_setscheduler() may try to switch a
task which finished sched_ext_dead() back into SCX triggering invalid SCX task
state transitions.

Add task_dead_and_done() which tests whether a task is TASK_DEAD and has
completed its final context switch, and use it to short-circuit sched_class
operations which may be called on dead tasks.

Fixes: 7900aa699c34 ("sched_ext: Fix cgroup exit ordering by moving sched_ext_free() to finish_task_switch()")
Reported-by: Andrea Righi <arighi@nvidia.com>
Link: http://lkml.kernel.org/r/20260202151341.796959-1-arighi@nvidia.com
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c