[LTP] [PATCH] sched_football: isolcpus handling

Attila Fazekas afazekas@redhat.com
Mon Jan 13 17:00:40 CET 2025


sched_football expects each player thread is scheduleable
to all of the physical CPU threads, however for example
when you are using isolcpus by default you threads are
not scheduled to some CPU. It leads to the test hangs.
591c56b045b2d44a0f4ba1a13545420b23e909b5solved was asimilar issue
in realtime/prio-preempt .

Signed-off-by: Attila Fazekas <afazekas@redhat.com>
---
 .../realtime/func/sched_football/sched_football.c  | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/testcases/realtime/func/sched_football/sched_football.c b/testcases/realtime/func/sched_football/sched_football.c
index 763b41f23..e4ae6a027 100644
--- a/testcases/realtime/func/sched_football/sched_football.c
+++ b/testcases/realtime/func/sched_football/sched_football.c
@@ -133,6 +133,18 @@ void referee(int game_length)
 	TST_EXP_EXPR(final_ball == 0);
 }
 
+static inline int get_numcpus(void)
+{
+	cpu_set_t mask;
+
+	CPU_ZERO(&mask);
+
+	/* Get the number of cpus accessible to the current process */
+	sched_getaffinity(getpid(), sizeof(mask), &mask);
+
+	return CPU_COUNT(&mask);
+}
+
 static void do_test(void)
 {
 	struct sched_param param;
@@ -140,7 +152,7 @@ static void do_test(void)
 	int i;
 
 	if (players_per_team == 0)
-		players_per_team = sysconf(_SC_NPROCESSORS_ONLN);
+		players_per_team = get_numcpus();
 
 	tst_atomic_store(0, &players_ready);
 
-- 
2.47.1



More information about the ltp mailing list