Expand description
The per-CID queues, observed from the loader. The arena the BPF program
keeps them in is mapped into this process too, at the addresses the
program itself uses, so the loader reads a queue through the same
edq code the program runs, over a memory that can only load.
Nothing is added to the scheduling paths for this. A queue already counts the tasks it holds and the tasks ever queued on it, and both are read without its lock. The time a task waits in a queue follows from the two: by Littleβs law the average wait is the average depth over the arrival rate. The arrivals are exact, and the depth is sampled by a thread that runs only while a stats client is polling.
Re-exportsΒ§
use std::ffi::OsStr;πuse std::sync::Arc;πuse std::sync::Mutex;πuse std::sync::atomic::AtomicBool;πuse std::sync::atomic::AtomicU64;πuse std::sync::atomic::Ordering;πuse std::thread;πuse std::time::Duration;πuse std::time::Instant;πuse anyhow::Context;πuse anyhow::Result;πuse anyhow::ensure;πuse libbpf_rs::AsRawLibbpf;πuse libbpf_rs::MapCore;πuse libbpf_rs::MapFlags;πuse crate::Loaded;πuse crate::OpsProfiler;πuse crate::edq;πuse crate::edq::View;π
StructsΒ§
- Arena
View - The arena, read through the mapping libbpf made when it created the map. The addresses the BPF program stores are user addresses in that mapping, so they are read as they are. An address outside of it reads as 0. The view keeps the object, and with it the mapping, alive.
- CidTable
Reader - A per-CID table of the schedulerβs, read from the loader: the one whose
header is in the
.datasectionsection, see scx_rustschedβscid_slot!, withwords64-bit words per CID. For counters each CPU keeps for itself, which cost the scheduling paths no shared write. - Queue
Sampler - Samples the depth of every CIDβs queue while a stats client is polling, and parks once nobody has asked for a while, as the callback profiler drops its accounting.
- Queue
Stats - What the sampler saw of one CIDβs queue, cumulative.
- Shared π
- State π