linux/Documentation/scheduler/sched-design-CFS.rst
Imported from
_research/manual-study-linux/file-notes/linux__Documentation__scheduler__sched-design-CFS.rst.md.
File Notes: Documentation/scheduler/sched-design-CFS.rst
Status: reviewed.
Purpose
Documents the CFS model, its virtual-runtime accounting, RB-tree runqueue, and the scheduler-class abstraction that lets the core delegate policy.
Key Points
CFS models an ideal multitasking CPU by tracking each task’s p->se.vruntime.
On real hardware only one task runs at a time, so virtual runtime records how
much CPU service a task has received relative to its fair share. The old CFS
pick rule was the leftmost entity in a time-ordered RB tree: the task with the
smallest virtual runtime.
The document also explains scheduling classes. sched/fair.c implements CFS
and EEVDF-era fair scheduling, sched/rt.c implements FIFO/RR, and the core
calls class hooks for enqueue, dequeue, wakeup preemption, picking, setting the
next task, and ticks.
Rust Translation Guidance
Treat virtual time as an explicit accounting domain. A Rust scheduler should not hide fairness accounting inside timers; it should have scheduling entities with service accounting, queue membership, and policy hooks.
AI-Native Systems Guidance
Agent scheduling should expose a similar class model. Normal jobs can be fair jobs, batch jobs can use longer slices, and latency-sensitive jobs can request more responsive behavior through policy rather than unbounded priority.
Evidence
- CFS models an ideal multitasking CPU and introduces virtual runtime at
Documentation/scheduler/sched-design-CFS.rst:18-30. p->se.vruntimeis the tracked value, and old CFS picked the smallest virtual runtime atDocumentation/scheduler/sched-design-CFS.rst:37-49.- CFS uses an RB tree and tracks
min_vruntimeand load atDocumentation/scheduler/sched-design-CFS.rst:57-80. - The scheduler-class abstraction and hook list are documented at
Documentation/scheduler/sched-design-CFS.rst:151-207.