notes

The lock-wait instrument

Name: provisional, for this stem, and for the module, feature and job-mix-lock: line it describes. Naming is an architect's.

kernel/src/lock_wait.rs, built only with --features lock_wait, which implies job_mix. It answers one question about the job mix: how often its threads found a kernel lock held, and how long they waited. No other kernel carries a byte of it, and script/fastpath-footprint builds neither feature. null-system-call-under-load.md is what it was built to explain and what it found.

What it counts

Per sweep point, summed over cores:

Counting runs only while the supervisor has armed it, for each timed subrun, and not during the untimed breakdown exchange. Each core's counters sit on cache lines of their own, written only by that core, so the instrument does not add the cross-core traffic it measures.

A rank that sync::rank gives to more than one lock (59 is the inbox, the kernel object budget and the mappings table) is printed by number only. A name would claim an attribution the counter cannot make.

What it costs

An acquisition that finds the lock free costs what it always did. InterruptSafeMutualExclusionLock::lock opens with try_lock, the same compare-and-swap test_and_set_lock's lock opens with. current_capability pays a flag store, a counter increment and a flag clear, all on its own core's line. The clock is read only on the contended path, twice per wait. On radon a rdtime may be emulated by firmware (a recollection about the SiFive U74, not checked against radon's OpenSBI), and reading it on every call would add to the cheapest system call the very cost this is trying to find. The reaper reads the clock on every reap, which is cold: one call per thread exit.

What it cannot see