public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] sched_football: isolcpus handling
@ 2025-01-13 16:00 Attila Fazekas
  2025-01-13 22:08 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Attila Fazekas @ 2025-01-13 16:00 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.
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


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

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

* Re: [LTP] [PATCH] sched_football: isolcpus handling
  2025-01-13 16:00 [LTP] [PATCH] sched_football: isolcpus handling Attila Fazekas
@ 2025-01-13 22:08 ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2025-01-13 22:08 UTC (permalink / raw)
  To: Attila Fazekas; +Cc: ltp

Hi Attila,

> 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
nit: missing spaces:
591c56b045b2d44a0f4ba1a13545420b23e909b5 solved was a similar 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);
> +}

Can't we unify these get_numcpus() functions and move to librttest.[ch]?

Also we have similar code in testcases/kernel/sched/cfs-scheduler/starvation.c
added in 1800e635783b69cacdce9f654ecd730a8f30915b (uses code from
lib/tst_cpu.c), but that's outside of testcases/realtime/, thus let's keep it
untouched.

Kind regards,
Petr

> +
>  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);

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

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

end of thread, other threads:[~2025-01-13 22:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-13 16:00 [LTP] [PATCH] sched_football: isolcpus handling Attila Fazekas
2025-01-13 22:08 ` Petr Vorel

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