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::ScxConsts;
49pub use user_exit_info::ScxExitKind;
50pub use user_exit_info::UeiDumpPtr;
51pub use user_exit_info::UserExitInfo;
52pub use user_exit_info::SCX_ECODE_ACT_RESTART;
53pub use user_exit_info::SCX_ECODE_RSN_HOTPLUG;
54pub use user_exit_info::UEI_DUMP_PTR_MUTEX;
55
56pub mod build_id;
57pub mod compat;
58pub use compat::ROOT_PREFIX;
59
60mod libbpf_logger;
61pub use libbpf_logger::init_libbpf_logging;
62pub mod libbpf_clap_opts;
63
64pub mod ravg;
65
66mod topology;
67pub use topology::Core;
68pub use topology::CoreType;
69pub use topology::Cpu;
70pub use topology::Llc;
71pub use topology::Node;
72pub use topology::Topology;
73pub use topology::NR_CPUS_POSSIBLE;
74pub use topology::NR_CPU_IDS;
75
76mod energy_model;
77pub use energy_model::EnergyModel;
78pub use energy_model::PerfDomain;
79pub use energy_model::PerfState;
80
81mod cpumask;
82pub use cpumask::read_cpulist;
83pub use cpumask::Cpumask;
84
85mod gpu;
86
87mod infeasible;
88pub use infeasible::LoadAggregator;
89pub use infeasible::LoadLedger;
90
91pub mod mangoapp;
92
93pub mod misc;
94pub use misc::monitor_stats;
95pub use misc::normalize_load_metric;
96pub use misc::try_set_rlimit_infinity;
97
98mod netdev;
99pub use netdev::read_netdevs;
100pub use netdev::NetDev;
101
102pub mod pm;
103
104pub mod enums;
105pub use enums::scx_enums;
106
107pub mod cli;
108pub use cli::TopologyArgs;
109
110#[cfg(feature = "autopower")]
111pub mod autopower;
112
113pub mod perf;