Skip to main content

Crate scx_cake

Crate scx_cake 

Source

Re-exportsΒ§

pub(crate) use scx_utils::NR_CPU_IDS; πŸ”’
pub(crate) use std::collections::BTreeMap; πŸ”’
pub(crate) use std::io::IsTerminal; πŸ”’
pub(crate) use std::mem::MaybeUninit; πŸ”’
pub(crate) use std::sync::Arc; πŸ”’
pub(crate) use std::sync::atomic::AtomicBool; πŸ”’
pub(crate) use std::sync::atomic::AtomicU64; πŸ”’
pub(crate) use std::sync::atomic::Ordering; πŸ”’
pub(crate) use std::time::Duration; πŸ”’
pub(crate) use anyhow::Context; πŸ”’
pub(crate) use anyhow::Result; πŸ”’
pub(crate) use clap::Parser; πŸ”’
pub(crate) use libbpf_rs::AsRawLibbpf; πŸ”’
pub(crate) use libbpf_rs::MapCore; πŸ”’
pub(crate) use libbpf_rs::MapFlags; πŸ”’
pub(crate) use libbpf_rs::OpenObject; πŸ”’
pub(crate) use log::info; πŸ”’
pub(crate) use log::warn; πŸ”’
pub(crate) use scx_utils::NR_CPU_IDS; πŸ”’
pub(crate) use scx_utils::Topology; πŸ”’
pub(crate) use scx_utils::UserExitInfo; πŸ”’
pub(crate) use scx_utils::build_id; πŸ”’
pub(crate) use scx_utils::compat; πŸ”’
pub(crate) use scx_utils::scx_ops_attach; πŸ”’
pub(crate) use scx_utils::scx_ops_load; πŸ”’
pub(crate) use scx_utils::scx_ops_open; πŸ”’
pub(crate) use scx_utils::try_set_rlimit_infinity; πŸ”’
pub(crate) use scx_utils::uei_exited; πŸ”’
pub(crate) use scx_utils::uei_report; πŸ”’
pub use bpf_intf::*;

ModulesΒ§

bpf_intf
bpf_skel πŸ”’
build_identity πŸ”’
core_performance πŸ”’
Startup-only platform preference discovery. These are hints, not speed ratios.
imp
types

StructsΒ§

BpfLinks
BpfMaps
BpfProgs
BpfSkel
BpfSkelBuilder
HandoffProbe πŸ”’
One host’s wake+block+switch hop, as a distribution rather than a mean.
LlcLayout πŸ”’
The LLC topology the loader publishes to rodata, built from (cpu id, llc id) pairs so any host shape can be tested without a machine.
OpenBpfMaps
OpenBpfProgs
OpenBpfSkel
Opts πŸ”’
scx_cake: a gaming-first sched_ext scheduler.
OwnedRef
PreferredDie πŸ”’
Per-LLC idle-word masks and the LLC each mode prefers: the die with the most high-capacity cores, else the largest cache under mode β€œcache”, else the highest summed platform preference. Multi-LLC hosts within one word only.
Scheduler πŸ”’
SinkMonitor πŸ”’
Live IRQ-sink tracking riding the 1 s run loop. Each window the handler-time deltas are split at their widest gap; a CPU above the cut for FLAG_POLLS windows is published, released after UNFLAG_POLLS below it (a loading screen must not flap the mask). An unchanged set doubles the interval up to INTERVAL_MAX; a disagreeing window resets to tick rate. All four are counts.
StructOps

ConstantsΒ§

SCHEDULER_NAME πŸ”’
TOGGLES πŸ”’
Every construct toggle: name, construct, BPF default. The default is checked against the compiled rodata at start so the two cannot drift; –help prints this table.

StaticsΒ§

DATA

FunctionsΒ§

amd_x3d_mode πŸ”’
The AMD 3D V-cache mode (β€œcache” or β€œfrequency”) when the platform driver exposes it.
attach_irq_pair πŸ”’
Retain complete pairs only, ordered for entry-first teardown.
build_skel_config
coarse_tick_ns πŸ”’
The tick period from the coarse clock’s resolution, which the kernel sets to one jiffy. 0 when the resolution is not a plausible tick (a VM or an odd clocksource): the precise task-age clock is used instead.
configure_acquire_census πŸ”’
ops.cpu_acquire exists for the probe hold census only; a release run does not pay a BPF entry per RT-to-SCX switch to record nothing.
cpuidle_states πŸ”’
cpuidle exit latency per state index (ns, enabled states only) from cpu0’s sysfs, and the driver name; empty on a host without a driver.
drop_privileges_for_observers πŸ”’
Drop the calling thread’s capability sets and restore process inspection. Call after privileged setup. Earlier-created threads retain their own capabilities; a subsequent privileged initialization requires re-exec.
last_cpu_id πŸ”’
The highest CPU id in a sysfs cpulist (β€œ0-15”, β€œ0-3,8-11”, β€œ0”).
main πŸ”’
online_cpu_set πŸ”’
CPUs online now, from sysfs; every present CPU when the file is unreadable.
parse_opts_lenient πŸ”’
Parse the command line, dropping options cake does not have instead of refusing to start (a legacy scx_loader flag must not keep the scheduler off); dropped tokens are reported once logging is up. Real errors keep clap’s.
preferred_die πŸ”’
preferred_word πŸ”’
probe_handoff_hop_ns πŸ”’
Measure one wake + block + switch hop on THIS host: two threads ping-pong through a condvar, the blocking handoff cake_handoff_max_ns is a proxy for. Runs before attach, so it measures the stock kernel path; ~2200 round trips. Returns ns per one-way hop, or None, and callers keep the defaults.
read_irq_ticks πŸ”’
Per-CPU time spent in interrupt handlers, in kernel ticks, from /proc/stat (irq + softirq columns, CONFIG_IRQ_TIME_ACCOUNTING). Handler TIME is the harm itself: a wake suffers when it lands on a running handler, so line counts mis-price it; softirq is included because NAPI shadows wakes.
reexec_self πŸ”’
Restore file capabilities for a requested restart after dropping the link.
sink_deltas πŸ”’
The CPUs /proc/stat reported in both reads, and their handler-time deltas in that order. Only those are ranked: a possible-but-offline id has no handler time and would push the whole online set above the widest gap.
sink_words πŸ”’
sinks_by_widest_gap πŸ”’
Split the host’s handler-time distribution at its widest gap: sinks are the CPUs above the cut. No unit-carrying threshold, so it adapts to any host. A zero delta enters at half a tick so every ratio stays finite. A flat set has no sinks; a cut condemning half the machine is load, not affinity (None).
smt_fold πŸ”’
Factor the narrow sibling map into two shifts when every edge has the same distance. Irregular numbering keeps the exact per-CPU lookup.
toggle_help πŸ”’