-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scx_rustlite: simple vtime-based scheduler written in Rust #38
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, but we probably should move the above boilerplate code into scx_utils.