]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched_ext: Add a selftest for scx_bpf_dsq_peek
authorRyan Newton <newton@meta.com>
Wed, 15 Oct 2025 15:50:36 +0000 (11:50 -0400)
committerTejun Heo <tj@kernel.org>
Wed, 15 Oct 2025 16:46:36 +0000 (06:46 -1000)
commit5aff3b319997eb8d0e25b8d2e3b5c88ed07395ac
tree19c6a54bdd4cd6915c3f4b8c92f56c313c21a7e1
parent44f5c8ec5b9ad8ed4ade08d727f803b2bb07f1c3
sched_ext: Add a selftest for scx_bpf_dsq_peek

This commit adds two tests. The first is the most basic unit test:
make sure an empty queue peeks as empty, and when we put one element
in the queue, make sure peek returns that element.

However, even this simple test is a little complicated by the different
behavior of scx_bpf_dsq_insert in different calling contexts:
 - insert is for direct dispatch in enqueue
 - insert is delayed when called from select_cpu

In this case we split the insert and the peek that verifies the
result between enqueue/dispatch.

Note: An alternative would be to call `scx_bpf_dsq_move_to_local` on an
empty queue, which in turn calls `flush_dispatch_buf`, in order to flush
the buffered insert. Unfortunately, this is not viable within the
enqueue path, as it attempts a voluntary context switch within an RCU
read-side critical section.

The second test is a stress test that performs many peeks on all DSQs
and records the observed tasks.

Signed-off-by: Ryan Newton <newton@meta.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
tools/testing/selftests/sched_ext/Makefile
tools/testing/selftests/sched_ext/peek_dsq.bpf.c [new file with mode: 0644]
tools/testing/selftests/sched_ext/peek_dsq.c [new file with mode: 0644]