sched_ext is a Linux kernel feature which enables implementing kernel thread schedulers in BPF and dynamically loading them. This repository contains various scheduler implementations and support utilities.
sched_ext enables safe and rapid iterations of scheduler implementations, thus radically widening the scope of scheduling strategies that can be experimented with and deployed; even in massive and complex production environments.
You can find more information, links to blog posts and recordings, in the wiki. The following are a few highlights of this repository.
- The scx_layered case study concretely demonstrates the power and benefits of sched_ext.
- For a high-level but thorough overview of the sched_ext (especially its motivation), please refer to the overview document.
- For a description of the schedulers shipped with this tree, please refer to the schedulers document.
- The following video is the scx_rustland scheduler which makes most scheduling decisions in userspace Rust code showing better FPS in terraria while kernel is being compiled. This doesn't mean that scx_rustland is a better scheduler but does demonstrate how safe and easy it is to implement a scheduler which is generally usable and can outperform the default scheduler in certain scenarios.
sched_ext is supported by the upstream kernel starting from version 6.12. Both Meta and Google are fully committed to sched_ext and Meta is in the process of mass production deployment. See #kernel-feature-status for more details.
In all example shell commands, $SCX refers to the root of this repository.
All that's necessary for running sched_ext schedulers is a kernel with sched_ext support and the scheduler binaries along with the libraries they depend on. Switching to a sched_ext scheduler is as simple as running a sched_ext binary:
scx_simple is a very simple global vtime scheduler which can behave acceptably on CPUs with a simple topology (single socket and single L3 cache domain).
Above, we switch the whole system to use scx_simple by running the binary, suspend it with ctrl-z to confirm that it's loaded, and then switch back to the kernel default scheduler by terminating the process with ctrl-c. For scx_simple, suspending the scheduler process doesn't affect scheduling behavior because all that the userspace component does is print statistics. This doesn't hold for all schedulers.
In addition to terminating the program, there are two more ways to disable a sched_ext scheduler - sysrq-S and the watchdog timer. Ignoring kernel bugs, the worst damage a sched_ext scheduler can do to a system is starving some threads until the watchdog timer triggers.
As illustrated, once the kernel and binaries are in place, using sched_ext schedulers is straightforward and safe. While developing and building schedulers in this repository isn't complicated either, sched_ext makes use of many new BPF features, some of which require build tools which are newer than what many distros are currently shipping. This should become less of an issue in the future. For the time being, the following custom repositories are provided for select distros.
This repository provides two build systems:
- C schedulers: Use make
- Rust schedulers: Use cargo
Dependencies:
- clang: >=16 required, >=17 recommended
- libbpf: >=1.2.2 required, >=1.3 recommended
- bpftool: Usually available in linux-tools-common or similar packages
- libelf, libz, libzstd: For linking against libbpf
- pkg-config: For finding system libraries
- Rust toolchain: >=1.82
The kernel has to be built with the following configuration:
- CONFIG_BPF=y
- CONFIG_BPF_SYSCALL=y
- CONFIG_BPF_JIT=y
- CONFIG_DEBUG_INFO_BTF=y
- CONFIG_BPF_JIT_ALWAYS_ON=y
- CONFIG_BPF_JIT_DEFAULT_ON=y
- CONFIG_SCHED_CLASS_EXT=y
The scx/kernel.config file includes all required and other recommended options for using sched_ext. You can append its contents to your kernel .config file to enable the necessary features.
Rust schedulers are also published on crates.io:
See: CARGO BUILD
- C schedulers: build/scheds/c/scx_simple
- Rust schedulers: target/release/scx_rusty
Both make and cargo support these environment variables for BPF compilation:
- BPF_CLANG: The clang command to use. (Default: clang)
- BPF_CFLAGS: Override all compiler flags for BPF compilation
- BPF_BASE_CFLAGS: Override base compiler flags (non-include)
- BPF_EXTRA_CFLAGS_PRE_INCL: Extra flags before include paths
- BPF_EXTRA_CFLAGS_POST_INCL: Extra flags after include paths
C schedulers only:
- BPFTOOL: The bpftool command to use. (Default: bpftool)
- CC: The C compiler to use. (Default: cc)
Examples:
With the implementation of scx_stats, schedulers no longer display statistics by default. To display the statistics from the currently running scheduler, a manual user action is required. Below are examples of how to do this.
- To check the scheduler statistics, use the
for example 0.5 - this will print the output every half a second
Some schedulers may implement different or multiple monitoring options. Refer to --help of each scheduler for details. Most schedulers also accept --stats $INTERVAL to print the statistics directly from the scheduling instance.
- scx_bpfland
- scx_rusty
- scx_lavd
- scx_rustland
See: scx_loader and scxctl
See also migration guide from scx.service to scx_loader.service: GUIDE
The kernel feature is not yet upstream and can be found in the sched_ext repository. The following are important branches:
- sched_ext: The main development branch. This branch periodically pulls from the bpf-next tree to stay in sync with the kernel and BPF developments.
- sched_ext-release-*: sched_ext backports on top of released kernels. We plan to maintain backports for a few recent kernel releases until sched_ext is merged upstream. Currently maintained backports:
- sched_ext-vN: Patchsets posted upstream. The v4 LKML thread has high-level discussions.
A list of the breaking changes in the sched_ext kernel tree and the associated commits for the schedulers in this repo.
Want to learn how to develop a scheduler or find some useful tools for working with schedulers? See the developer guide for more details.
We aim to build a friendly and approachable community around sched_ext. You can reach us through the following channels:
- GitHub: https://github.com/sched-ext/scx
- Discord: https://discord.gg/b2J8DrWa7t
- Mailing List: [email protected] (for kernel development)
We also hold weekly office hours every Tuesday. Please see the #office-hours channel on Discord for details.
There are articles and videos about sched_ext, which helps you to explore sched_ext in various ways. Followings are some examples:
- Sched_ext YT playlist
- LWN: The extensible scheduler class (February, 2023)
- arighi's blog: Implement your own kernel CPU scheduler in Ubuntu with sched_ext (July, 2023)
- David Vernet's talk : Kernel Recipes 2023 - sched_ext: pluggable scheduling in the Linux kernel (September, 2023)
- Changwoo's blog: sched_ext: a BPF-extensible scheduler class (Part 1) (December, 2023)
- arighi's blog: Getting started with sched_ext development (April, 2024)
- Changwoo's blog: sched_ext: scheduler architecture and interfaces (Part 2) (June, 2024)
- arighi's YT channel: scx_bpfland Linux scheduler demo: topology awareness (August, 2024)
- David Vernet's talk: Kernel Recipes 2024 - Scheduling with superpowers: Using sched_ext to get big perf gains (September, 2024)
- arighi's talk: Kernel Recipes 2025 - Schedule Recipes (September, 2025)
.png)
