Skip to content

Commit 4e59c90

Browse files
author
Andrea Righi
authored
Merge pull request raspberrypi#116 from arighi/github-ci
ci: add github workflow to test the sched-ext kernel
2 parents 6eb6c92 + 74cdbb0 commit 4e59c90

File tree

4 files changed

+135
-0
lines changed

4 files changed

+135
-0
lines changed

.github/workflows/run-schedulers

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
#
3+
# Run sched-ext scheduler for TIMEOUT seconds inside virtme-ng and catch
4+
# potential errors, then unload the scheduler and return the exit status.
5+
6+
# Maximum time for each scheduler run.
7+
TEST_TIMEOUT=30
8+
9+
# Maximum timeout for the guest used for each scheduler run (this is used to
10+
# hard-shutdown the guest in case of system hangs).
11+
GUEST_TIMEOUT=60
12+
13+
# Check if virtme-ng is available.
14+
if [ ! -x `which vng` ]; then
15+
echo "vng not found, please install virtme-ng to enable testing"
16+
exit 1
17+
fi
18+
19+
# Test all the available schedulers.
20+
#
21+
# NOTE: virtme-ng automatically runs the kernel from the current working
22+
# directory by default.
23+
#
24+
# Each scheduler will be tested in a separate instance booted from scratch, to
25+
# ensure that each run does not impact the others.
26+
#
27+
# TODO: exclude scx_layered for now, because it requires a special config
28+
# file, otherwise its test would fail with "Error: No layer spec".
29+
#
30+
# Maybe in the future change scx_layered to run with a default layer spec, just
31+
# for testing it.
32+
#
33+
for sched in $(find tools/sched_ext/build/bin -type f -executable | grep -v scx_layered); do
34+
rm -f /tmp/output
35+
(timeout --foreground --preserve-status ${GUEST_TIMEOUT} \
36+
vng --force-9p --disable-microvm --verbose -- \
37+
"timeout --foreground --preserve-status ${TEST_TIMEOUT} ${sched}" \
38+
2>&1 </dev/null || true) | tee /tmp/output
39+
sed -n -e '/\bBUG:/q1' \
40+
-e '/\bWARNING:/q1' \
41+
-e '/\berror\b/Iq1' \
42+
-e '/\bstall/Iq1' \
43+
-e '/\btimeout\b/Iq1' /tmp/output
44+
res=$?
45+
if [ ${res} -ne 0 ]; then
46+
echo "FAIL: ${sched}"
47+
exit 1
48+
else
49+
echo "OK: ${sched}"
50+
fi
51+
done

.github/workflows/sched-ext.config

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# sched-ext mandatory options
2+
#
3+
CONFIG_BPF=y
4+
CONFIG_BPF_SYSCALL=y
5+
CONFIG_BPF_JIT=y
6+
CONFIG_DEBUG_INFO_BTF=y
7+
CONFIG_BPF_JIT_ALWAYS_ON=y
8+
CONFIG_BPF_JIT_DEFAULT_ON=y
9+
CONFIG_SCHED_CLASS_EXT=y
10+
11+
# Enable scheduling debugging
12+
#
13+
CONFIG_SCHED_DEBUG=y
14+
15+
# Enable extra scheduling features (for a better code coverage while testing
16+
# the schedulers)
17+
#
18+
CONFIG_SCHED_AUTOGROUP=y
19+
CONFIG_SCHED_CORE=y
20+
21+
# Enable fully preemptible kernel for a better test coverage of the schedulers
22+
#
23+
# CONFIG_PREEMPT_NONE is not set
24+
# CONFIG_PREEMPT_VOLUNTARY is not set
25+
CONFIG_PREEMPT=y
26+
CONFIG_PREEMPT_COUNT=y
27+
CONFIG_PREEMPTION=y
28+
CONFIG_PREEMPT_DYNAMIC=y
29+
CONFIG_PREEMPT_RCU=y
30+
31+
# Additional debugging information (useful to catch potential locking issues)
32+
#
33+
CONFIG_DEBUG_LOCKDEP=y
34+
CONFIG_DEBUG_ATOMIC_SLEEP=y

.github/workflows/test-kernel.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: test-kernel
2+
run-name: ${{ github.actor }} PR run
3+
on: [pull_request, push]
4+
jobs:
5+
test-schedulers:
6+
runs-on: ubuntu-22.04
7+
steps:
8+
### OTHER REPOS ####
9+
10+
# Hard turn-off interactive mode
11+
- run: echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections
12+
13+
# Refresh packages list
14+
- run: sudo apt update
15+
16+
### DOWNLOAD AND INSTALL DEPENDENCIES ###
17+
18+
# Download dependencies packaged by Ubuntu
19+
- run: sudo apt -y install gcc make git coreutils cmake elfutils libelf-dev libunwind-dev libzstd-dev linux-headers-generic linux-tools-common linux-tools-generic ninja-build python3-pip python3-requests qemu-kvm udev iproute2 busybox-static libvirt-clients kbd kmod file rsync zstd pahole flex bison cpio libcap-dev libelf-dev python3-dev cargo rustc
20+
21+
# clang 17
22+
# Use a custom llvm.sh script which includes the -y flag for
23+
# add-apt-repository. Otherwise, the CI job will hang. If and when
24+
# https://github.com/opencollab/llvm-jenkins.debian.net/pull/26 is
25+
# merged, we can go back to using https://apt.llvm.org/llvm.sh.
26+
- run: wget https://raw.githubusercontent.com/Decave/llvm-jenkins.debian.net/fix_llvmsh/llvm.sh
27+
- run: chmod +x llvm.sh
28+
- run: sudo ./llvm.sh all
29+
- run: sudo ln -sf /usr/bin/clang-17 /usr/bin/clang
30+
- run: sudo ln -sf /usr/bin/llvm-strip-17 /usr/bin/llvm-strip
31+
32+
# Checkout repository
33+
- uses: actions/checkout@v4
34+
35+
# Install virtme-ng
36+
- run: pip install virtme-ng
37+
38+
### END DEPENDENCIES ###
39+
40+
# Build a minimal kernel (with sched-ext enabled) using virtme-ng
41+
- run: vng -v --build --config .github/workflows/sched-ext.config
42+
43+
# Build the in-kernel schedulers
44+
- run: cd tools/sched_ext && make
45+
46+
# Test the schedulers inside the recompile kernel
47+
- run: .github/workflows/run-schedulers

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,6 @@ sphinx_*/
169169

170170
# Rust analyzer configuration
171171
/rust-project.json
172+
173+
# Include ".github" directory
174+
!.github/

0 commit comments

Comments
 (0)