Re: [PATCH 2/2] selftests/sched_ext: Add cyclic SCX_KICK_WAIT stress test
From: Andrea Righi
Date: Sun Mar 29 2026 - 11:54:26 EST
Hi Cheng-Yang,
On Sun, Mar 29, 2026 at 05:06:20PM +0800, Cheng-Yang Chou wrote:
> 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.
Actually, I disagree. The whole point of the kselftests is to expose kernel
issues, including bugs in older kernels that may need fixes. So, I think we
shouldn't skip the test.
-Andrea
>
> 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
>
> From 6f09d2298e547aa7a519d4bff262fc6851a969ea Mon Sep 17 00:00:00 2001
> From: Cheng-Yang Chou <yphbchou0911@xxxxxxxxx>
> 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@xxxxxxxxx>
> ---
> 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
>