pub struct WatchBpfMap { /* private fields */ }Expand description
Host-side, observer-effect-free read of a NAMED scheduler BPF-map field, surfaced as an assertable run-level metric.
The free-running host monitor resolves the field once (lazily, after the
scheduler attaches and its maps appear) via BTF, then reads it each
monitor tick WITHOUT freezing the guest — turning “the scheduler computed
X” into an assertable metric. Read via
crate::vmm::result::VmResult::run_metric under the key
<scheduler-obj>_<label> (scalar, scalar-counter, or per-CPU-counter) or
<scheduler-obj>_<label>_{avg,max} (per-CPU gauge), e.g.
scx_lavd_avg_lat_cri, scx_lavd_lat_headroom_avg.
<scheduler-obj> is libbpf’s object name for the active scheduler, which
can differ from its source / ops name (e.g. scx-ktstr’s object is
bpf_bpf). Each target’s label must be unique within a test: duplicate
labels resolve to one metric key and are rejected at VM build time.
Construct with WatchBpfMap::new, which const-asserts the field
formats at compile time. Direct struct-literal construction is rejected
(fields are crate-private) so every constructed value passes the gate.
Implementations§
Source§impl WatchBpfMap
impl WatchBpfMap
Sourcepub const fn new(
map_name_suffix: &'static str,
field: &'static str,
agg: BpfMapAgg,
label: &'static str,
) -> Self
pub const fn new( map_name_suffix: &'static str, field: &'static str, agg: BpfMapAgg, label: &'static str, ) -> Self
Const constructor for use in static/const context.
map_name_suffix matches a loaded BPF map by ends_with (kernel map
names truncate to 15 bytes). Unlike BpfMapWrite::new it does NOT
require a leading .: a watched map may be a section map (.bss)
OR a named map (cpu_ctx_stor). field is a dot-path into the map’s
value type (sys_stat.avg_lat_cri, or a bare lat_headroom).
label is the metric-key leaf appended to the scheduler-obj prefix.
§Panics
Panics at compile time when any of map_name_suffix / field /
label is empty or carries whitespace, a path separator (/, \),
or a non-printable / control / high-bit byte. Additionally field
may not have a leading/trailing . or a doubled .. (an empty path
segment the resolver could never match), and label may not contain
. at all (it is a single metric-key leaf, not a path).
Sourcepub const fn map_name_suffix(&self) -> &'static str
pub const fn map_name_suffix(&self) -> &'static str
The validated map-name suffix to match (via ends_with) against
loaded BPF maps (e.g. ".bss", "cpu_ctx_stor").
Sourcepub const fn field(&self) -> &'static str
pub const fn field(&self) -> &'static str
The dot-path into the map’s value type
(e.g. "sys_stat.avg_lat_cri" or "lat_headroom").
Trait Implementations§
Source§impl Clone for WatchBpfMap
impl Clone for WatchBpfMap
Source§fn clone(&self) -> WatchBpfMap
fn clone(&self) -> WatchBpfMap
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WatchBpfMap
impl Debug for WatchBpfMap
Source§impl Hash for WatchBpfMap
impl Hash for WatchBpfMap
Source§impl PartialEq for WatchBpfMap
impl PartialEq for WatchBpfMap
impl Copy for WatchBpfMap
impl Eq for WatchBpfMap
impl StructuralPartialEq for WatchBpfMap
Auto Trait Implementations§
impl Freeze for WatchBpfMap
impl RefUnwindSafe for WatchBpfMap
impl Send for WatchBpfMap
impl Sync for WatchBpfMap
impl Unpin for WatchBpfMap
impl UnwindSafe for WatchBpfMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more