How galpt/infinity-scheduler works
1. What this repository is
- infinity-scheduler is a Linux kernel scheduler patch set, not a standalone daemon or userspace service.
- Its architectural boundary is the upstream kernel scheduler: it modifies CFS/EEVDF and RT scheduling behavior in-kernel.
2. Main functional subsystem: the scheduling policy
- The policy centers on a fair-share budget model driven by an EMA (exponential moving average) of recent runtime.
- The key idea is a feedback loop: more runtime increases EMA, which shortens future slices; sleeping decays EMA, restoring responsiveness.
3. Core code location
- src/infinity_sched.c is the reference implementation of the scheduling logic.
- src/infinity_sched.h defines the public-facing kernel API used by the patch: constants, sysctl declarations, and function prototypes.
- Treat src/ as the algorithm source of truth for the kernel modifications.
4. Where it hooks into the kernel
- The README maps Infinity into specific scheduler touchpoints:
- fair scheduling: update_deadline(), update_curr(), enqueue_task_fair(), dequeue_task_fair(), task_fork_fair(), pick_next_entity()
- RT scheduling: update_curr_rt(), dequeue_task_rt(), __enqueue_rt_entity()
- v3-specific wakeup behavior: place_entity(), pick_eevdf()
- These hooks are the main architectural integration points between Infinity and the upstream scheduler.
5. Fair-scheduling data flow
- A task’s runtime history feeds the EMA state.
- That EMA drives:
- slice length via infinity_slice()
- deadline/wakeup positioning via infinity_wakeup() and infinity_wakeup_scale()
- task initialization via infinity_fork_init()
- The result is a scheduler tree where CPU-bound tasks are progressively throttled while interactive sleepers regain advantage.
6. RT-scheduling data flow
- RT tasks are not separate from the model; they are also modulated by the same EMA concept.
- update_curr_rt() and dequeue_task_rt() adjust RT state as tasks run or block.
- In v3, __enqueue_rt_entity() also uses EMA-modulated queue placement, so RT behavior is influenced by recent execution intensity rather than a fixed priority model alone.
7. Wakeup and interactivity behavior
- Sleep/wakeup transitions are important boundaries in the design.
- On sleep, tasks record timing and let EMA decay; on wake, the scheduler can give them shorter virtual slices so they reach an earlier deadline in the EEVDF tree.
- The README also highlights a futex-wait bypass path: interactive waiters can skip slice protection so they can preempt sooner at the next scheduling point.
8. Configuration surface
- Runtime control is exposed through kernel sysctl parameters under kernel.infinity_*.
- The main knobs are:
- infinity_carriage_ns — the base fair-share window
- infinity_smt_divisor — SMT-specific slice adjustment
- infinity_running — read-only active flag
- infinity_reset — reset trigger
- This makes the policy tunable without changing the kernel image, but still keeps all values clamped in-kernel.
9. Repository packaging by kernel version
- patches/stable/ contains versioned patch bundles for specific kernel releases such as linux-6.18-infinity, linux-7.0.12-infinity, and linux-7.1-infinity.
- This is the release/distribution layer of the repo: the same scheduler concept is adapted into multiple kernel baselines.
10. Tooling and automation layer
- tools/install-infinity-scheduler.sh is the main operational entry point for building and installing the patched kernel.
- tools/build-kernel.sh supports standalone kernel builds.
- tools/adapt-patches.py, tools/fix-patch-format.py, and tools/fix-patch-counts.py support patch maintenance across kernel versions.
- These tools exist to keep the patch series portable as upstream kernel internals move.
11. Operational lifecycle
- The expected flow is: obtain the correct patch set, build a kernel with the Infinity changes, install it, and boot into the -infinity kernel.
- Runtime verification happens through uname -r, sysctl state, and kernel log output.
- This shows the project’s runtime boundary clearly: once booted, Infinity lives entirely inside the Linux kernel scheduler.
12. Architectural summary for diagramming
- A useful diagram would show:
- Userspace/sysctl feeding tunables into the kernel
- Task execution / sleep / wake events feeding EMA state
- Infinity scheduling logic computing slices, deadlines, and RT placement
- Upstream kernel scheduler structures receiving the modified decisions
- Patch/tooling layer as the build-time path that injects Infinity into specific kernel versions
Main entry points: infinity_sched.c Scheduler core · 0001-infinity-scheduler.patch 6.18 bundle · build-kernel.sh Build script · install-infinity-scheduler.sh Install script
Components 21
Policy core
EMA-driven scheduler logic and tunables
- Scheduler core · Reference implementation of Infinity scheduling policy
src/infinity_sched.c - Kernel API · Constants, sysctls, and scheduler function prototypes
src/infinity_sched.h - EMA budget · Tracks recent runtime to shape future CPU share
- Slice control · Computes fair-share slice length from budget state
- Wakeup logic · Adjusts wakeup placement and deadline advantage
- Fork init · Initializes task state for new forks
- RT modulation · Applies EMA-aware behavior to real-time tasks
- Sysctl knobs · Kernel.infinity_* tunables and reset controls
Kernel hooks
Upstream CFS/EEVDF and RT integration points
- Fair hooks · CFS/EEVDF touchpoints for runtime, enqueue, dequeue, fork, and pick
- RT hooks · RT scheduling touchpoints for runtime and queue state
- EEVDF wakeups · Wakeup placement and selection changes in v3 behavior
- Kernel scheduler · Modified CFS, EEVDF, and RT scheduler behavior
Patch bundles
Versioned patch series for kernel releases
- 6.18 bundle · Stable patch series for linux-6.18-infinity
patches/stable/linux-6.18-infinity/0001-infinity-scheduler.patch - 7.0.12 bundle · Stable patch series for linux-7.0.12-infinity
patches/stable/linux-7.0.12-infinity/0001-infinity-scheduler.patch - 7.1 bundle · Stable patch series for linux-7.1-infinity
patches/stable/linux-7.1-infinity/0001-infinity-scheduler.patch
Tooling
Build, install, and patch-maintenance scripts
- Install script · Builds and installs the patched kernel
tools/install-infinity-scheduler.sh - Build script · Standalone kernel build helper
tools/build-kernel.sh - Adapt patches · Port patch series across kernel versions
tools/adapt-patches.py - Fix format · Normalizes patch formatting
tools/fix-patch-format.py - Fix counts · Updates patch counts and metadata
tools/fix-patch-counts.py
Other components
- README · Architecture and usage guide
README.md
Connections 26
- README → Scheduler core: describes · Documents the scheduler implementation and behavior
- README → 6.18 bundle: packages · Explains versioned patch bundles
- Scheduler core → Kernel API: uses · Implementation depends on shared kernel-facing declarations
- Scheduler core → EMA budget: maintains · Updates runtime history and decay state
- EMA budget → Slice control: drives · Budget state determines future slice length
- EMA budget → Wakeup logic: drives · Budget state influences wakeup placement
- EMA budget → RT modulation: drives · Budget state modulates RT behavior
- Scheduler core → Fork init: implements · Initializes task state on fork
- Scheduler core → Sysctl knobs: reads · Consumes tunables and reset state
- Sysctl knobs → Kernel scheduler: configures · Exposes runtime control inside the kernel scheduler
- Scheduler core → Fair hooks: hooks · Integrates into CFS scheduling paths
- Scheduler core → RT hooks: hooks · Integrates into RT scheduling paths
- Scheduler core → EEVDF wakeups: hooks · Integrates wakeup and selection behavior
- Fair hooks → Kernel scheduler: modifies · Changes fair-scheduler decisions in-kernel
- RT hooks → Kernel scheduler: modifies · Changes real-time scheduling behavior
- EEVDF wakeups → Kernel scheduler: modifies · Changes EEVDF wakeup and pick behavior
- 6.18 bundle → Kernel scheduler: patches · Applies Infinity changes to a kernel baseline
- 7.0.12 bundle → Kernel scheduler: patches · Applies Infinity changes to a kernel baseline
- 7.1 bundle → Kernel scheduler: patches · Applies Infinity changes to a kernel baseline
- Install script → Build script: invokes · Install flow builds the patched kernel
- Install script → 6.18 bundle: uses · Selects a versioned patch bundle for installation
- Build script → 6.18 bundle: consumes · Build helper works with patched kernel sources
- Adapt patches → 7.0.12 bundle: updates · Ports patch series across moving kernel internals
- Fix format → 6.18 bundle: normalizes · Maintains patch formatting consistency
- Fix counts → 6.18 bundle: repairs · Maintains patch metadata and counts
- Build script → Kernel scheduler: produces · Build output is the patched kernel image