selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting
Upstream has no selftest of the SCHED_DEADLINE bandwidth accounting. A
leak or a double release does not show at once. Later, the root domain
refuses deadline tasks, or admits more than it can run.
Add deadline_bw_test, with 47 cases. Most cases count the tasks of 10ms
every 100ms that a root domain admits, before and after they run. Once
the tasks of the case are gone and past their 0-lag time, the two counts
must be equal. The cases cover:
- priority inheritance, boost and deboost
- parameter changes, SCHED_FLAG_KEEP_PARAMS among them
- cpuset moves
- deaths, sched_yield() and runtime overruns
- a stopped task
- bandwidth reclaiming and deadline server changes
- CPU hotplug
- parameter changes while a task wakes on another CPU (params_waking)
The comment above each case gives its scenario. params_waking also
compares the this_bw of its CPUs, which "sched/debug: Show the deadline
bandwidth of each runqueue" prints. Two cases follow reproducers of Juri
Lelli's sched-deadline-tests: stopped_switched_out and
pi_chain_two_owners.
The test needs root, deadline admission control and 3 CPUs. Most cases
need the cgroup v2 cpuset controller, and some need debugfs, CPU hotplug
or 4 CPUs. move_cancelled needs CONFIG_RT_GROUP_SCHED. A case skips
without what it needs. While a sched_ext scheduler runs all fair tasks,
the server cases use the ext server, and hotplug_server skips.
The message of each fix in this series names the cases that test it.
These cases are not named there. Each fails without its fix, and passes
with it:
- overrun_caught and stopped_switched_out: "sched/deadline: Release the
bandwidth of a task that leaves the class asleep"
- params_keep_class_change: "sched: Refuse SCHED_FLAG_KEEP_PARAMS that
would change the policy or the class"
overrun_caught fails in part of the runs only.
On v7.4-rc2, in three runs of 8 VMs of 8 CPUs, six cases fail in every
VM:
- boosted_owner_policy
- deboost_resets_period
- death_zombie_switched
- params_keep_boosted
- params_keep_class_change
- stopped_switched_out
params_switched_asleep was only in the third run. It failed in every VM
there. params_shrunk_long_period passed there: div64_long() does not
trap.
overrun_caught fails in 5 VMs of 24. In one VM, hotplug_server crashed
the kernel with a divide error in inactive_task_timer().
"sched/deadline: Do not divide by zero active CPUs of a root domain"
fixes it.
Two cases skip there. params_waking needs the this_bw that "sched/debug:
Show the deadline bandwidth of each runqueue" prints. move_cancelled
needs CONFIG_RT_GROUP_SCHED.
With the whole series, every case passes wherever it runs, PREEMPT_RT
included. The test also ran in guests built without cpusets, and in
guests booted with isolcpus=domain,1,2 or isolcpus=domain,0,1.
move_cancelled ran in two guests built with CONFIG_RT_GROUP_SCHED. No
kernel warning is logged.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://github.com/jlelli/sched-deadline-tests
Link: https://patch.msgid.link/90f0986ac819f480267ffa4275db7cb26d3be219.1795115075.git.mathieu.desnoyers@efficios.com
5 files changed