Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scx: Fix exit selftest to use custom DSQ

In commit 63fb3ec80516 ("sched_ext: Allow only user DSQs for
scx_bpf_consume(), scx_bpf_dsq_nr_queued() and bpf_iter_scx_dsq_new()"), we
updated the consume path to only accept user DSQs, thus making it invalid
to consume SCX_DSQ_GLOBAL. This selftest was doing that, so let's create a
custom DSQ and use that instead. The test now passes:

[root@virtme-ng sched_ext]# ./runner -t exit
===== START =====
TEST: exit
DESCRIPTION: Verify we can cleanly exit a scheduler in multiple places
OUTPUT:
[ 12.387229] sched_ext: BPF scheduler "exit" enabled
[ 12.406064] sched_ext: BPF scheduler "exit" disabled (unregistered from BPF)
[ 12.453325] sched_ext: BPF scheduler "exit" enabled
[ 12.474064] sched_ext: BPF scheduler "exit" disabled (unregistered from BPF)
[ 12.515241] sched_ext: BPF scheduler "exit" enabled
[ 12.532064] sched_ext: BPF scheduler "exit" disabled (unregistered from BPF)
[ 12.592063] sched_ext: BPF scheduler "exit" disabled (unregistered from BPF)
[ 12.654063] sched_ext: BPF scheduler "exit" disabled (unregistered from BPF)
[ 12.715062] sched_ext: BPF scheduler "exit" disabled (unregistered from BPF)
ok 1 exit #
===== END =====

Signed-off-by: David Vernet <void@manifault.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

David Vernet and committed by
Tejun Heo
895669fd 4f7f4170

+5 -3
+5 -3
tools/testing/selftests/sched_ext/exit.bpf.c
··· 15 15 16 16 #define EXIT_CLEANLY() scx_bpf_exit(exit_point, "%d", exit_point) 17 17 18 + #define DSQ_ID 0 19 + 18 20 s32 BPF_STRUCT_OPS(exit_select_cpu, struct task_struct *p, 19 21 s32 prev_cpu, u64 wake_flags) 20 22 { ··· 33 31 if (exit_point == EXIT_ENQUEUE) 34 32 EXIT_CLEANLY(); 35 33 36 - scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 34 + scx_bpf_dispatch(p, DSQ_ID, SCX_SLICE_DFL, enq_flags); 37 35 } 38 36 39 37 void BPF_STRUCT_OPS(exit_dispatch, s32 cpu, struct task_struct *p) ··· 41 39 if (exit_point == EXIT_DISPATCH) 42 40 EXIT_CLEANLY(); 43 41 44 - scx_bpf_consume(SCX_DSQ_GLOBAL); 42 + scx_bpf_consume(DSQ_ID); 45 43 } 46 44 47 45 void BPF_STRUCT_OPS(exit_enable, struct task_struct *p) ··· 69 67 if (exit_point == EXIT_INIT) 70 68 EXIT_CLEANLY(); 71 69 72 - return 0; 70 + return scx_bpf_create_dsq(DSQ_ID, -1); 73 71 } 74 72 75 73 SEC(".struct_ops.link")