* [PATCH v2 sched_ext/for-7.1-fixes] sched_ext: Drop %NONE early return in scx_disable_and_exit_task()
@ 2026-05-12 21:11 Tejun Heo
2026-05-12 21:18 ` [PATCH v2 sched_ext/for-7.1-fixes] sched_ext: Drop NONE " Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Tejun Heo @ 2026-05-12 21:11 UTC (permalink / raw)
To: void, arighi, changwoo; +Cc: sched-ext, emil, linux-kernel, Tejun Heo
d3e73a0808dd ("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: d3e73a0808dd ("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>
---
kernel/sched/ext.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 9354da79e162..68120f679178 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3703,22 +3703,14 @@ static void scx_sub_init_cancel_task(struct scx_sched *sch, struct task_struct *
static void scx_disable_and_exit_task(struct scx_sched *sch,
struct task_struct *p)
{
- /*
- * %NONE means @p is already detached at the SCX level (e.g. handed
- * back to the parent by scx_fail_parent() with no init to undo).
- * Skip to avoid clobbering scx_task_sched() and writing %NONE again
- * on a state that's already %NONE.
- */
- if (scx_get_task_state(p) == SCX_TASK_NONE)
- return;
-
__scx_disable_and_exit_task(sch, p);
/*
* If set, @p exited between __scx_init_task() and scx_enable_task() in
* scx_sub_enable() and is initialized for both the associated sched and
* its parent. Exit for the child too - scx_enable_task() never ran for
- * it, so undo only init_task.
+ * it, so undo only init_task. The flag is only set on the sub-enable
+ * path, so it's always clear when @p arrives here in %SCX_TASK_NONE.
*/
if (p->scx.flags & SCX_TASK_SUB_INIT) {
if (!WARN_ON_ONCE(!scx_enabling_sub_sched))
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-12 21:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 21:11 [PATCH v2 sched_ext/for-7.1-fixes] sched_ext: Drop %NONE early return in scx_disable_and_exit_task() Tejun Heo
2026-05-12 21:18 ` [PATCH v2 sched_ext/for-7.1-fixes] sched_ext: Drop NONE " Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox