scx_fail_parent() leaves cgroup tasks at (state=NONE, sched=parent, sched_class=ext) until the parent itself is torn down by the scx_error() it raised. When the later root_disable iterates them, two paths trip on NONE. scx_disable_and_exit_task() re-enters the wrapper at NONE: the inner switch returns early but the trailing scx_set_task_sched(p, NULL) clobbers the parent sched left by scx_fail_parent(), and scx_set_task_state(p, NONE) wastes a write on an already-NONE task. switched_from_scx() then calls scx_disable_task(), which WARNs on non-ENABLED state and writes state=READY, producing a NONE -> READY transition the validation matrix rejects. Treat NONE as "nothing to do" in both paths. Add a NONE early-return at the top of scx_disable_and_exit_task() and a parallel NONE check in switched_from_scx() next to task_dead_and_done().
Unified · Split
| @@ -3703,6 +3703,15 @@ static void scx_sub_init_cancel_task(struct scx_sched *sch, struct task_struct * · 3702 unmodified lines | ||
| 3703 | 3703 | static void scx_disable_and_exit_task(struct scx_sched *sch, |
| 3704 | 3704 | struct task_struct *p) |
| 3705 | 3705 | { |
| 3706 | + /* | |
| 3707 | + * %NONE means @p is already detached at the SCX level (e.g. handed | |
| 3708 | + * back to the parent by scx_fail_parent() with no init to undo). | |
| 3709 | + * Skip to avoid clobbering scx_task_sched() and writing %NONE again | |
| 3710 | + * on a state that's already %NONE. | |
| 3711 | + */ | |
| 3712 | + if (scx_get_task_state(p) == SCX_TASK_NONE) | |
| 3713 | + return; | |
| 3714 | + | |
| 3706 | 3715 | __scx_disable_and_exit_task(sch, p); |
| 3707 | 3716 | |
| 3708 | 3717 | /* |
| @@ -3921,6 +3930,16 @@ static void switched_from_scx(struct rq *rq, struct task_struct *p) · 212 unmodified lines | ||
| 3921 | 3930 | if (task_dead_and_done(p)) |
| 3922 | 3931 | return; |
| 3923 | 3932 | |
| 3933 | + /* | |
| 3934 | + * %NONE means SCX is no longer tracking @p at the task level (e.g. | |
| 3935 | + * scx_fail_parent() handed @p back to the parent at NONE pending the | |
| 3936 | + * parent's own teardown). There is nothing to disable; calling | |
| 3937 | + * scx_disable_task() would WARN on the non-%ENABLED state and trigger a | |
| 3938 | + * NONE -> READY validation failure. | |
| 3939 | + */ | |
| 3940 | + if (scx_get_task_state(p) == SCX_TASK_NONE) | |
| 3941 | + return; | |
| 3942 | + | |
| 3924 | 3943 | scx_disable_task(scx_task_sched(p), p); |
| 3925 | 3944 | } |
| 3926 | 3945 | |