Skip to content

Commit 39e25a2

Browse files
committed
sched_ext: Drop NONE early return in scx_disable_and_exit_task()
d3e73a0 ("sched_ext: Handle SCX_TASK_NONE in disable/switched_from paths") skipped the trailing scx_set_task_sched(p, NULL) on NONE tasks. After scx_fail_parent() parks a task at NONE/sched=parent and the parent is later freed via queue_rcu_work() during root_disable, the preserved p->scx.sched dangles - print_scx_info() from sched_show_task() reads sch->ops.name from freed memory. Drop the early return. __scx_disable_and_exit_task() already short- circuits on NONE and the SUB_INIT block was cleared by scx_fail_parent()'s earlier call, so clearing p->scx.sched is the only work left - and the one thing the path actually needs. v2: Extend the SUB_INIT block comment to note that the flag is only set on the sub-enable path, so it's always clear on the NONE re-entry (Andrea). Fixes: d3e73a0 ("sched_ext: Handle SCX_TASK_NONE in disable/switched_from paths") Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Andrea Righi <arighi@nvidia.com>
1 parent 9a415cc commit 39e25a2

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

kernel/sched/ext.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,22 +3703,14 @@ static void scx_sub_init_cancel_task(struct scx_sched *sch, struct task_struct *
37033703
static void scx_disable_and_exit_task(struct scx_sched *sch,
37043704
struct task_struct *p)
37053705
{
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-
37153706
__scx_disable_and_exit_task(sch, p);
37163707

37173708
/*
37183709
* If set, @p exited between __scx_init_task() and scx_enable_task() in
37193710
* scx_sub_enable() and is initialized for both the associated sched and
37203711
* its parent. Exit for the child too - scx_enable_task() never ran for
3721-
* it, so undo only init_task.
3712+
* it, so undo only init_task. The flag is only set on the sub-enable
3713+
* path, so it's always clear when @p arrives here in %SCX_TASK_NONE.
37223714
*/
37233715
if (p->scx.flags & SCX_TASK_SUB_INIT) {
37243716
if (!WARN_ON_ONCE(!scx_enabling_sub_sched))

0 commit comments

Comments
 (0)