-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A scheduler that focuses on ensuring fairness among tasks and performance predictability. It operates using a vruntime-based policy, where each task is assigned a "latency" weight. This weight is dynamically adjusted based on how often a task release the CPU before its full time slice is used. Tasks that release the CPU early are given a higher latency weight, prioritizing them over tasks that fully consume their time slice. The combination of dynamic latency weights and vruntime-based scheduling ensures responsive and consistent performance, even in overcommitted systems. This makes the scheduler particularly well-suited for workloads that require multimedia or real-time audio processing. Signed-off-by: Andrea Righi <[email protected]>
- Loading branch information
Showing
17 changed files
with
1,387 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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,26 @@ | ||
[package] | ||
name = "scx_fair" | ||
version = "1.0.4" | ||
authors = ["Andrea Righi <[email protected]>"] | ||
edition = "2021" | ||
description = "A scheduler designed for multimedia and real-time audio processing workloads. https://github.com/sched-ext/scx/tree/main" | ||
license = "GPL-2.0-only" | ||
|
||
[dependencies] | ||
anyhow = "1.0.65" | ||
ctrlc = { version = "3.1", features = ["termination"] } | ||
clap = { version = "4.1", features = ["derive", "env", "unicode", "wrap_help"] } | ||
crossbeam = "0.8.4" | ||
libbpf-rs = "0.24.1" | ||
log = "0.4.17" | ||
scx_stats = { path = "../../../rust/scx_stats", version = "1.0.4" } | ||
scx_stats_derive = { path = "../../../rust/scx_stats/scx_stats_derive", version = "1.0.4" } | ||
scx_utils = { path = "../../../rust/scx_utils", version = "1.0.4" } | ||
serde = { version = "1.0", features = ["derive"] } | ||
simplelog = "0.12" | ||
|
||
[build-dependencies] | ||
scx_utils = { path = "../../../rust/scx_utils", version = "1.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,26 @@ | ||
# scx_fair | ||
|
||
This is a single user-defined scheduler used within [sched_ext](https://github.com/sched-ext/scx/tree/main), which is a Linux kernel feature which enables implementing kernel thread schedulers in BPF and dynamically loading them. [Read more about sched_ext](https://github.com/sched-ext/scx/tree/main). | ||
|
||
## Overview | ||
|
||
A scheduler that focuses on ensuring fairness among tasks and performance | ||
predictability. | ||
|
||
It operates using a vruntime-based policy, where each task is assigned a | ||
"latency" weight. This weight is dynamically adjusted based on how often a task | ||
release the CPU before its full time slice is used. Tasks that release the CPU | ||
early are given a higher latency weight, prioritizing them over tasks that | ||
fully consume their time slice. | ||
|
||
## Typical Use Case | ||
|
||
The combination of dynamic latency weights and vruntime-based scheduling | ||
ensures responsive and consistent performance, even in overcommitted systems. | ||
|
||
This makes the scheduler particularly well-suited for workloads that require | ||
multimedia or real-time audio processing. | ||
|
||
## Production Ready? | ||
|
||
Yes. |
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,13 @@ | ||
// Copyright (c) Andrea Righi <[email protected]> | ||
// | ||
// 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,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,42 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* Copyright (c) 2024 Andrea Righi <[email protected]> | ||
* | ||
* 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 | ||
|
||
#include <limits.h> | ||
|
||
#define MAX(x, y) ((x) > (y) ? (x) : (y)) | ||
#define MIN(x, y) ((x) < (y) ? (x) : (y)) | ||
#define CLAMP(val, lo, hi) MIN(MAX(val, lo), hi) | ||
|
||
enum consts { | ||
NSEC_PER_USEC = 1000ULL, | ||
NSEC_PER_MSEC = (1000ULL * NSEC_PER_USEC), | ||
NSEC_PER_SEC = (1000ULL * NSEC_PER_MSEC), | ||
}; | ||
|
||
#ifndef __VMLINUX_H__ | ||
typedef unsigned char u8; | ||
typedef unsigned short u16; | ||
typedef unsigned int u32; | ||
typedef unsigned long u64; | ||
|
||
typedef signed char s8; | ||
typedef signed short s16; | ||
typedef signed int s32; | ||
typedef signed long s64; | ||
|
||
typedef int pid_t; | ||
#endif /* __VMLINUX_H__ */ | ||
|
||
struct domain_arg { | ||
s32 cpu_id; | ||
s32 sibling_cpu_id; | ||
}; | ||
|
||
#endif /* __INTF_H */ |
Oops, something went wrong.