public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/2] sched_football: isolcpus handling
@ 2025-01-17 13:57 Attila Fazekas
  2025-01-17 13:57 ` [LTP] [PATCH v2 1/2] lib: move get_numcpus to librttest.[ch] Attila Fazekas
  2025-01-17 13:57 ` [LTP] [PATCH v2 2/2] sched_football: use get_numcpus() Attila Fazekas
  0 siblings, 2 replies; 7+ messages in thread
From: Attila Fazekas @ 2025-01-17 13:57 UTC (permalink / raw)
  To: ltp; +Cc: Attila Fazekas

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(-)

-- 
2.47.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v2 1/2] lib: move get_numcpus to librttest.[ch]
  2025-01-17 13:57 [LTP] [PATCH v2 0/2] sched_football: isolcpus handling Attila Fazekas
@ 2025-01-17 13:57 ` Attila Fazekas
  2025-01-17 16:17   ` Cyril Hrubis
  2025-01-17 13:57 ` [LTP] [PATCH v2 2/2] sched_football: use get_numcpus() Attila Fazekas
  1 sibling, 1 reply; 7+ messages in thread
From: Attila Fazekas @ 2025-01-17 13:57 UTC (permalink / raw)
  To: ltp; +Cc: Attila Fazekas

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

Signed-off-by: Attila Fazekas <afazekas@redhat.com>
---
 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(-)

diff --git a/testcases/realtime/func/prio-preempt/prio-preempt.c b/testcases/realtime/func/prio-preempt/prio-preempt.c
index 272833763..5dd717d1f 100644
--- a/testcases/realtime/func/prio-preempt/prio-preempt.c
+++ b/testcases/realtime/func/prio-preempt/prio-preempt.c
@@ -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;
diff --git a/testcases/realtime/include/librttest.h b/testcases/realtime/include/librttest.h
index 0a1bb0540..39538c47c 100644
--- a/testcases/realtime/include/librttest.h
+++ b/testcases/realtime/include/librttest.h
@@ -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 */
diff --git a/testcases/realtime/lib/librttest.c b/testcases/realtime/lib/librttest.c
index 764398179..03566f36d 100644
--- a/testcases/realtime/lib/librttest.c
+++ b/testcases/realtime/lib/librttest.c
@@ -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);
+}
-- 
2.47.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v2 2/2] sched_football: use get_numcpus()
  2025-01-17 13:57 [LTP] [PATCH v2 0/2] sched_football: isolcpus handling Attila Fazekas
  2025-01-17 13:57 ` [LTP] [PATCH v2 1/2] lib: move get_numcpus to librttest.[ch] Attila Fazekas
@ 2025-01-17 13:57 ` Attila Fazekas
  2025-01-17 16:18   ` Cyril Hrubis
  1 sibling, 1 reply; 7+ messages in thread
From: Attila Fazekas @ 2025-01-17 13:57 UTC (permalink / raw)
  To: ltp; +Cc: 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.

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

diff --git a/testcases/realtime/func/sched_football/sched_football.c b/testcases/realtime/func/sched_football/sched_football.c
index 763b41f23..5ffc1ff46 100644
--- a/testcases/realtime/func/sched_football/sched_football.c
+++ b/testcases/realtime/func/sched_football/sched_football.c
@@ -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);
 
-- 
2.47.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v2 1/2] lib: move get_numcpus to librttest.[ch]
  2025-01-17 13:57 ` [LTP] [PATCH v2 1/2] lib: move get_numcpus to librttest.[ch] Attila Fazekas
@ 2025-01-17 16:17   ` Cyril Hrubis
  0 siblings, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2025-01-17 16:17 UTC (permalink / raw)
  To: Attila Fazekas; +Cc: ltp

Hi!
> +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:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v2 2/2] sched_football: use get_numcpus()
  2025-01-17 13:57 ` [LTP] [PATCH v2 2/2] sched_football: use get_numcpus() Attila Fazekas
@ 2025-01-17 16:18   ` Cyril Hrubis
  2025-01-21  9:15     ` Petr Vorel
  0 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2025-01-17 16:18 UTC (permalink / raw)
  To: Attila Fazekas; +Cc: ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v2 2/2] sched_football: use get_numcpus()
  2025-01-17 16:18   ` Cyril Hrubis
@ 2025-01-21  9:15     ` Petr Vorel
  2025-01-23 11:21       ` Attila Fazekas
  0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2025-01-21  9:15 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp, Attila Fazekas

Hi Attila, Cyril,

patchset merged, thanks!

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH v2 2/2] sched_football: use get_numcpus()
  2025-01-21  9:15     ` Petr Vorel
@ 2025-01-23 11:21       ` Attila Fazekas
  0 siblings, 0 replies; 7+ messages in thread
From: Attila Fazekas @ 2025-01-23 11:21 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi Petr, Cyril,

Thanks!

I have sent a follow up to the CPU_FREE()
https://lists.linux.it/pipermail/ltp/2025-January/041869.html

Best regards,
Attila

On Tue, Jan 21, 2025 at 10:15 AM Petr Vorel <pvorel@suse.cz> wrote:

> Hi Attila, Cyril,
>
> patchset merged, thanks!
>
> Kind regards,
> Petr
>
>

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-23 11:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-17 13:57 [LTP] [PATCH v2 0/2] sched_football: isolcpus handling Attila Fazekas
2025-01-17 13:57 ` [LTP] [PATCH v2 1/2] lib: move get_numcpus to librttest.[ch] Attila Fazekas
2025-01-17 16:17   ` Cyril Hrubis
2025-01-17 13:57 ` [LTP] [PATCH v2 2/2] sched_football: use get_numcpus() Attila Fazekas
2025-01-17 16:18   ` Cyril Hrubis
2025-01-21  9:15     ` Petr Vorel
2025-01-23 11:21       ` Attila Fazekas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox