scx_rust_scheduler
is a fully functional FIFO scheduler for the Linux kernel
that operates in user-space and it is 100% implemented in Rust.
It is based on scx_rustland_core
, a framework that is specifically designed
to simplify the creation of user-space schedulers, leveraging the Linux
kernel's sched_ext
feature and BPF.
The scheduler is intended to serve as a basic template for developers who want to experiment with more advanced scheduling policies without having to directly engage with low-level kernel internals.
In order to run this scheduler you need a kernel that supports sched_ext
(CONFIG_SCHED_CLASS_EXT=y
).
You also need the following binaries/packages in order to build the scheduler:
- cargo
- rustc
- bindgen
- bpftool
- libbpf
CachyOS ships a sched_ext
kernel by default, so you only need to install the
following user-space packages:
$ sudo pacman -S bpf libbpf rust clang pkgconf
If you are using Ubuntu, you can run the following commands to setup an
environment to build and test scx_rust_scheduler
:
- install a
sched_ext
Ubuntu kernel and all the required user-space dependencies:
$ sudo add-apt-repository -y --enable-source ppa:arighi/sched-ext
$ sudo apt update -y
$ sudo apt dist-upgrade -y
$ sudo apt install -y rustc cargo libbpf-dev pkg-config clang
- reboot the system
- Build the scheduler:
$ cargo build
- Enable the scheduler:
$ sudo ./target/debug/scx_rust_scheduler
Rust scheduler is enabled (CTRL+c to exit)
- Disable the scheduler:
^C
Rust scheduler is disabled
EXIT: Scheduler unregistered from user space
If your distro doesn't provide a kernel recent enough (>= v6.12), you can use virtme-ng to setup a testing environment to run your Rust scheduler.
Example:
- Install virtme-ng:
$ pip install --break-sysmstem-packages virtme-ng
- Get the Rust scheduler template and build it:
$ git clone https://github.com/arighi/scx_rust_scheduler.git
$ cd scx_rust_scheduler
$ cargo build
- Run the scheduler inside a virtme-ng session:
$ vng --ssh -vr v6.13-rc1 -- ./target/debug/scx_rust_scheduler
- Test: now from another shell session run
vng --ssh-client
to get an interactive shell session where you can run commands to stress test your scheduler.
This software is licensed under the GNU General Public License version 2. See the LICENSE file for details.