sched_ext: Arm the exit on the sub-scheduler enable error path
Subsystems (2)
PATCH 1/1 sched_ext: Arm the exit on the sub-scheduler enable error path
When enabling a sub-scheduler fails, scx_sub_enable_workfn() jumps to err_disable and calls scx_flush_disable_work() to unwind. That flush only does something once the exit has been armed, which happens via scx_error()/scx_exit(). Several error paths reach err_disable without arming it - most commonly ops.init_task() rejecting a task with a valid errno, and the -ENOMEM cases from the arena and cmask scratch allocations.
On those paths teardown never runs: the half-enabled scheduler stays linked in its parent, ops.exit() is never called, it is left stuck in bypass with the cgroup subtree still pointing at it, and cmd->ret == 0 reports the attach as successful. It only gets cleaned up later when the struct_ops map is detached.
The root enable path already arms the exit before flushing; do the same here. scx_claim_exit() makes it harmless for paths that already errored.
--- kernel/sched/ext/sub.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
kernel/sched/ext/sub.c +11 -0
@@ -570,6 +570,17 @@ void scx_sub_enable_workfn(struct kthread_work *work)percpu_up_write (&scx_fork_rwsem); err_disable:mutex_unlock (&scx_enable_mutex); +/* +* Several error edges reach here without having called scx_error() +* (e.g. ops.init_task() returning a valid errno, or -ENOMEM from the +* arena/cmask scratch allocation), leaving exit_kind == SCX_EXIT_NONE. +* Arm the exit so the disable work is queued; otherwise +* scx_flush_disable_work() is a no-op and the half-enabled +* sub-scheduler is left linked and reported as a successful attach. +* Mirrors scx_root_enable_workfn(); scx_claim_exit() makes this +* idempotent for paths that already errored. +*/ +scx_error (sch,"scx_sub_enable() failed (%d)" , ret);scx_flush_disable_work (sch); cmd->ret =0 ; }
Signature · 1 line
2.53.0
Tejun Heo
reviewerHello, David.
Thanks, the diagnosis is correct. This is already fixed in the pending sub-scheduler capability series - the same scx_error() arming at err_disable is folded into:
[PATCH v2 sched_ext/for-7.3 19/36] sched_ext: Add per-shard cap delegation for sub-schedulers
https://lore.kernel.org/r/[email protected]
Thanks.
--
tejun