assert_scx_events_clean

Function assert_scx_events_clean 

Source
pub fn assert_scx_events_clean(
    events: &[(&str, i64)],
    max_count: Option<i64>,
) -> AssertResult
Expand description

Assert that every SCX event counter in events is at or below max_count. events is a slice of (name, count) pairs sourced from the kernel’s per-task scx_event_stats (see kernel/sched/ext.c, SCX_EV_* macros) — typically aggregated and surfaced via monitor::ScxEventDeltas or sidecar GauntletRow.fallback_count / keep_last_count fields. Pass None for max_count to require zero (the strict default — error-class events should not fire under a healthy scheduler).

The assertion is decoupled from the monitor module on purpose: callers harvest the counters they care about (via the live monitor path or by reading sidecar JSON post-hoc) and feed name/count pairs in. This keeps the assert API surface decoupled from the kernel-side counter inventory, which evolves across kernel versions — adding a new SCX_EV_* does not force an API change here.

Returns a passing result if every counter is within bound; failures concatenate one AssertDetail per offending counter under DetailKind::SchedulerEvent so an operator can identify which events fired without scanning the full counter set.

// Strict default — every counter must be zero.
let r = assert_scx_events_clean(&[("enq_skip_exiting", 0), ("dispatch_local_dsq_offline", 0)], None);
assert!(r.is_pass());

// A non-zero error-class counter fails.
let r = assert_scx_events_clean(&[("enq_skip_exiting", 7)], None);
assert!(r.is_fail());

// Caller-supplied bound tolerates small counts.
let r = assert_scx_events_clean(&[("dispatch_keep_last", 3)], Some(10));
assert!(r.is_pass());