scx_cgroup_return_subtree(9)
π scx_cgroup_return_subtree(9) β a Kernel API Manual moment
okay so bestie, we're deep in scx_cgroup_return_subtree(9) territory, which lives in the Kernel API Manual and is genuinely one of those "glue" functions that keeps the whole sub-scheduler teardown from falling apart. stay with me, it's giving backstage-crew energy and honestly? iconic. π
β¨ NAME β¨
scx_cgroup_return_subtree β hand the subtree's cgroups back to the parent sched. that's the whole gig. no cap. π«Ά
πΈ SYNOPSIS πΈ
void scx_cgroup_return_subtree (struct scx_sched *sch );
π¦ ARGUMENTS π¦
schβ the sub-scheduler that's being disabled rn. it's the one on its way out, and we're politely returning its stuff. π
π DESCRIPTION π
so this gets called while we're disabling sch β but like, at a very specific moment: after the subtree's cgrp->scx_sched's have been reset to the parent sched, and before tasks get re-homed. why that order? because it mirrors root disable's teardown order, which is cgroups-before-tasks. periodt. it's the literal reverse of scx_cgroup_claim_subtree: we exit sch's cgroups from sch, then init them on the parent using the current tg->scx.* values β which means we resync any settings that changed while sch was holding them. slay. β¨
now the spicy part π β when an init on the parent fails, the parent is failed. that's the same policy we use for task re-homing, so no surprises there. the remaining task_groups get punted: they move to the parent anyway, but with SCX_TG_INITED cleared, since ops.cgroup_init failed or literally never ran for them. and a punted task_group gets no cgroup ops. none. zero. π
so what happens to the dying parent? its own disable moves it one sched up, and it gets inited there. and root ends the whole chain: root teardown drops cgroup ops entirely, and the next enable's bulk init re-inits every online task_group. the circle of life, honestly. π
heads up bestie β the task re-home that follows still deliversops.init_taskto the dying parent, including for tasks sitting in punted cgroups it never inited. that's tolerated, exactly like the downstream failures of task punting (go peek atscx_punt_task). it's not a bug, it's the vibe. π
π SEE ALSO π
- the kernel file itself:
./kernel/sched/ext/sub.c scx_skip_subtree_pre(9)scx_next_descendant_pre(9)scx_rescue_charge(9)scx_rescue_end(9)scx_rescue_keep(9)scx_rescue_accrue(9)scx_rescue_admit(9)scx_rescue_try_admit(9)scx_rescue_check_overload(9)scx_rescue_timerfn(9)scx_resolve_local_dsq(9)queue_sync_ecaps(9)scx_process_sync_ecaps(9)scx_unbypass_replay_ecaps(9)scx_discard_stale_ecaps_syncs(9)scx_rehome_task(9)scx_punt_task(9)scx_cgroup_claim_subtree(9)scx_cgroup_task_migrating(9)scx_cgroup_task_migrated(9)scx_cgroup_task_migrate_canceled(9)scx_bpf_sub_dispatch(9)scx_bpf_sub_grant(9)scx_bpf_sub_revoke(9)scx_bpf_sub_caps(9)scx_bpf_sub_kill_bstr(9)
and that's the whole page, bestie π this one ships out of ./kernel/sched/ext and it's dated October 2026 β go off, calendar. mwah. ππ§π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms