scx_utils/
lib.rs

1// Copyright (c) Meta Platforms, Inc. and affiliates.
2//
3// This software may be used and distributed according to the terms of the
4// GNU General Public License version 2.
5
6//! # Utility collection for sched_ext schedulers
7//!
8//! [sched_ext](https://github.com/sched-ext/scx) is a Linux kernel feature
9//! which enables implementing kernel thread schedulers in BPF and dynamically
10//! loading them.
11//!
12//! This crate is a collection of utilities for sched_ext scheduler
13//! implementations which use Rust for userspace component. This enables
14//! implementing hot paths in BPF while offloading colder and more complex
15//! operations to userspace Rust code which can be significantly more convenient
16//! and powerful.
17//!
18//! The utilities can be put into two broad categories.
19//!
20//! ## Build Utilities
21//!
22//! BPF being its own CPU architecture and independent runtime environment,
23//! build environment and steps are already rather complex. The need to
24//! interface between two different languages - C and Rust - adds further
25//! complexities. This crate contains `struct BpfBuilder` which is to be
26//! used from `build.rs` and automates most of the process.
27//!
28//! ## Utilities for Rust Userspace Component
29//!
30//! Utility modules which can be useful for userspace component of sched_ext
31//! schedulers.
32
33pub use log::info;
34pub use log::warn;
35pub use paste::paste;
36
37mod clang_info;
38
39mod bindings;
40
41mod bpf_builder;
42pub use bpf_builder::BpfBuilder;
43
44mod builder;
45pub use builder::Builder;
46
47mod user_exit_info;
48pub use user_exit_info::SCX_ECODE_ACT_RESTART;
49pub use user_exit_info::SCX_ECODE_RSN_HOTPLUG;
50pub use user_exit_info::ScxConsts;
51pub use user_exit_info::ScxExitKind;
52pub use user_exit_info::UEI_DUMP_PTR_MUTEX;
53pub use user_exit_info::UeiDumpPtr;
54pub use user_exit_info::UserExitInfo;
55
56pub mod build_id;
57pub mod compat;
58
59mod libbpf_logger;
60pub use libbpf_logger::init_libbpf_logging;
61
62pub mod ravg;
63
64mod topology;
65pub use topology::Core;
66pub use topology::CoreType;
67pub use topology::Cpu;
68pub use topology::Llc;
69pub use topology::NR_CPU_IDS;
70pub use topology::NR_CPUS_POSSIBLE;
71pub use topology::Node;
72pub use topology::Topology;
73
74mod energy_model;
75pub use energy_model::EnergyModel;
76pub use energy_model::PerfDomain;
77pub use energy_model::PerfState;
78
79mod cpumask;
80pub use cpumask::Cpumask;
81pub use cpumask::read_cpulist;
82
83mod gpu;
84
85mod infeasible;
86pub use infeasible::LoadAggregator;
87pub use infeasible::LoadLedger;
88
89pub mod mangoapp;
90
91pub mod misc;
92pub use misc::monitor_stats;
93pub use misc::normalize_load_metric;
94pub use misc::set_rlimit_infinity;
95
96mod netdev;
97pub use netdev::NetDev;
98pub use netdev::read_netdevs;
99
100pub mod pm;
101
102pub mod enums;
103pub use enums::scx_enums;
104
105#[cfg(feature = "autopower")]
106pub mod autopower;
107
108pub mod perf;