freenode
Kernel & Low-Level

SCHED_DEADLINE fixes stop crashes and bandwidth leaks

Eight accounting bugs could crash Linux or leave deadline scheduling unable to admit tasks or offline CPUs.

Mathieu Desnoyers has posted eight fixes for bandwidth accounting bugs in the Linux kernel's SCHED_DEADLINE scheduler, two of which can take the system down and others that silently corrupt how much CPU capacity the policy thinks it has left.

SCHED_DEADLINE is the real-time class that guarantees a task runtime within a period. The kernel tracks reserved bandwidth per root domain and per runqueue so admission control can refuse oversubscription. When that bookkeeping drifts, a root domain may admit more deadline work than its CPUs can carry, refuse every new deadline task, refuse to offline its last CPU, or warn on underflows that permanently skew reclaim accounting.

Two defects crash the kernel. One is a divide-by-zero while a fair server's runtime or period is written through debugfs as its CPU passes through hotplug and sits in a root domain with no active CPUs. The other is a BUG when a deadline task's affinity no longer covers any online CPU, which priority inheritance and CPU hotplug can reach on a default configuration.

The other six leave total or per-runqueue bandwidth holding what live tasks do not. Failures span policy switches that reserve bandwidth and then reject the request, throttled tasks briefly moved out of SCHED_DEADLINE and back so they never run again (a fatal signal cannot revive them), sleepers and priority-inheritance handoffs that free bandwidth twice or from the wrong domain, root-domain rebuilds on cpuset or hotplug changes that drop reservations still owed until a later timer, wakeups that migrate a task before its bandwidth is charged to the new runqueue, and kernels built without cpusets that lose every deadline reservation on the first hotplug.

Desnoyers asked deadline maintainers for careful review: he knows the concepts but not the implementation in depth, and wrote the patches with an LLM assistant under his supervision. Each fix has a reproducer measured in VMs. The series also adds selftests that drive policy round-trips, rebuilds, priority inheritance, parameter races on migrating wakeups, fair-server changes, randomized mixes, and hotplug, checking that free bandwidth returns to its starting point once the test tasks are gone.