Crate scx_utils

Source
Expand description

§Utility collection for sched_ext schedulers

sched_ext is a Linux kernel feature which enables implementing kernel thread schedulers in BPF and dynamically loading them.

This crate is a collection of utilities for sched_ext scheduler implementations which use Rust for userspace component. This enables implementing hot paths in BPF while offloading colder and more complex operations to userspace Rust code which can be significantly more convenient and powerful.

The utilities can be put into two broad categories.

§Build Utilities

BPF being its own CPU architecture and independent runtime environment, build environment and steps are already rather complex. The need to interface between two different languages - C and Rust - adds further complexities. This crate contains struct BpfBuilder which is to be used from build.rs and automates most of the process.

§Utilities for Rust Userspace Component

Utility modules which can be useful for userspace component of sched_ext schedulers.

Re-exports§

pub use user_exit_info::SCX_ECODE_ACT_RESTART;
pub use user_exit_info::SCX_ECODE_RSN_HOTPLUG;
pub use topology::NR_CPU_IDS;
pub use topology::NR_CPUS_POSSIBLE;
pub use misc::monitor_stats;
pub use misc::normalize_load_metric;
pub use misc::set_rlimit_infinity;
pub use enums::scx_enums;

Modules§

autopower
bindings 🔒
bpf_builder 🔒
build_id
builder 🔒
clang_info 🔒
compat
cpumask 🔒
SCX Cpumask
energy_model 🔒
SCX Energy Model
enums
infeasible 🔒
SCX Load Calculator
libbpf_logger 🔒
mangoapp
misc
netdev 🔒
perf
pm
ravg
Running Average Utilities
topology 🔒
SCX Topology
user_exit_info 🔒

Macros§

import_enums
info
Logs a message at the info level.
paste
scx_ops_attach
Must be used together with scx_ops_load!(). See there.
scx_ops_load
struct sched_ext_ops can change over time. If compat.bpf.h::SCX_OPS_DEFINE() is used to define ops, and scx_ops_open!(), scx_ops_load!(), and scx_ops_attach!() are used to open, load and attach it, backward compatibility is automatically maintained where reasonable.
scx_ops_open
struct sched_ext_ops can change over time. If compat.bpf.h::SCX_OPS_DEFINE() is used to define ops, and scx_ops_open!(), scx_ops_load!(), and scx_ops_attach!() are used to open, load and attach it, backward compatibility is automatically maintained where reasonable.
uei_exited
Takes a reference to C struct user_exit_info and test whether the BPF scheduler has exited. See UserExitInfo.
uei_read
Takes a reference to C struct user_exit_info and reads it into UserExitInfo. See UserExitInfo.
uei_report
Takes a reference to C struct user_exit_info, reads, invokes UserExitInfo::report() on and then returns Ok(uei). See UserExitInfo.
uei_set_size
Resize debug dump area according to ops.exit_dump_len. If this macro is not called, debug dump area is not allocated and debug dump won’t be printed out.
unwrap_or_break
warn
Logs a message at the warn level.

Structs§

BpfBuilder
Build helpers for sched_ext schedulers with Rust userspace component
Builder
Core
Cpu
Cpumask
EnergyModel
Llc
LoadAggregator
LoadLedger
NR_CPUS_POSSIBLE
The number of possible CPUs that may be active on the system. Note that this value is separate from the number of possible CPU IDs in the system, as there may be gaps in what CPUs are allowed to be onlined. For example, some BIOS implementations may report spans of disabled CPUs that may not be onlined, whose IDs are lower than the IDs of other CPUs that may be onlined.
NR_CPU_IDS
The maximum possible number of CPU IDs in the system. As mentioned above, this is different than the number of possible CPUs on the system (though very seldom is). This number may differ from the number of possible CPUs on the system when e.g. there are fully disabled CPUs in the middle of the range of possible CPUs (i.e. CPUs that may not be onlined).
NetDev
Node
PerfDomain
PerfState
SCX_ECODE_ACT_RESTART
SCX_ECODE_RSN_HOTPLUG
Topology
UeiDumpPtr
UserExitInfo
Rust counterpart of C struct user_exit_info.

Enums§

CoreType
ScxConsts
ScxExitKind

Statics§

UEI_DUMP_PTR_MUTEX

Functions§

init_libbpf_logging
read_cpulist
read_netdevs