]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/sched_ext: Fix init_enable_count flakiness
authorTejun Heo <tj@kernel.org>
Mon, 2 Feb 2026 19:40:22 +0000 (09:40 -1000)
committerTejun Heo <tj@kernel.org>
Mon, 2 Feb 2026 19:45:09 +0000 (09:45 -1000)
commit4544e9c4ec9a5955a37fdd8204a3d98106f97ab7
treedf80af29deddb81ef57145c72d105c78956a6ca0
parent2e06d54ea9a25e2925a31eb5410af0f16baa8f19
selftests/sched_ext: Fix init_enable_count flakiness

The init_enable_count test is flaky. The test forks 1024 children before
attaching the scheduler to verify that existing tasks get ops.init_task()
called. The children were using sleep(1) before exiting.

7900aa699c34 ("sched_ext: Fix cgroup exit ordering by moving sched_ext_free()
to finish_task_switch()") changed when tasks are removed from scx_tasks -
previously when the task_struct was freed, now immediately in
finish_task_switch() when the task dies.

Before the commit, pre-forked children would linger on scx_tasks until freed
regardless of when they exited, so the scheduler would always see them during
iteration. The sleep(1) was unnecessary. After the commit, children are
removed as soon as they die. The sleep(1) masks the problem in most cases but
the test becomes flaky depending on timing.

Fix by synchronizing properly using a pipe. All children block on read() and
the parent signals them to exit by closing the write end after attaching the
scheduler. The children are auto-reaped so there's no need to wait on them.

Reported-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Cc: David Vernet <void@manifault.com>
Cc: Andrea Righi <arighi@nvidia.com>
Cc: Changwoo Min <changwoo@igalia.com>
Cc: Emil Tsalapatis <emil@etsalapatis.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
tools/testing/selftests/sched_ext/init_enable_count.c