Skip to content

sched_ext: selftest infrastructure fixes

Tao Cui sched-ext 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 1 replyIn review
  2. v15 patches 2 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6selftests/sched_ext: Fix reload_loop error-path use-after-freetools/testing/selftests/sched_ext/reload_loop.c+5 -10 replies
2/6sched_ext: Add SCX_ECODE_RSN_CGROUP_OFFLINE to user_exit_info.htools/sched_ext/include/scx/user_exit_info.h+1 -00 replies
3/6selftests/sched_ext: Fail loudly when EXIT_KIND is missing from BTFtools/testing/selftests/sched_ext/allowed_cpus.c tools/testing/selftests/sched_ext/cgroup_nr_cpus.c tools/testing/selftests/sched_ext/cyclic_kick_wait.c +4 more+28 -160 replies
4/6selftests/sched_ext: Add SCX_ASSERT_ALIVE and adopt ittools/testing/selftests/sched_ext/create_dsq.bpf.c tools/testing/selftests/sched_ext/create_dsq.c tools/testing/selftests/sched_ext/init_enable_count.bpf.c +4 more+56 -10 replies
5/6selftests/sched_ext: Bound exit waitstools/testing/selftests/sched_ext/exit.c tools/testing/selftests/sched_ext/hotplug.c tools/testing/selftests/sched_ext/prog_run.c +1 more+36 -80 replies
6/6selftests/sched_ext: Report reload_loop attach failurestools/testing/selftests/sched_ext/reload_loop.c+36 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/6] sched_ext: selftest infrastructure fixes

From: Tao Cui <[email protected]>

The sched_ext selftests pass vacuously or hang in several failure
scenarios: a scheduler that dies mid-test freezes the state the test asserts on, EXIT_KIND() silently maps missing BTF enumerators to SCX_EXIT_NONE, waits for scheduler exit are unbounded, attach failures in the reload stress test are swallowed, and an error path in reload_loop destroys the skeleton under a still-running thread.

This is v2 of the series posted as [1]; it applies the review feedback from Tejun (and the sashiko bot findings, which overlapped):

- P1: use SCX_FAIL() inside the error branch.
- P2: name ebeca1f930ea in the description (and fix the wrong attribution the v1 description carried).
- P3: the v1 premise was wrong - struct scx_exit_info carries the enum, so the BTF always has the type and the enumerators the tests use exist on all sched_ext kernels. The patch is kept but
reshaped: EXIT_KIND() is now an alias of SCX_KIND_VAL() (single implementation), the remaining kind != EXIT_KIND(SCX_EXIT_NONE) sites are converted to UEI_EXITED(), invalid_one() resolves error_kind before spawning the gated worker, and the v1 <unistd.h> include is not needed here.
- P4: SCX_ASSERT_ALIVE() prints uei.msg too.
- P5: split in two. exit.c now destroys the link and the skeleton on its timeout path (a scheduler stuck unexited no longer stays attached and makes every later test fail with EBUSY); reload_loop drops its dead reporting arm and the always-on EBUSY printf, and the failure bar is now "at least one successful attach per thread". The two #defines became an enum and stray blank lines after setup() are gone.

Base: tj/sched_ext for-next at 8ef2c4fe917a ("Merge branch 'for-7.3-fixes' into for-next"), rebased after the review round. v1 was based on the then-tip f55a5ae74ca6; the rebase is a pure replay (the only selftest-side upstream change in between is a dequeue_remote.c build fix outside the files touched here).

Testing: full sched_ext selftest suite (QEMU/KVM x86_64, 4 vcpus, serial console) on a kernel built from this base: a runner built from this series and a runner built from the plain base pass identically, 38 passed / 2 skipped / 0 failed each (the skips are
environment-dependent: enq_blocked requires PROXY_EXEC and nohz_tick requires NOHZ_FULL; kick_coalesce passes since the base kernel has lazy preemption). On top of that, A/B checks: a scheduler whose exit point never fires wedges a pre-series runner forever in exit's unbounded wait, while with patch 5 the runner reports "Timed out waiting for scheduler to exit" after ~10s, destroys the link and the skeleton, and every subsequent test still attaches and passes (the stuck A/B ran on the f55a5ae74ca6 pre-rebase base with identical series content; the remaining A/Bs were run the same way on the v1 base and their code paths are unchanged here); a synthetic BTF without the SCX_EXIT_UNREG_BPF enumerator fails loudly with patch 3 and passes silently without it; an injected scheduler death reports kind, exit code and uei.msg through SCX_ASSERT_ALIVE(); under reload stress with in-flight teardown, patch 6 classifies the observed 1125-1233 EBUSY failures and passes as long as each thread completed at least one attach.

[1] https://lore.kernel.org/all/[email protected]/

Tao Cui (6):
selftests/sched_ext: Fix reload_loop error-path use-after-free
sched_ext: Add SCX_ECODE_RSN_CGROUP_OFFLINE to user_exit_info.h selftests/sched_ext: Fail loudly when EXIT_KIND is missing from BTF selftests/sched_ext: Add SCX_ASSERT_ALIVE and adopt it selftests/sched_ext: Bound exit waits selftests/sched_ext: Report reload_loop attach failures

 tools/sched_ext/include/scx/user_exit_info.h  |  1 +
 .../selftests/sched_ext/allowed_cpus.c        |  2 +-
 .../selftests/sched_ext/cgroup_nr_cpus.c      |  2 +-
 .../selftests/sched_ext/create_dsq.bpf.c      |  8 +++
 .../testing/selftests/sched_ext/create_dsq.c  |  2 +
 .../selftests/sched_ext/cyclic_kick_wait.c    |  2 +-
 .../testing/selftests/sched_ext/enq_blocked.c |  2 +-
 tools/testing/selftests/sched_ext/exit.c      |  8 ++-
 tools/testing/selftests/sched_ext/hotplug.c   | 12 ++--
 .../sched_ext/init_enable_count.bpf.c         |  8 +++
 .../selftests/sched_ext/init_enable_count.c   | 13 +++++
 tools/testing/selftests/sched_ext/kick.c      |  8 ++-
 .../testing/selftests/sched_ext/maximal.bpf.c |  6 +-
 tools/testing/selftests/sched_ext/maximal.c   |  2 +
 tools/testing/selftests/sched_ext/nohz_tick.c |  6 +-
 tools/testing/selftests/sched_ext/prog_run.c  |  7 ++-
 .../testing/selftests/sched_ext/reload_loop.c | 49 +++++++++++++---
 tools/testing/selftests/sched_ext/scx_test.h  | 57 +++++++++++++++++--
 18 files changed, 162 insertions(+), 33 deletions(-)
Signature · 1 line
2.53.0