Skip to content

Template to implement Linux kernel schedulers in Rust running in user-space

License

Notifications You must be signed in to change notification settings

arighi/scx_rust_scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

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.

Requirements

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

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

Ubuntu

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

Getting Started

  • 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

Setting up a virtual environment for testing

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.

See also

License

This software is licensed under the GNU General Public License version 2. See the LICENSE file for details.

About

Template to implement Linux kernel schedulers in Rust running in user-space

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published