Skip to contentSkip to conversation

sched_football: isolcpus handling

PATCH In review Attila Fazekas 3 participants 7 messages Jan 17, 2025 – Jan 23, 2025

lore
Share & tools
lore
#0 lore raw

v2 cover sched_football: isolcpus handling

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. 591c56b045b2d44a0f4ba1a13545420b23e909b5 solved was a similar issue in realtime/prio-preempt .

Attila Fazekas (2):
lib: move get_numcpus to librttest.[ch]
sched_football: use get_numcpus()

 testcases/realtime/func/prio-preempt/prio-preempt.c | 13 -------------
 .../realtime/func/sched_football/sched_football.c   |  2 +-
 testcases/realtime/include/librttest.h              |  4 ++++
 testcases/realtime/lib/librttest.c                  | 13 +++++++++++++
 4 files changed, 18 insertions(+), 14 deletions(-)
Signature · 5 lines
2.47.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH v2 1/2 lib: move get_numcpus to librttest.[ch]

get_numcpus() can be used by other tests therefore it is better to move it to a shared place.

---
 testcases/realtime/func/prio-preempt/prio-preempt.c | 13 -------------
 testcases/realtime/include/librttest.h              |  4 ++++
 testcases/realtime/lib/librttest.c                  | 13 +++++++++++++
 3 files changed, 17 insertions(+), 13 deletions(-)
testcases/realtime/func/prio-preempt/prio-preempt.c +0 -13
index 272833763..5dd717d1f 100644
@@ -288,19 +288,6 @@ void *master_thread(void *arg)
 	return NULL;
 }
 
-int get_numcpus(void)
-{
-	long numcpus_conf = sysconf(_SC_NPROCESSORS_CONF);
-	size_t size = CPU_ALLOC_SIZE(numcpus_conf);
-	cpu_set_t *cpuset = CPU_ALLOC(numcpus_conf);
-
-	CPU_ZERO_S(size, cpuset);
-	/* Get the number of cpus accessible to the current process */
-	sched_getaffinity(0, size, cpuset);
-
-	return CPU_COUNT_S(size, cpuset);
-}
-
 int main(int argc, char *argv[])
 {
 	int pri_boost, numcpus;
testcases/realtime/include/librttest.h +4 -0
index 0a1bb0540..39538c47c 100644
@@ -355,4 +355,8 @@ int trace_marker_write(char *buf, int len);
  */
 int atrace_marker_write(char *tag, char *msg);
 
+/* get_numcpus: get the number of cpus accessible to the current process
+ */
+int get_numcpus(void);
+
 #endif /* LIBRTTEST_H */
testcases/realtime/lib/librttest.c +13 -0
index 764398179..03566f36d 100644
@@ -763,3 +763,16 @@ int atrace_marker_write(char *tag, char *msg)
 	return trace_marker_write(trace_buf,
 				  strnlen(trace_buf, TRACE_BUF_LEN));
 }
+
+int get_numcpus(void)
+{
+	long numcpus_conf = sysconf(_SC_NPROCESSORS_CONF);
+	size_t size = CPU_ALLOC_SIZE(numcpus_conf);
+	cpu_set_t *cpuset = CPU_ALLOC(numcpus_conf);
+
+	CPU_ZERO_S(size, cpuset);
+	/* Get the number of cpus accessible to the current process */
+	sched_getaffinity(0, size, cpuset);
+
+	return CPU_COUNT_S(size, cpuset);
+}
Signature · 5 lines
2.47.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v2 1/2
#2 lore raw

Re: [LTP] [PATCH v2 1/2] lib: move get_numcpus to librttest.[ch]

Hi!

testcases/realtime/lib/librttest.c int atrace_marker_write(char *tag, char *msg) · line 778

Quoted 12 lines
testcases/realtime/lib/librttest.c +12 -0
+int get_numcpus(void)
+{
+	long numcpus_conf = sysconf(_SC_NPROCESSORS_CONF);
+	size_t size = CPU_ALLOC_SIZE(numcpus_conf);
+	cpu_set_t *cpuset = CPU_ALLOC(numcpus_conf);
+
+	CPU_ZERO_S(size, cpuset);
+	/* Get the number of cpus accessible to the current process */
+	sched_getaffinity(0, size, cpuset);
+
+	return CPU_COUNT_S(size, cpuset);
+}

Can we please add another patch on the top that adds CPU_FREE() to this function?

For this patch:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

PATCH v2 2/2 sched_football: use get_numcpus()

In reply to Attila Fazekas

sched_football can hang in systems where not all CPU cores are available, using get_numcpus() to account
for things like isolated cores.

---
 testcases/realtime/func/sched_football/sched_football.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/realtime/func/sched_football/sched_football.c +1 -1
index 763b41f23..5ffc1ff46 100644
@@ -140,7 +140,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);
 
Signature · 5 lines
2.47.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Re: [LTP] [PATCH v2 2/2] sched_football: use get_numcpus()

Hi Attila, Cyril,

patchset merged, thanks!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp