scx_cgroup_return_subtree(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 delivers ops.init_task to 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 at scx_punt_task). it's not a bug, it's the vibe. πŸ’…

πŸŽ€ SEE ALSO πŸŽ€


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