Skip to contentSkip to conversation

selftests/sched_ext: Fix exit selftest hang on UP

PATCH Applied Andrea Righi 3 participants 3 messages Jul 1, 2025 – Jul 3, 2025

Subsystems (2)
lore
Share & tools
lore

Andrea Righi

author reviewer
#0 lore raw

PATCH 1/1 selftests/sched_ext: Fix exit selftest hang on UP

On single-CPU systems, ops.select_cpu() is never called, causing the EXIT_SELECT_CPU test case to wait indefinitely.

Avoid the stall by skipping this specific sub-test when only one CPU is available.

Fixes a5db7817af780 ("sched_ext: Add selftests")
---
 tools/testing/selftests/sched_ext/exit.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tools/testing/selftests/sched_ext/exit.c +8 -0
index 9451782689de1..ee25824b1cbe6 100644
@@ -22,6 +22,14 @@ static enum scx_test_status run(void *ctx)
 		struct bpf_link *link;
 		char buf[16];
 
+		/*
+		 * On single-CPU systems, ops.select_cpu() is never
+		 * invoked, so skip this test to avoid getting stuck
+		 * indefinitely.
+		 */
+		if (tc == EXIT_SELECT_CPU && libbpf_num_possible_cpus() == 1)
+			continue;
+
 		skel = exit__open();
 		SCX_ENUM_INIT(skel);
 		skel->rodata->exit_point = tc;
Signature · 1 line
2.50.0
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Tue, Jul 01, 2025 at 08:08:45AM +0200 Andrea Righi wrote:

On single-CPU systems, ops.select_cpu() is never called, causing the EXIT_SELECT_CPU test case to wait indefinitely.

Avoid the stall by skipping this specific sub-test when only one CPU is available.

Fixes a5db7817af780 ("sched_ext: Add selftests")

Thanks Andrea! You beat me to it. I didn't know that libbpf call existed :)

and

Cheers,
Phil

Quoted 26 lines
---
 tools/testing/selftests/sched_ext/exit.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tools/testing/selftests/sched_ext/exit.c +8 -0
index 9451782689de1..ee25824b1cbe6 100644
@@ -22,6 +22,14 @@ static enum scx_test_status run(void *ctx)
 		struct bpf_link *link;
 		char buf[16];
 
+		/*
+		 * On single-CPU systems, ops.select_cpu() is never
+		 * invoked, so skip this test to avoid getting stuck
+		 * indefinitely.
+		 */
+		if (tc == EXIT_SELECT_CPU && libbpf_num_possible_cpus() == 1)
+			continue;
+
 		skel = exit__open();
 		SCX_ENUM_INIT(skel);
 		skel->rodata->exit_point = tc;
Signature · 1 line
2.50.0
reviewer Applied
#2 lore raw
In reply to Andrea Righi
Quoted 9 lines · Andrea Righi

On single-CPU systems, ops.select_cpu() is never called, causing the EXIT_SELECT_CPU test case to wait indefinitely.

Avoid the stall by skipping this specific sub-test when only one CPU is available.

Fixes a5db7817af780 ("sched_ext: Add selftests")

Applied to sched_ext/for-6.16-fixes.

Thanks.

Signature · 1 line
tejun