Skip to content

Commit

Permalink
ci: use virtme-ng to test the schedulers
Browse files Browse the repository at this point in the history
Use virtme-ng to run the schedulers after they're built; virtme-ng
allows to pick an arbitrary sched-ext enabled kernel and run it
virtualizing the entire user-space root filesystem, so we can basically
exceute the recompiled schedulers inside such kernel.

This should allow to catch potential run-time issue in advance (both in
the kernel and the schedulers).

The sched-ext kernel is taken from the Ubuntu ppa (ppa:arighi/sched-ext)
at the moment, since it is the easiest / fastest way to get a
precompiled sched-ext kernel to run inside the Ubuntu 22.04 testing
environment.

The schedulers are tested using the new meson target "test_sched", the
specific actions are defined in meson-scripts/test_sched.

By default each test has a timeout of 30 sec, after the virtme-ng
completes the boot (that should be enough to initialize the scheduler
and run the scheduler for some seconds), while the total lifetime of the
virtme-ng guest is set to 60 sec, after this time the guest will be
killed (this allows to catch potential kernel crashes / hangs).

If a single scheduler fails the test, the entire "test_sched" action
will be interrupted and the overall test result will be considered a
failure.

At the moment scx_layered is excluded from the tests, because it
requires a special configuration (we should probably pre-generate a
default config in the workflow actions and change the scheduler to use
the default config if it's executed without any argument).

Moreover, scx_flatcg is also temporarily excluded from the tests,
because of these known issues:
 - sched-ext#49
 - sched-ext/sched_ext#101

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
  • Loading branch information
Andrea Righi committed Dec 29, 2023
1 parent dbc8e23 commit 05f5c69
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 9 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/build-scheds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ jobs:
steps:
### OTHER REPOS ####

# virtme-ng isn't used yet, but let's incorporate installing it in our environment
# as we have plans to use it in the future.
- run: sudo add-apt-repository -y ppa:arighi/virtme-ng
- run: sudo apt update

# Hard turn-off interactive mode
- run: echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections

# Add sched-ext external ppa to get the latest sched-ext kernel
- run: sudo add-apt-repository -n -y ppa:arighi/sched-ext
- run: sudo sed -i s/jammy/noble/ /etc/apt/sources.list.d/arighi-ubuntu-sched-ext-jammy.list

# Refresh packages list
- run: sudo apt update

### DOWNLOAD AND INSTALL DEPENDENCIES ###

# Download dependencies packaged by Ubuntu
- run: sudo apt -y install cmake cargo elfutils libelf-dev libunwind-dev libzstd-dev linux-headers-generic linux-tools-common linux-tools-generic ninja-build virtme-ng
- run: sudo apt -y install coreutils cmake cargo 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

# clang 17
# Use a custom llvm.sh script which includes the -y flag for
Expand Down Expand Up @@ -49,11 +51,19 @@ jobs:
# meson
- run: pip install meson

# Install virtme-ng
- run: pip install virtme-ng

# Download a sched-ext enabled kernel
- run: apt download linux-image-unsigned-6.7.0-3-generic linux-modules-6.7.0-3-generic
- run: mkdir -p kernel
- run: for f in *.deb; do dpkg -x $f kernel; done

### END DEPENDENCIES ###

# The actual build:
- run: meson setup build -Dlibbpf_a=`pwd`/libbpf/src/libbpf.a
- run: meson setup build -Dlibbpf_a=`pwd`/libbpf/src/libbpf.a -Dkernel=$(pwd)/$(ls -c1 kernel/boot/vmlinuz* | tail -1)
- run: meson compile -C build

# TODO: Run the schedulers using virtme-ng (currently blocked on being able
# to use virtme-ng in a Docker container).
# Test schedulers
- run: meson compile -C build test_sched
57 changes: 57 additions & 0 deletions meson-scripts/test_sched
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
#
# Run a scheduler for TIMEOUT seconds inside virtme-ng and catch potential
# errors, then unload the scheduler and return the exit status.

# Maximum time for each scheduler run.
TEST_TIMEOUT=30

# Maximum timeout for the guest used for each scheduler run (this is used to
# hard-shutdown the guest in case of system hangs).
GUEST_TIMEOUT=60

# List of schedulers to test
#
# TODO:
# - scx_layered: temporarily excluded because it
# cannot run with a default configuration
#
SCHEDULERS="scx_simple scx_central scx_flatcg scx_nest scx_pair scx_qmap scx_userland scx_rusty scx_rustland"

if [ ! -x `which vng` ]; then
echo "vng not found, please install virtme-ng to enable testing"
exit 1
fi
if [ $# -lt 1 ]; then
echo "Usage: $0 VMLINUZ"
exit 1
fi
kernel=$1

for sched in ${SCHEDULERS}; do
sched_path=$(find -type f -executable -name ${sched})
if [ ! -n "${sched_path}" ]; then
echo "${sched}: binary not found"
echo "FAIL: ${sched}"
exit 1
fi
echo "testing ${sched_path}"

rm -f /tmp/output
timeout --preserve-status ${GUEST_TIMEOUT} \
vng --force-9p --disable-microvm -v -r ${kernel} -- \
"timeout --foreground --preserve-status ${TEST_TIMEOUT} ${sched_path}" \
2>&1 </dev/null | tee /tmp/output
sed -n -e '/\bBUG:/q1' \
-e '/\bWARNING:/q1' \
-e '/\berror\b/Iq1' \
-e '/\bstall/Iq1' \
-e '/\btimeout\b/Iq1' /tmp/output
res=$?
if [ ${res} -ne 0 ]; then
echo "FAIL: ${sched}"
exit 1
else
echo "OK: ${sched}"
fi
done
8 changes: 8 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ get_sys_incls = find_program(join_paths(meson.current_source_dir(),
'meson-scripts/get_sys_incls'))
cargo_fetch = find_program(join_paths(meson.current_source_dir(),
'meson-scripts/cargo_fetch'))
test_sched = find_program(join_paths(meson.current_source_dir(),
'meson-scripts/test_sched'))

bpf_clang_ver = run_command(get_clang_ver, bpf_clang, check: true).stdout().strip()
bpf_clang_maj = bpf_clang_ver.split('.')[0].to_int()
Expand Down Expand Up @@ -146,6 +148,12 @@ endif

run_target('fetch', command: [cargo_fetch, cargo], env: cargo_env)

if get_option('kernel') != ''
kernel = get_option('kernel')
endif

run_target('test_sched', command: [test_sched, kernel])

if get_option('enable_rust')
subdir('rust')
endif
Expand Down
2 changes: 2 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ option('offline', type: 'boolean', value: 'false',
description: 'Compilation step should not access the internet')
option('enable_rust', type: 'boolean', value: 'true',
description: 'Enable rust sub-projects')
option('kernel', type: 'string', value: 'vmlinuz',
description: 'kernel image used to test schedulers')

0 comments on commit 05f5c69

Please sign in to comment.