pub enum SchedClass {
Cfs,
Batch,
Idle,
Rt,
Deadline,
Ext,
}Expand description
Coarse Linux scheduling class identifier.
Maps to one of the kernel’s six core scheduler classes:
fair_sched_class (CFS / EEVDF — covers SCHED_NORMAL,
SCHED_BATCH, SCHED_IDLE), rt_sched_class (covers
SCHED_FIFO and SCHED_RR), dl_sched_class (covers
SCHED_DEADLINE), and ext_sched_class (covers SCHED_EXT
when sched_ext is loaded). The class is a coarser concept
than SchedPolicy — Cfs covers Normal/Batch/Idle, Rt
covers Fifo/RoundRobin — and is what
WorkType::AsymmetricWaker consumes when it wants to
describe a waker / wakee pair without specifying priority
values. When a per-worker class is applied,
SchedClass::to_policy maps the variant to the equivalent
SchedPolicy (using a default priority where applicable)
and routes through set_sched_policy.
Variants§
Cfs
fair_sched_class — SCHED_NORMAL (CFS / EEVDF). The
default; matches a freshly-forked task before any policy
override.
Batch
fair_sched_class — SCHED_BATCH (background-friendly
fair task with longer wakeup latency targets).
Idle
fair_sched_class — SCHED_IDLE (lowest fair-class
weight; runs only when nothing else is runnable).
Rt
rt_sched_class — SCHED_FIFO at default priority
RT_DEFAULT_PRIO. Requires CAP_SYS_NICE. For explicit
priority control use SchedPolicy::Fifo directly.
Deadline
dl_sched_class — SCHED_DEADLINE. Maps to a
minimum-bandwidth deadline reservation
(SchedClass::default_deadline_reservation) so
SchedClass::Deadline is constructible without picking
runtime/deadline/period. Callers needing precise
reservations should use SchedPolicy::Deadline
directly.
Ext
ext_sched_class — SCHED_EXT. Routes the worker
through the loaded sched_ext BPF scheduler. Under
switch-all (the default scx-ktstr regime), this is the
same effective class as Cfs because every fair-policy
task already reroutes to ext via task_should_scx (see
kernel/sched/ext.c). Cfs is preserved as the explicit
“I want fair semantics” knob the user expresses; Ext
maps to SchedPolicy::Ext, which sets policy == SCHED_EXT
on the task_struct so it is BPF-scheduled even under a
SCX_OPS_SWITCH_PARTIAL scheduler.
Implementations§
Source§impl SchedClass
impl SchedClass
Sourcepub const fn to_policy(self) -> SchedPolicy
pub const fn to_policy(self) -> SchedPolicy
Resolve to an equivalent SchedPolicy. Rt uses
RT_DEFAULT_PRIO; Deadline uses the minimum-bandwidth
reservation (2us runtime, 1ms deadline, 10ms period — passes
__checkparam_dl and the default sysctl bounds).
Ext maps to SchedPolicy::Ext, which issues sched_setattr
with sched_policy = SCHED_EXT (7) so the kernel reads
policy == SCHED_EXT. The task is BPF-scheduled only when a
sched_ext scheduler is attached; with none attached the syscall
still succeeds and the task runs in fair_sched_class.
Sourcepub const fn default_deadline_reservation() -> SchedPolicy
pub const fn default_deadline_reservation() -> SchedPolicy
Minimum-bandwidth SCHED_DEADLINE reservation that passes
__checkparam_dl’s runtime >= (1 << DL_SCALE) (1024ns)
floor and the kernel’s default sched_deadline_period_min_us
(100us). 2us runtime, 1ms deadline, 10ms period — bandwidth
fraction 0.0002, well below admission-control limits.
Trait Implementations§
Source§impl Clone for SchedClass
impl Clone for SchedClass
Source§fn clone(&self) -> SchedClass
fn clone(&self) -> SchedClass
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SchedClass
impl Debug for SchedClass
Source§impl Default for SchedClass
impl Default for SchedClass
Source§fn default() -> SchedClass
fn default() -> SchedClass
Source§impl<'de> Deserialize<'de> for SchedClass
impl<'de> Deserialize<'de> for SchedClass
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SchedClass
impl PartialEq for SchedClass
Source§impl Serialize for SchedClass
impl Serialize for SchedClass
impl Copy for SchedClass
impl Eq for SchedClass
impl StructuralPartialEq for SchedClass
Auto Trait Implementations§
impl Freeze for SchedClass
impl RefUnwindSafe for SchedClass
impl Send for SchedClass
impl Sync for SchedClass
impl Unpin for SchedClass
impl UnwindSafe for SchedClass
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