CtprofMetricDef

Struct CtprofMetricDef 

Source
#[non_exhaustive]
pub struct CtprofMetricDef { pub name: &'static str, pub rule: AggRule, pub sched_class: Option<&'static str>, pub config_gates: &'static [&'static str], pub is_dead: bool, pub description: &'static str, pub section: Section, }
Expand description

One metric exposed by the comparison pipeline.

The auto-scale ladder for the rendered cell is derived from AggRule::ladder at render time — there is no separate unit tag on the metric def. A registry entry that pairs an AggRule variant with a category-mismatched ladder fails at compile time (the ladder mapping is a closed match on the variant, not a free-form string).

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: &'static str§rule: AggRule§sched_class: Option<&'static str>

Scheduler-class scope for the metric. None means class-agnostic — every task class accumulates the value (e.g. nr_migrations). Concrete spellings:

  • "cfs-only" — incremented strictly inside CFS-class call paths (kernel/sched/fair.c), zero under SCHED_EXT / SCHED_FIFO / SCHED_RR / SCHED_DEADLINE / SCHED_IDLE. Examples: nr_wakeups_affine, nr_wakeups_affine_attempts, nr_failed_migrations_*, nr_forced_migrations, slice_max.
  • "fair-policy" — emitted only when fair_policy(p->policy) returns true. Per kernel/sched/sched.h:194,203, that admits SCHED_NORMAL, SCHED_BATCH, AND SCHED_EXT (under CONFIG_SCHED_CLASS_EXT). Zero under SCHED_FIFO/RR/DL/IDLE. Example: fair_slice_ns.
  • "non-ext" — written by the schedstats sleep/wait family wrappers __update_stats_enqueue_sleeper (kernel/sched/stats.c:48) and __update_stats_wait_end (kernel/sched/stats.c:21), called from fair.c, rt.c, deadline.c but NOT ext.c — i.e. CFS/RT/DL accumulate, sched_ext bypasses. Examples: wait_sum, wait_count, wait_max, voluntary_sleep_ns, sleep_max, block_sum, block_max, iowait_sum, iowait_count.
§config_gates: &'static [&'static str]

Kernel CONFIG options that gate the metric. &[] means no gating (always populated when the source path runs). One element typically; multi-element when more than one gate is required (e.g. core_forceidle_sum requires CONFIG_SCHED_CORE AND CONFIG_SCHEDSTATS). Concrete spellings match the literal Kconfig symbol so an operator can grep CONFIG_X /boot/config-$(uname -r) to confirm. Verified gates:

  • "CONFIG_SCHEDSTATS" — gates every __schedstat_* / schedstat_* macro call. Off → the macro is do { } while (0) per kernel/sched/stats.h:75-82.
  • "CONFIG_SCHED_INFO" — gates the lighter-weight sched_info_* accounting (run_time_ns, wait_time_ns, timeslices); the schedstat file is gated by sched_info_on() at proc_pid_schedstat (fs/proc/base.c:511-523).
  • "CONFIG_SCHED_CORE" — gates the core-scheduling subsystem (__account_forceidle_time).
  • "CONFIG_SCHED_CLASS_EXT" — gates the sched_ext class. When off, no task can land on ext, so ext_enabled reads false uniformly.
  • "CONFIG_TASK_DELAY_ACCT" — gates the delayacct accounting path that populates the taskstats genetlink delay-family fields (cpu_delay_*, blkio_delay_*, etc.).
  • "CONFIG_TASK_IO_ACCOUNTING" — gates the per-task I/O accounting fields exposed by /proc/<tid>/io (rchar, wchar, syscr, syscw, read_bytes, write_bytes, cancelled_write_bytes). The kernel emits all 7 fields under one do_io_accounting call, and CONFIG_TASK_IO_ACCOUNTING depends on CONFIG_TASK_XACCT in init/Kconfig — so from the procfs-reader perspective the file is all-or-nothing.
§is_dead: bool

True for kernel counters that are exposed in /proc but never incremented anywhere in the kernel tree — always reads zero. Operators reading the rendered table see the [dead] flag and stop chasing the always-zero cell. The registry is currently empty of is_dead: true entries: the previously-registered dead counters (nr_wakeups_idle, nr_wakeups_passive, nr_migrations_cold) were dropped from ThreadState and the registry; the kernel still emits the lines so the parser silently ignores them. The flag remains as infrastructure: a future kernel that resurrects a dead counter (or exposes a new always-zero one) registers with is_dead: true and the [dead] rendering path fires.

§description: &'static str

One-line operator-facing description of what this metric counts. Surfaced by the ctprof metric-list subcommand alongside the bracketed tag suffix so an operator scanning a rendered table can map an unfamiliar metric name to its semantics without leaving the CLI. Plain ASCII. “Cumulative” is load-bearing — use it to distinguish counters from gauges; the AggRule only names the per-group reduction, not the per-thread counter shape.

§section: Section

Section this metric belongs to for the --sections per-row filter. Most rows tag Section::Primary; taskstats-sourced rows (the eight delay-accounting categories plus the two memory watermarks) carry Section::TaskstatsDelay so an operator can scope the rendered table down to (or away from) the taskstats rows. The primary-table emitter checks DisplayOptions::is_section_enabled per row before rendering — --sections taskstats-delay keeps only taskstats rows, --sections primary excludes them, and either alone keeps the primary table open. The default (empty filter) renders every row regardless of section.

Trait Implementations§

Source§

impl Clone for CtprofMetricDef

Source§

fn clone(&self) -> CtprofMetricDef

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CtprofMetricDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for CtprofMetricDef

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,