Skip to content

Commit

Permalink
add more details to readme and helpers for local development
Browse files Browse the repository at this point in the history
  • Loading branch information
likewhatevs committed Sep 12, 2024
1 parent 773f89c commit d35b596
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/caching-build.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
name: caching-build
on:
# only runs on main, hourly cache update used by all branches
schedule:
- cron: "0 * * * *"
push:

jobs:
build-kernel:
if: (github.ref != 'refs/heads/main') && (github.ref != 'refs/heads/setup-repo')
runs-on: ubuntu-24.04
steps:
# redundancy to exit fast
- run: echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections
- run: sudo apt update
- run: sudo apt install -y git --no-install-recommends
# get latest head commit of sched_ext for-next
- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-next | awk '{print $1}')" >> $GITHUB_ENV

- run: echo "SCHED_EXT_KERNEL_COMMIT=KERNEL_COMMIT_SHA7_HERE" >> $GITHUB_ENV
- uses: actions/checkout@v4

# use cached kernel if available, create after job if not
Expand Down Expand Up @@ -54,7 +52,7 @@ jobs:
name: Clone Kernel
# Get the latest sched-ext enabled kernel directly from the korg
# for-next branch
run: git clone --single-branch -b for-next --depth 1 https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git linux
run: git clone --single-branch -b sched_ext https://github.com/sched-ext/sched_ext.git linux && cd linux && git checkout ${{ env.SCHED_EXT_KERNEL_COMMIT }}

# guard rail because we are caching
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
Expand All @@ -66,18 +64,20 @@ jobs:

- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
# Build a minimal kernel (with sched-ext enabled) using virtme-ng
run: cd linux && vng -v --build --config ../.github/workflows/sched-ext.config
run: cd linux && find . -type f -exec sed -i 's/-Werror/-Wno-error/g' {} \; && vng -v --build --config ../.github/workflows/sched-ext.config

- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
# Generate kernel headers
run: cd linux && make headers

integration-test:
if: (github.ref != 'refs/heads/main') && (github.ref != 'refs/heads/setup-repo')
runs-on: ubuntu-24.04
needs: build-kernel
strategy:
matrix:
scheduler: [ scx_bpfland, scx_lavd, scx_layered, scx_rlfifo, scx_rustland, scx_rusty ]
scheduler: [ scx_layered, scx_rusty ]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install-deps-action
Expand All @@ -93,7 +93,7 @@ jobs:
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

# get latest head commit of sched_ext for-next
- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-next | awk '{print $1}')" >> $GITHUB_ENV
- run: echo "SCHED_EXT_KERNEL_COMMIT=KERNEL_COMMIT_SHA7_HERE" >> $GITHUB_ENV

# use cached kernel if available, create after job if not
- name: Cache Kernel
Expand Down Expand Up @@ -133,6 +133,7 @@ jobs:
- run: meson compile -C build veristat_${{ matrix.scheduler }}

rust-test-core:
if: (github.ref != 'refs/heads/main') && (github.ref != 'refs/heads/setup-repo')
runs-on: ubuntu-24.04
needs: build-kernel
strategy:
Expand All @@ -153,7 +154,7 @@ jobs:
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

# get latest head commit of sched_ext for-next
- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-next | awk '{print $1}')" >> $GITHUB_ENV
- run: echo "SCHED_EXT_KERNEL_COMMIT=KERNEL_COMMIT_SHA7_HERE" >> $GITHUB_ENV
# cache bzImage alone for rust tests
- name: Cache bzImage
id: cache-bzImage
Expand All @@ -178,11 +179,12 @@ jobs:
- run: vng -v --memory 10G --cpu 8 -r linux/arch/x86/boot/bzImage --net user -- cargo test --manifest-path rust/${{ matrix.component }}/Cargo.toml

rust-test-schedulers:
if: (github.ref != 'refs/heads/main') && (github.ref != 'refs/heads/setup-repo')
runs-on: ubuntu-24.04
needs: build-kernel
strategy:
matrix:
scheduler: [ scx_bpfland, scx_lavd, scx_layered, scx_rlfifo, scx_rustland, scx_rusty ]
scheduler: [ scx_layered, scx_rusty ]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install-deps-action
Expand All @@ -198,7 +200,7 @@ jobs:
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

# get latest head commit of sched_ext for-next
- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-next | awk '{print $1}')" >> $GITHUB_ENV
- run: echo "SCHED_EXT_KERNEL_COMMIT=KERNEL_COMMIT_SHA7_HERE" >> $GITHUB_ENV
# cache bzImage alone for rust tests
- name: Cache bzImage
id: cache-bzImage
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ libbpf/
*.gitignore
PKGBUILD
target
local-linux-checkout
.cache

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ on kernels with older versions of the sched-ext source tree.

### Setting up a backport

1) Create a branch named `$SHORT_SHA-vmlinux` , where `$SHORT_SHA` is the first 7 characters of the commit hash in the scx kernel tree you are targeting.
1) Create a branch named `$SHORT_SHA-vmlinux` , where `$SHORT_SHA` is the first 7 characters of the commit hash in the scx kernel tree you are targeting. In this branch, in `.github/workflows/caching-build.yml`, replace KERNEL_COMMIT_SHA7_HERE with the 7 character commit hash of the kernel commit you will be packporting to.

2) Run `backport-scripts/generate-backport-vmlinux.sh` passing it `$SHORT_SHA` (such as `af1234`) and branch name, in that order. Optionally, pass a third
arg, the git repo to obtain that commit and branch from, if neccessary.
2) Run `backport-scripts/generate-backport-vmlinux.sh` passing it `$SHORT_SHA` (such as `af1234`) and branch name, in that order. Optionally, pass a third arg, the git repo to obtain that commit and branch from, if neccessary.

3) Update the symlink `scheds/include/vmlinux/vmlinux.h` to point to your new vmlinux.h.

4) Add a CI badge to this branch on this page.
4) Commit and push your branch.

5) Commit and push your branch.
5) Open a new branch (i.e. `af1234-${SCX_RELEASE}-fixes`) off of your initial branch (i.e. `af1234`)
and edit files other than `vmlinux.h` until first `cargo test` (ran in this repo's root) passes and then CI passes. Edit `.github/workflows/caching-build.yml` as is neccessary to reducing the schedulers built/tested (not everything can be reasonably backported).

6) Open a new branch (i.e. `af1234-${SCX_RELEASE}-fixes`) off of your initial branch (i.e. `af1234`)
and edit files other than `vmlinux.h` until first `cargo test` (ran in this repo's root) passes and then CI passes.
6) Push this branch as you get things working, push it as `af1234-${SCX_RELEASE}-backport` once CI passes.

7) Push this branch as you get things working, push it as `af1234-${SCX_RELEASE}-backport` once CI passes.
7) Add a CI badge on this page on the setup-repo branch for the CI job for that new branch.

### Updating a backport

Expand All @@ -38,3 +37,4 @@ and edit files other than `vmlinux.h` until first `cargo test` (ran in this repo
Please make any updates to this document and the setup scripts on the branch `setup-repo`. This will be rebased atop `main` when merging in updates.

*`main` will be updated periodically (roughly coinciding with releases of scx), backports will be updated/created on an as-needed basis.*
*`main` will be overwritten with commits from upstream during syncs. setup-repo will be rebased upon main and pushed to main before rebasing other branches, so put things to persist across this process on setup-repo.`
16 changes: 16 additions & 0 deletions local-e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -euxo pipefail

SCHED="$1"
REPO_ROOT="$(git rev-parse --show-toplevel)"

cd ./local-linux-checkout || exit 1
vng -v --memory 10G --cpu 8 --build --config "${REPO_ROOT}/.github/workflows/sched-ext.config"
cd $OLDPWD || exit 1
meson setup build -Dkernel=./local-linux-checkout -Dkernel_headers=./local-linux-checkout/usr/include -Denable_stress=true
ln -sf "${REPO_ROOT}/local-linux-checkout" "${REPO_ROOT}/build/local-linux-checkout"
meson compile -C build "$SCHED"
meson compile -C build test_sched_"$SCHED"
meson compile -C build stress_tests_"$SCHED"

0 comments on commit d35b596

Please sign in to comment.