pub enum SchedulerSpec {
Eevdf,
Discover(&'static str),
Path(&'static str),
KernelBuiltin {
enable: &'static [&'static str],
disable: &'static [&'static str],
},
}Expand description
How to specify the scheduler for an #[ktstr_test].
The four variants form a semantic taxonomy, not a syntactic one:
Eevdf is the no-scx control (“kernel default,
don’t launch anything”); Discover and
Path both locate a userspace scheduler binary, by
name-lookup vs. explicit filesystem path respectively; and
KernelBuiltin activates an in-kernel
scheduling policy via shell commands rather than any binary.
Variants§
Eevdf
No userspace scheduler — run under the kernel’s default scheduler. On current kernels that’s EEVDF; the variant name is fixed so the assertion isn’t coupled to the kernel version’s default.
Discover(&'static str)
Auto-discover the scheduler binary by name (looks in
KTSTR_SCHEDULER env, the ktstr binary’s sibling dir,
target/debug/, target/release/, and invokes
cargo build if nothing’s found).
Path(&'static str)
Explicit filesystem path to a scheduler binary. The file must
already exist; resolve_scheduler does not auto-build this
variant.
KernelBuiltin
Kernel-built scheduler (e.g. BPF-less sched_ext or debugfs-tuned). Activated/deactivated via shell commands rather than a userspace binary.
Implementations§
Source§impl SchedulerSpec
impl SchedulerSpec
Sourcepub const fn has_active_scheduling(&self) -> bool
pub const fn has_active_scheduling(&self) -> bool
Whether this spec represents an active scheduling policy (anything other than the kernel default EEVDF).
Returns true for every variant except Self::Eevdf —
including Self::KernelBuiltin, which runs an in-kernel
non-default policy via shell enable/disable commands but
has no userspace BPF binary. Callers that need “the test
runs SOMETHING other than EEVDF” — e.g. enabling
repro-section render, switching verbose-output mode on,
gating non-default-only logic — want this method.
Callers that need “the test runs a userspace BPF
scheduler binary with verifier-stats / struct_ops slab
activity” — e.g. wiring monitor thresholds, surfacing
verifier_stats warnings, gating the auto-repro probe —
want the narrower Self::has_bpf_scheduler instead.
has_active_scheduling returns true for KernelBuiltin,
which is the wrong gate for any code path that assumes a
BPF binary is attached.
Quick gate-picker: use has_active_scheduling when the
predicate is “non-default scheduling policy”; use
Self::has_bpf_scheduler when the predicate is
“userspace BPF binary attached”.
Sourcepub const fn has_bpf_scheduler(&self) -> bool
pub const fn has_bpf_scheduler(&self) -> bool
Whether this spec drives a userspace BPF scheduler binary
(i.e. attaches a struct sched_ext_ops to the kernel).
Returns true for Self::Discover and Self::Path —
both variants point at a userspace BPF binary that
resolve_scheduler locates and launches. Returns false
for Self::Eevdf (no scheduler) and Self::KernelBuiltin
(in-kernel policy switched via shell commands, no userspace
binary, no BPF verifier output, no struct_ops slab activity).
Distinct from Self::has_active_scheduling: that returns
true for KernelBuiltin too (because the kernel IS running
a non-default scheduling policy), which is the wrong gate
for code paths that read verifier_stats, wire BPF-attach
monitor thresholds, or probe for the userspace scheduler
binary’s auto-repro hooks. Use this method whenever the
downstream consumer assumes “BPF binary is loaded and
running” rather than “the kernel is on a non-EEVDF policy”.
Sourcepub const fn display_name(&self) -> &'static str
pub const fn display_name(&self) -> &'static str
Short, human-readable name for logging and sidecar output.
Maps Eevdf → "eevdf", Discover(n) → n, Path(p) → p,
KernelBuiltin { .. } → "kernel". Single source of truth
for “what do we call this scheduler when telling the user” —
sidecar serialization and failure-header formatting both use
this, and any future consumer gets identical naming for free.
Sourcepub const fn scheduler_commit(&self) -> Option<&'static str>
pub const fn scheduler_commit(&self) -> Option<&'static str>
Best-effort git commit of the scheduler binary used for this
run, or None when the commit cannot be determined honestly.
Currently ALWAYS returns None. The field is reserved on the
sidecar schema so stats tooling can enrich it once a reliable
source exists, but no variant today has one:
Eevdf— no userspace scheduler binary at all. Kernel default; the running kernel’s identity belongs inhost.kernel_release, not here.Discover(_)—resolve_schedulerhas a 5-path cascade (KTSTR_SCHEDULERenv override → sibling of the ktstr binary →target/debug/→target/release/→ cargo rebuild fallback). Only the rebuild path guarantees the resulting binary was built from the current tree; the four pre-built discovery paths can point at a binary whose commit is unknown to this process. Synthesizing a commit would be a lie in 4 of 5 cases and would silently attribute regressions to the wrong commit. A future enhancement can probe the binary itself (e.g.--versionoutput, an ELF note) and returnSome(..)ONLY when the actual commit is introspected; until then,Noneis the only honest answer.Path(p)— arbitrary externally-built binary. No reliable introspection path (no shared ABI, no required--versionformat).KernelBuiltin— in-kernel scheduler, no userspace binary commit to record.
Returning None rather than Some("unknown") keeps the
sidecar schema’s nullable semantics honest: perf-delta
distinguishes “unset” from “set to a sentinel” without a
magic string, and a future enhancement that learns to
introspect a scheduler binary can flip a single arm to
Some(..) without retrofitting consumers to strip a
sentinel.
Trait Implementations§
Source§impl Clone for SchedulerSpec
impl Clone for SchedulerSpec
Source§fn clone(&self) -> SchedulerSpec
fn clone(&self) -> SchedulerSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SchedulerSpec
impl Debug for SchedulerSpec
Source§impl From<&SchedulerSpec> for SchedulerKind
impl From<&SchedulerSpec> for SchedulerKind
Source§fn from(spec: &SchedulerSpec) -> Self
fn from(spec: &SchedulerSpec) -> Self
Single source of truth for the SchedulerSpec → SchedulerKind mapping. Exhaustive match so adding a 5th SchedulerSpec variant triggers a compile error here, forcing the discriminator to grow in lockstep.
Source§impl Hash for SchedulerSpec
impl Hash for SchedulerSpec
Source§impl PartialEq for SchedulerSpec
impl PartialEq for SchedulerSpec
impl Copy for SchedulerSpec
impl Eq for SchedulerSpec
impl StructuralPartialEq for SchedulerSpec
Auto Trait Implementations§
impl Freeze for SchedulerSpec
impl RefUnwindSafe for SchedulerSpec
impl Send for SchedulerSpec
impl Sync for SchedulerSpec
impl Unpin for SchedulerSpec
impl UnwindSafe for SchedulerSpec
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