Skip to content

Commit

Permalink
[Features][CustomSched][BPFLib]
Browse files Browse the repository at this point in the history
    * Custom Scheduling
    * Capturing cgroup stats on per invoke level
    * BPFLibrary to create a pinned BPFMap of function characteristics
      * used to share data with scx scheduler

clippy changes
  • Loading branch information
abrehman94 authored and Abdul Rehman committed Oct 17, 2024
1 parent ba8fb72 commit 939b86b
Show file tree
Hide file tree
Showing 77 changed files with 4,188 additions and 94 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ __pycache__/*.lock
**.lock
**__pycache__**
.idea/
.vscode/
.vscode/
**.swp
4 changes: 2 additions & 2 deletions src/Ilúvatar/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ iluvatar_worker/src/worker.dev*json
iluvatar_worker_library/tests/resources/worker.dev*json
iluvatar_controller/src/controller.dev*json
target/
**.swp
.vscode/
**.sw*
.vscode/
4 changes: 3 additions & 1 deletion src/Ilúvatar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ members = [
"iluvatar_library",
"iluvatar_worker_library",
"iluvatar_energy_mon",
"iluvatar_rpc"
"iluvatar_rpc",
"iluvatar_bpf_library",
"fs_policy_tsksz",
]
resolver = "2"

Expand Down
6 changes: 5 additions & 1 deletion src/Ilúvatar/Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ passthrough = ["ARCH=amd64", "GO_VERSION=1.22.0", "CNI_VERSION=v1.1.1", "GOPATH=
default-target = "x86_64-unknown-linux-gnu" # use this target if none is explicitly provided
pre-build = [ # additional commands to run prior to building the package
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get --assume-yes install protobuf-compiler iproute2 wget curl runc bridge-utils iptables net-tools sysstat"
"apt-get update && apt-get --assume-yes install protobuf-compiler iproute2 wget curl runc bridge-utils iptables net-tools sysstat libelf-dev lsb-release wget software-properties-common gnupg",
"wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh all && ln -s /usr/bin/ld.lld-18 /usr/bin/ld.lld && ln -s /usr/bin/clang-18 /usr/bin/clang && ln -s /usr/bin/clang++-18 /usr/bin/clang++ && rm llvm.sh"
]



9 changes: 6 additions & 3 deletions src/Ilúvatar/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
CROSS_FLAGS=CROSS_CONTAINER_UID=0 CROSS_CONTAINER_GID=0 CROSS_ROOTLESS_CONTAINER_ENGINE=false CROSS_CONTAINER_USER_NAMESPACE=none CROSS_CONTAINER_OPTS=--privileged
RUST_FLAGS=-Dwarnings
#RUST_FLAGS=-Dwarnings
# Jetson platform
# TARGET_PLAT=aarch64-unknown-linux-gnu
TARGET_PLAT?=x86_64-unknown-linux-gnu
Expand All @@ -12,7 +12,7 @@ endif
RUST_C?=cross
DEBUG_FLAGS=--all-targets $(TARGET) -j $(NPROCS)
RELEASE_FLAGS=--lib --bins $(TARGET) -j $(NPROCS) --release
CARGO_ARGS?=""
CARGO_ARGS?=

default: debug

Expand All @@ -37,6 +37,9 @@ tiny:
debug:
@echo "Building debug"
@RUSTFLAGS=$(RUST_FLAGS) $(RUST_C) build $(DEBUG_FLAGS) $(CARGO_ARGS)
fix:
@echo "Fixing lint errors"
@RUSTFLAGS=$(RUST_FLAGS) $(RUST_C) fix $(DEBUG_FLAGS) $(CARGO_ARGS)
spans:
@echo "Building full_spans"
@RUSTFLAGS=$(RUST_FLAGS) $(RUST_C) build --features full_spans $(RELEASE_FLAGS) $(CARGO_ARGS)
Expand All @@ -55,4 +58,4 @@ format:
format-check:
@cargo fmt --all -- --check
clippy:
@RUSTFLAGS=$(RUST_FLAGS) $(RUST_C) clippy --workspace --examples --benches --no-deps -- -Dclippy::suspicious -Dclippy::correctness -Dclippy::perf -Aclippy::single_match -Aclippy::new_without_default -Aclippy::too_many_arguments -Aclippy::type-complexity -Dclippy::from_over_into -Aclippy::redundant-field-names -Dwarnings
@RUSTFLAGS=$(RUST_FLAGS) $(RUST_C) clippy --fix --allow-no-vcs --workspace --examples --benches --no-deps -- -Dclippy::suspicious -Dclippy::correctness -Dclippy::perf -Aclippy::single_match -Aclippy::new_without_default -Aclippy::too_many_arguments -Aclippy::type-complexity -Dclippy::from_over_into -Aclippy::redundant-field-names -Dwarnings
8 changes: 8 additions & 0 deletions src/Ilúvatar/ansible/worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@
remote_src: "{{__remote_bin_src}}"
become: yes

- name: copy fs_policy_tsksz
ansible.builtin.copy:
src: "{{__bin_src}}/fs_policy_tsksz"
dest: "{{bin_dir}}/"
mode: "preserve"
remote_src: "{{__remote_bin_src}}"
become: yes

- name: copy worker config
ansible.builtin.copy:
src: "{{__bin_src}}/{{worker.config_name}}"
Expand Down
Empty file.
33 changes: 33 additions & 0 deletions src/Ilúvatar/fs_policy_tsksz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "fs_policy_tsksz"
version = "0.0.3"
authors = ["Abdul Rehman <abdulrehmanee010@gmail.com>"]
edition = "2021"
description = "A simple scheduler that preserves locality for a function cgroup"
license = "GPL-2.0-only"

[dependencies]
anyhow = "1.0.65"
plain = "0.2.3"
ctrlc = { version = "3.1", features = ["termination"] }
libbpf-rs = "0.24.1"
libc = "0.2.137"
scx_utils = { version = "1.0.3" }
scx_rustland_core = { version = "1.0.3" }

# Specific to iluvatar
iluvatar_library = { path = "../iluvatar_library" }
iluvatar_worker_library = { path = "../iluvatar_worker_library" }
clap = { version = "4.5.4", features = ["derive"] }
ipc-channel = { version = "0.18.1", features = ["memfd"] }
serde = { version = "1.0" }

[build-dependencies]
scx_utils = { version = "1.0.3" }
scx_rustland_core = { version = "1.0.3" }

[features]
enable_backtrace = []



1 change: 1 addition & 0 deletions src/Ilúvatar/fs_policy_tsksz/LICENSE
20 changes: 20 additions & 0 deletions src/Ilúvatar/fs_policy_tsksz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# scx_rlfifo

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

scx_rlfifo is a simple FIFO scheduler runs in user-space, based on the
scx_rustland_core framework.

## Typical Use Case

This scheduler is provided as a simple template that can be used as a baseline
to test more complex scheduling policies.

## Production Ready?

Definitely not. Using this scheduler in a production environment is not
recommended, unless there are specific requirements that necessitate a basic
FIFO scheduling approach. Even then, it's still recommended to use the kernel's
SCHED_FIFO real-time class.
11 changes: 11 additions & 0 deletions src/Ilúvatar/fs_policy_tsksz/build.rs
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();
}
14 changes: 14 additions & 0 deletions src/Ilúvatar/fs_policy_tsksz/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if serialize
sched_deps = [libbpf, bpftool_target, sched]
else
sched_deps = [libbpf, bpftool_target]
endif

sched = custom_target('scx_rlfifo',
output: '@PLAINNAME@.__PHONY__',
input: 'Cargo.toml',
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
cargo_build_args],
env: cargo_env,
depends: sched_deps,
build_always_stale: true)
8 changes: 8 additions & 0 deletions src/Ilúvatar/fs_policy_tsksz/rustfmt.toml
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"
Loading

0 comments on commit 939b86b

Please sign in to comment.