Re: [PATCH 2/2] selftests/sched_ext: Add cyclic SCX_KICK_WAIT stress test

Cheng-Yang Chou
2026-03-29T09:06:25Z

[-- Attachment #1: Type: text/plain, Size: 1287 bytes --]

Hi Tejun,

On Sat, Mar 28, 2026 at 02:18:56PM -1000, Tejun Heo wrote:
> Add a test that creates a 3-CPU kick_wait cycle (A->B->C->A). A BPF
> scheduler kicks the next CPU in the ring with SCX_KICK_WAIT on every
> enqueue while userspace workers generate continuous scheduling churn via
> sched_yield(). Without the preceding fix, this hangs the machine within seconds.

I think it would be better to skip this test on older, unpatched kernels.
Sometimes I use my local kernel for testing before the stable patches are
fully integrated, so skipping the test would be a safer approach.

Otherwise, this test can stall the machine and make it impossible to
exit the test runner.

Log:

$ sudo ./runner -t cyclic_kick_wait # on v6.14
===== START =====
TEST: cyclic_kick_wait
DESCRIPTION: Verify SCX_KICK_WAIT forward progress under a 3-CPU wait cycle
OUTPUT:
libbpf: struct_ops cyclic_kick_wait_ops: member cgroup_set_bandwidth not found in kernel, skipping it as it's set to zero
libbpf: struct_ops cyclic_kick_wait_ops: member cgroup_set_idle not found in kernel, skipping it as it's set to zero
libbpf: struct_ops cyclic_kick_wait_ops: member priv not found in kernel, skipping it as it's set to zero
ERR: cyclic_kick_wait.c:169
Failed to join worker thread 0 (-110)

Thanks,
Cheng-Yang

[-- Attachment #2: fix.patch --]
[-- Type: text/x-diff, Size: 1648 bytes --]

From 6f09d2298e547aa7a519d4bff262fc6851a969ea Mon Sep 17 00:00:00 2001
From: Cheng-Yang Chou <yphbchou0911@gmail.com>
Date: Sun, 29 Mar 2026 16:07:05 +0800
Subject: [PATCH] selftests/sched_ext: Skip cyclic_kick_wait on kernels without
deadlock fix

The cyclic_kick_wait test triggers a deadlock on kernels lacking the
SCX_KICK_WAIT fix, causing the machine to hang or worker threads to
timeout (-110).

Use __COMPAT_struct_has_field() to probe vmlinux BTF for
rq_scx.kick_sync_pending, a field introduced by the SCX_KICK_WAIT
deadlock fix. Skip the test on older kernels that lack the fix rather
than hanging the machine.

Example failure on unpatched kernels:
ERR: cyclic_kick_wait.c:169
Failed to join worker thread 0 (-110)

Fixes: e9b990b76922 ("selftests/sched_ext: Add cyclic SCX_KICK_WAIT stress test")
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
tools/testing/selftests/sched_ext/cyclic_kick_wait.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/sched_ext/cyclic_kick_wait.c b/tools/testing/selftests/sched_ext/cyclic_kick_wait.c
index c2e5aa9de715..b060ffe63ba3 100644
--- a/tools/testing/selftests/sched_ext/cyclic_kick_wait.c
+++ b/tools/testing/selftests/sched_ext/cyclic_kick_wait.c
@@ -88,6 +88,11 @@ static enum scx_test_status setup(void **ctx)
{
struct cyclic_kick_wait *skel;

+ if (!__COMPAT_struct_has_field("rq_scx", "kick_sync_pending")) {
+ fprintf(stderr, "Skipping test: kernel lacks SCX_KICK_WAIT deadlock fix\n");
+ return SCX_TEST_SKIP;
+ }
+
skel = cyclic_kick_wait__open();
SCX_FAIL_IF(!skel, "Failed to open skel");
SCX_ENUM_INIT(skel);
--
2.43.0