mirror of
https://github.com/sched-ext/scx.git
synced 2026-12-03 15:20:51 +00:00
Record fixed homes, the compute grant cap and the hog ladder behind them in STATE, and bring DESIGN, the README and the bench notes in line with the code. Remove the retired bench launchers. The dated research reports stay on the development branch, so links to them point there.
29 lines
1018 B
Python
29 lines
1018 B
Python
"""Runnable-since clock for wake latency read from a sched tracepoint stream.
|
|
|
|
sched_waking and sched_wakeup also fire for a task that is still on a CPU (it
|
|
set a sleep state but was woken before it switched out) and for a task already
|
|
queued. Pairing such a wake with the task's next switch-in reports run time as
|
|
wait time. So the first wake wins, and a task's switch-out discards any wake
|
|
that arrived while it was running.
|
|
"""
|
|
|
|
|
|
class WakeClock:
|
|
__slots__ = ("_since",)
|
|
|
|
def __init__(self):
|
|
self._since = {}
|
|
|
|
def wake(self, pid, t, info=None):
|
|
"""Start pid's wait at t unless an earlier wake already started it."""
|
|
self._since.setdefault(pid, (t, info))
|
|
|
|
def pending(self, pid):
|
|
"""The (t, info) of pid's open wait, or None."""
|
|
return self._since.get(pid)
|
|
|
|
def switch(self, prev_pid, next_pid):
|
|
"""Close prev's stale wake; return next's (t, info) or None."""
|
|
self._since.pop(prev_pid, None)
|
|
return self._since.pop(next_pid, None)
|