Skip to contentSkip to conversation

sched_ext: Add comprehensive selftests

PATCH New dongwanqiang 2 participants 2 messages Jan 13 – Jan 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched_ext: Add comprehensive selftests

This patch series adds three new selftests to sched_ext to improve test coverage for previously untested code paths:

1. dsq_operations: Tests DSQ operations and concurrent access patterns
- DSQ creation and attachment
- Concurrent DSQ operations from multiple threads
- Task insertion and movement operations
- Boundary condition handling

2. concurrent_pressure: Tests scheduler behavior under high concurrency
- High-frequency scheduling operations
- Multiple worker threads (8 threads, 50 tasks each)
- 5-second pressure test duration
- Operation counting and statistics

3. error_handling: Tests error handling and boundary conditions
- Invalid task handling
- Invalid CPU ID validation
- Invalid weight value detection
- Null pointer handling
- Boundary value verification

These tests cover the following sched_ext ops callbacks:
- enqueue, dispatch, running, stopping
- update_idle, set_weight, set_cpumask, yield
- init, exit

The tests help ensure the scheduler behaves correctly under various conditions and improve overall code quality.

---
 tools/testing/selftests/sched_ext/Makefile    |   3 +
 .../sched_ext/concurrent_pressure.bpf.c       | 182 ++++++++++++
 .../selftests/sched_ext/concurrent_pressure.c | 139 +++++++++
 .../selftests/sched_ext/dsq_operations.bpf.c  | 200 +++++++++++++
 .../selftests/sched_ext/dsq_operations.c      | 103 +++++++
 .../selftests/sched_ext/error_handling.bpf.c  | 264 ++++++++++++++++++
 .../selftests/sched_ext/error_handling.c      |  90 ++++++
 7 files changed, 981 insertions(+)
 create mode 100644 tools/testing/selftests/sched_ext/concurrent_pressure.bpf.c
 create mode 100644 tools/testing/selftests/sched_ext/concurrent_pressure.c
 create mode 100644 tools/testing/selftests/sched_ext/dsq_operations.bpf.c
 create mode 100644 tools/testing/selftests/sched_ext/dsq_operations.c
 create mode 100644 tools/testing/selftests/sched_ext/error_handling.bpf.c
 create mode 100644 tools/testing/selftests/sched_ext/error_handling.c
tools/testing/selftests/sched_ext/Makefile +3 -0
index 011762224600..523be57b6cf6 100644
@@ -181,6 +181,9 @@ auto-test-targets :=			\
 	select_cpu_dispatch_dbl_dsp	\
 	select_cpu_vtime		\
 	test_example			\
+	dsq_operations			\
+	concurrent_pressure		\
+	error_handling			\
 
 testcase-targets := $(addsuffix .o,$(addprefix $(SCXOBJ_DIR)/,$(auto-test-targets)))
 
tools/testing/selftests/sched_ext/concurrent_pressure.bpf.c new file +182 -0

183 lines not on this page · raw message

tools/testing/selftests/sched_ext/concurrent_pressure.c new file +139 -0

140 lines not on this page · raw message

tools/testing/selftests/sched_ext/dsq_operations.bpf.c new file +200 -0

201 lines not on this page · raw message

tools/testing/selftests/sched_ext/dsq_operations.c new file +103 -0

104 lines not on this page · raw message

tools/testing/selftests/sched_ext/error_handling.bpf.c new file +264 -0

265 lines not on this page · raw message

tools/testing/selftests/sched_ext/error_handling.c new file +90 -0

91 lines not on this page · raw message

Signature · 1 line
2.52.0
#1 lore raw
we apply this patch upon 86063a2568b8f2 like below:

hi, dongwanqiang,

we apply this patch upon 86063a2568b8f2 like below:

* c3c5a73eb6ed69 (linux-review/dongwanqiang/sched_ext-Add-comprehensive-selftests/20260113-164727) sched_ext: Add comprehensive selftests
* 86063a2568b8f2 (shuah-kselftest/next) selftests/resctrl: Fix non-contiguous CBM check for Hygon

if we should pick another base or the patch depends on other patches, please kindly let us know. thanks

below is just FYI.

Hello,

kernel test robot noticed "kernel-selftests-bpf.sched_ext.make.fail" on:

commit: c3c5a73eb6ed699262df440942d88f23cc9f10e9 ("[PATCH v1] sched_ext: Add comprehensive selftests")
url: https://github.com/intel-lab-lkp/linux/commits/dongwanqiang/sched_ext-Add-comprehensive-selftests/20260113-164727
base: https://git.kernel.org/cgit/linux/kernel/git/shuah/linux-kselftest.git next
patch link: https://lore.kernel.org/all/[email protected]/
patch subject: [PATCH v1] sched_ext: Add comprehensive selftests

in testcase: kernel-selftests-bpf
version:
with following parameters:

group: sched_ext

config: x86_64-rhel-9.4-bpf
compiler: gcc-14
test machine: 8 threads 1 sockets Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (Kaby Lake) with 32G memory

(please refer to attached dmesg/kmsg for entire log/backtrace)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-lkp/[email protected]

CLNG-BPF ddsp_bogus_dsq_fail.bpf.o
/usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/testing/selftests/sched_ext/build/include/vmlinux.h:89012:2: warning: declaration does not declare anything [-Wmissing-declarations]

 89012 |         struct freelist_tid;
       |         ^~~~~~~~~~~~~~~~~~~

concurrent_pressure.bpf.c:104:24: error: use of undeclared identifier 'nr_cpu_ids'
104 | if (cpu < 0 || cpu >= nr_cpu_ids) {
| ^
concurrent_pressure.bpf.c:164:3: error: call to undeclared function 'scx_bpf_print'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

  164 |                 scx_bpf_print("Pressure test completed: %llu total operations\n", 
      |                 ^

concurrent_pressure.bpf.c:164:3: note: did you mean 'scx_bpf_events'? /usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/sched_ext/include/scx/common.bpf.h:103:6: note: 'scx_bpf_events' declared here
103 | void scx_bpf_events(struct scx_event_stats *events, size_t events__sz) __ksym __weak;
| ^
/usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/testing/selftests/sched_ext/build/include/vmlinux.h:108246:2: warning: declaration does not declare anything [-Wmissing-declarations]

 108246 |         union pipe_index;
        |         ^~~~~~~~~~~~~~~~
4 warnings and 2 errors generated.
/usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/testing/selftests/sched_ext/build/include/vmlinux.h:120240:4: warning: declaration does not declare anything [-Wmissing-declarations]
 120240 |                         struct freelist_counters;
        |                         ^~~~~~~~~~~~~~~~~~~~~~~~

make: *** [Makefile:136: /usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/testing/selftests/sched_ext/build/obj/sched_ext/concurrent_pressure.bpf.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from ddsp_bogus_dsq_fail.bpf.c:7:
In file included from /usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/sched_ext/include/scx/common.bpf.h:21:
/usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/testing/selftests/sched_ext/build/include/vmlinux.h:52185:3: warning: declaration does not declare anything [-Wmissing-declarations]

 52185 |                 struct ns_tree;
       |                 ^~~~~~~~~~~~~~
4 warnings generated.
/usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/testing/selftests/sched_ext/build/include/vmlinux.h:89012:2: warning: declaration does not declare anything [-Wmissing-declarations]
 89012 |         struct freelist_tid;
       |         ^~~~~~~~~~~~~~~~~~~
/usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/testing/selftests/sched_ext/build/include/vmlinux.h:108246:2: warning: declaration does not declare anything [-Wmissing-declarations]
 108246 |         union pipe_index;
        |         ^~~~~~~~~~~~~~~~
/usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/testing/selftests/sched_ext/build/include/vmlinux.h:120240:4: warning: declaration does not declare anything [-Wmissing-declarations]
 120240 |                         struct freelist_counters;
        |                         ^~~~~~~~~~~~~~~~~~~~~~~~

4 warnings generated.
make: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-9.4-bpf-c3c5a73eb6ed699262df440942d88f23cc9f10e9/tools/testing/selftests/sched_ext'

The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20260116/[email protected]

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki