Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched_ext: Unregister sub_kset on scheduler disable

When ops.sub_attach is set, scx_alloc_and_add_sched() creates sub_kset as a
child of &sch->kobj, which pins the parent with its own reference. The
disable paths never call kset_unregister(), so the final kobject_put() in
bpf_scx_unreg() leaves a stale reference and scx_kobj_release() never runs,
leaking the whole struct scx_sched on every load/unload cycle.

Unregister sub_kset in scx_root_disable() and scx_sub_disable() before
kobject_del(&sch->kobj).

Fixes: ebeca1f930ea ("sched_ext: Introduce cgroup sub-sched support")
Reported-by: Chris Mason <clm@meta.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>

+6
+6
kernel/sched/ext.c
··· 5721 5721 5722 5722 if (sch->ops.exit) 5723 5723 SCX_CALL_OP(sch, exit, NULL, sch->exit_info); 5724 + if (sch->sub_kset) 5725 + kset_unregister(sch->sub_kset); 5724 5726 kobject_del(&sch->kobj); 5725 5727 } 5726 5728 #else /* CONFIG_EXT_SUB_SCHED */ ··· 5854 5852 * could observe an object of the same name still in the hierarchy when 5855 5853 * the next scheduler is loaded. 5856 5854 */ 5855 + #ifdef CONFIG_EXT_SUB_SCHED 5856 + if (sch->sub_kset) 5857 + kset_unregister(sch->sub_kset); 5858 + #endif 5857 5859 kobject_del(&sch->kobj); 5858 5860 5859 5861 free_kick_syncs();