-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from arighi/scx-rustlite
scx_rustlite: simple vtime-based scheduler written in Rust
- Loading branch information
Showing
12 changed files
with
1,107 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,55 @@ | ||
// 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)) | ||
|
||
#define NSEC_PER_SEC 1000000000L | ||
#define CLOCK_BOOTTIME 7 | ||
|
||
#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 | ||
|
||
/* | ||
* Task sent to the user-space scheduler by the BPF dispatcher. | ||
* | ||
* All attributes are collected from the kernel by the the BPF component. | ||
*/ | ||
struct queued_task_ctx { | ||
s32 pid; | ||
u64 sum_exec_runtime; /* Total cpu time */ | ||
u64 weight; /* Task static priority */ | ||
}; | ||
|
||
/* | ||
* Task sent to the BPF dispatcher by the user-space scheduler. | ||
* | ||
* This structure has a payload that can be used by the user-space scheduler to | ||
* send debugging information to the BPF dispatcher (i.e., vruntime, etc.), | ||
* depending on the particular scheduler implementation. | ||
* | ||
* This struct can be easily extended to send more information to the | ||
* dispatcher (i.e., a target CPU, a variable time slice, etc.). | ||
*/ | ||
struct dispatched_task_ctx { | ||
s32 pid; | ||
u64 payload; /* Task payload */ | ||
}; | ||
|
||
#endif /* __INTF_H */ |
Oops, something went wrong.