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
37/// Gated exports of `scx_cargo::BpfBuilder` to avoid breaking existing users with this API change.
38/// Please switch build time support to the `scx_cargo` crate.
39#[cfg(feature = "deprecated-build-support")]
40pub use scx_cargo::{BpfBuilder, ClangInfo};
41
42mod bindings;
43
44mod user_exit_info;
45pub use user_exit_info::ScxConsts;
46pub use user_exit_info::ScxExitKind;
47pub use user_exit_info::UeiDumpPtr;
48pub use user_exit_info::UserExitInfo;
49pub use user_exit_info::SCX_ECODE_ACT_RESTART;
50pub use user_exit_info::SCX_ECODE_RSN_HOTPLUG;
51pub use user_exit_info::UEI_DUMP_PTR_MUTEX;
52
53pub mod build_id;
54pub mod compat;
55pub use compat::ksym_exists;
56pub use compat::ROOT_PREFIX;
57
58mod libbpf_logger;
59pub use libbpf_logger::init_libbpf_logging;
60pub mod libbpf_clap_opts;
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::Node;
70pub use topology::Topology;
71pub use topology::NR_CPUS_POSSIBLE;
72pub use topology::NR_CPU_IDS;
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::read_cpulist;
81pub use cpumask::Cpumask;
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::try_set_rlimit_infinity;
95
96mod netdev;
97pub use netdev::read_netdevs;
98pub use netdev::NetDev;
99
100pub mod pm;
101
102pub mod enums;
103pub use enums::scx_enums;
104
105pub mod cli;
106pub use cli::TopologyArgs;
107
108#[cfg(feature = "autopower")]
109pub mod autopower;
110
111pub mod perf;