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;
62
63pub mod ravg;
64
65mod topology;
66pub use topology::Core;
67pub use topology::CoreType;
68pub use topology::Cpu;
69pub use topology::Llc;
70pub use topology::Node;
71pub use topology::Topology;
72pub use topology::NR_CPUS_POSSIBLE;
73pub use topology::NR_CPU_IDS;
74
75mod energy_model;
76pub use energy_model::EnergyModel;
77pub use energy_model::PerfDomain;
78pub use energy_model::PerfState;
79
80mod cpumask;
81pub use cpumask::read_cpulist;
82pub use cpumask::Cpumask;
83
84mod gpu;
85
86mod infeasible;
87pub use infeasible::LoadAggregator;
88pub use infeasible::LoadLedger;
89
90pub mod mangoapp;
91
92pub mod misc;
93pub use misc::monitor_stats;
94pub use misc::normalize_load_metric;
95pub use misc::set_rlimit_infinity;
96
97mod netdev;
98pub use netdev::read_netdevs;
99pub use netdev::NetDev;
100
101pub mod pm;
102
103pub mod enums;
104pub use enums::scx_enums;
105
106#[cfg(feature = "autopower")]
107pub mod autopower;
108
109pub mod perf;