-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scx_rustlite: simple vtime-based scheduler written in Rust
Provide a simple scheduler with a BPF part and a user-space counterpart, written in Rust, that can be used as a template to implement more complex scheduling policies. The main goal of this scheduler is to be easy to read and well documented, so that newcomers (i.e., students, researchers, junior devs, etc.) can use it to quickly experiment their scheduling theories. For this reason the design of this scheduler is mostly focused on simplicity and code readability. Signed-off-by: Andrea Righi <[email protected]>
- Loading branch information
Andrea Righi
committed
Dec 18, 2023
1 parent
239d5d1
commit da8a99a
Showing
12 changed files
with
788 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
subdir('scx_layered') | ||
subdir('scx_rusty') | ||
subdir('scx_rustlite') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
src/bpf/.output | ||
Cargo.lock | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "scx_rustlite" | ||
version = "0.0.1" | ||
authors = ["Andrea Righi <[email protected]>", "Canonical"] | ||
edition = "2021" | ||
description = "Userspace scheduling with BPF" | ||
license = "GPL-2.0-only" | ||
|
||
[dependencies] | ||
anyhow = "1.0.65" | ||
bitvec = { version = "1.0", features = ["serde"] } | ||
clap = { version = "4.1", features = ["derive", "env", "unicode", "wrap_help"] } | ||
ctrlc = { version = "3.1", features = ["termination"] } | ||
fb_procfs = "0.7.0" | ||
hex = "0.4.3" | ||
libbpf-rs = "0.22.0" | ||
libc = "0.2.137" | ||
log = "0.4.17" | ||
ordered-float = "3.4.0" | ||
scx_utils = { path = "../../../rust/scx_utils", version = "0.4" } | ||
simplelog = "0.12.0" | ||
|
||
[build-dependencies] | ||
scx_utils = { path = "../../../rust/scx_utils", version = "0.4" } | ||
|
||
[features] | ||
enable_backtrace = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This software may be used and distributed according to the terms of the | ||
// GNU General Public License version 2. | ||
|
||
fn main() { | ||
scx_utils::BpfBuilder::new() | ||
.unwrap() | ||
.enable_intf("src/bpf/intf.h", "bpf_intf.rs") | ||
.enable_skel("src/bpf/main.bpf.c", "bpf") | ||
.build() | ||
.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
custom_target('scx_rustlite', | ||
output: '@PLAINNAME@.__PHONY__', | ||
input: 'Cargo.toml', | ||
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@', | ||
cargo_build_args], | ||
env: cargo_env, | ||
build_by_default: true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Get help on options with `rustfmt --help=config` | ||
# Please keep these in alphabetical order. | ||
edition = "2021" | ||
group_imports = "StdExternalCrate" | ||
imports_granularity = "Item" | ||
merge_derives = false | ||
use_field_init_shorthand = true | ||
version = "Two" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// This software may be used and distributed according to the terms of the | ||
// GNU General Public License version 2. | ||
|
||
#ifndef __INTF_H | ||
#define __INTF_H | ||
|
||
#define MAX(x, y) ((x) > (y) ? (x) : (y)) | ||
#define MIN(x, y) ((x) < (y) ? (x) : (y)) | ||
|
||
#include <stdbool.h> | ||
#ifndef __kptr | ||
#ifdef __KERNEL__ | ||
#error "__kptr_ref not defined in the kernel" | ||
#endif | ||
#define __kptr | ||
#endif | ||
|
||
#ifndef __KERNEL__ | ||
typedef unsigned char u8; | ||
typedef unsigned int u32; | ||
typedef int s32; | ||
typedef unsigned long long u64; | ||
typedef long long s64; | ||
#endif | ||
|
||
#include <scx/ravg.bpf.h> | ||
|
||
struct task_ctx { | ||
s32 pid; | ||
u64 vtime; | ||
}; | ||
|
||
#endif /* __INTF_H */ |
Oops, something went wrong.