mirror of
https://github.com/sched-ext/scx.git
synced 2026-12-03 15:20:51 +00:00
Pool count. A task counted into the wake pool could stop being runnable without being served: sched_ext bypass during a freezer cycle dequeues it and can refill its slice, which wiped the pool tag kept in the slice's low bits. Both pool counters then stayed above zero with no work left and idle CPUs kept kicking themselves: 72 self-kicks in eight quiet seconds in a four-CPU 7.3.5 guest. Keep the pool number in the task's groove and give it back in ops.quiescent on a dequeue that is not a sleep. Six freezer cycles then drained both counters to zero with no self-kick. The groove now serves every host, so ops.init_task creates it on every host. Deep queues. A search of a queue 64 or more tasks deep looks at eight tasks and moves one the CPU can run. When the same head has waited 2.5 s and still cannot be served, cake exits and names the queue, CPU and PID, and the kernel takes the work back. Placement. The preferred LLC and the core ranks are read once at start: capacity scaled by policy and firmware limits, then preferred-core hints. The once-a-second re-read of the X3D mode is gone, so restart cake after changing it. The loader samples the topology again when a hotplug lands during discovery. Homes. A task whose affinity no longer allows its fixed home gives it up at its next sample. A wake whose home is held by a higher class claims an idle CPU it may use, the home's LLC first. ops.cpu_release kicks an idle CPU that can run the head of the released CPU's queue. Slice grant. The grant's low five bits are cleared for the pool tag and the compute threshold is even, so the +1 on the doubled quotient never changed a grant. Drop it: cake_admit_direct goes from 121 to 108 instructions. --handoff-ns takes 32 to 750000 ns. ShadowGate on a 9800X3D, 7.3.5, 720p Low, four quiet launches a build. This work without the storage fix under it against the parent commit: 601.96 and 593.81 fps, frame p99 1.866 and 1.879 ms, input p99 1.734 and 1.749 ms, three of four pairs ahead. This commit against the same work without the fix, in a second run: 604.35 and 603.25 fps.
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Exercise Cake's pool callbacks with deterministic deferred DSQ insertions."""
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
|
|
sys.dont_write_bytecode = True
|
|
from review_regressions import function
|
|
|
|
|
|
def main():
|
|
bench = Path(__file__).resolve().parent
|
|
bpf = bench.parent / "src" / "bpf"
|
|
source = (bpf / "cake.bpf.c").read_text()
|
|
callbacks = [
|
|
"cake_pool_pending_inc", "cake_pool_claim", "cake_pool_serve",
|
|
"cake_pool_unserved", "cake_pool_pending_dec", "cake_pool_tag",
|
|
"cake_pool_retire", "cake_pool_retire_task", "cake_pool_seen", "cake_pool_insert",
|
|
"cake_quiescent", "cake_idle_interlock",
|
|
]
|
|
with tempfile.TemporaryDirectory(prefix="cake-pool-test-") as directory:
|
|
scratch = Path(directory)
|
|
(scratch / "callbacks.h").write_text(
|
|
"\n\n".join(function(source, name) for name in callbacks)
|
|
)
|
|
binary = scratch / "pool_regressions"
|
|
subprocess.run([
|
|
"cc", "-std=gnu11", "-O2", "-Wall", "-Wextra", "-Werror",
|
|
"-fsanitize=undefined", "-fno-sanitize-recover=all", "-I", str(bpf),
|
|
"-I", str(scratch), str(bench / "pool_regressions.c"), "-o", str(binary),
|
|
], check=True)
|
|
subprocess.run([str(binary)], check=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|