sched_ext/selftests: Add bypass mode operational test
Subsystems (2)
PATCH 4/5 sched_ext/selftests: Add bypass mode operational test
From: Su Zhidao <[email protected]>
Add a test that verifies the sched_ext bypass mechanism does not prevent tasks from running to completion.
The test attaches a minimal global FIFO scheduler, spawns worker processes that complete a fixed computation, detaches the scheduler (which triggers bypass mode while workers are still active), and verifies all workers complete successfully under bypass mode.
This exercises the scheduler attach/detach lifecycle and verifies that bypass mode (activated during unregistration to guarantee forward progress) does not stall running tasks.
Signed-off-by Su Zhidao <[email protected]>
--- tools/testing/selftests/sched_ext/Makefile | 1 + .../testing/selftests/sched_ext/bypass.bpf.c | 32 ++++++ tools/testing/selftests/sched_ext/bypass.c | 105 ++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 tools/testing/selftests/sched_ext/bypass.bpf.c create mode 100644 tools/testing/selftests/sched_ext/bypass.c
tools/testing/selftests/sched_ext/Makefile +1 -0
@@ -162,6 +162,7 @@ endef all_test_bpfprogs := $(foreach prog,$(wildcard *.bpf.c),$(INCLUDE_DIR)/$(patsubst %.c,%.skel.h,$(prog))) auto-test-targets := \ + bypass \ create_dsq \ dequeue \ enq_last_no_enq_fails \
tools/testing/selftests/sched_ext/bypass.bpf.c new file +32 -0
@@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* BPF scheduler for bypass mode operational test. +* +* Implements a minimal global FIFO scheduler. The userspace side +* attaches this scheduler, runs worker tasks to completion, and +* verifies that tasks complete successfully. +* +* Copyright (c) 2026 Xiaomi Corporation. +*/ +#include <scx/common.bpf.h> + +char _license[] SEC("license") = "GPL"; + +UEI_DEFINE (uei); + +void BPF_STRUCT_OPS (bypass_enqueue ,struct task_struct *p,u64 enq_flags) +{ +scx_bpf_dsq_insert (p,SCX_DSQ_GLOBAL ,SCX_SLICE_DFL , enq_flags); +} + +void BPF_STRUCT_OPS (bypass_exit ,struct scx_exit_info *ei) +{ +UEI_RECORD (uei, ei); +} + +SEC(".struct_ops.link") +struct sched_ext_ops bypass_ops = { + .enqueue = (void *)bypass_enqueue, + .exit = (void *)bypass_exit, + .name ="bypass_test" , +};
tools/testing/selftests/sched_ext/bypass.c new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.43.0