[LTP] [PATCH] sched/starvation: Choose from available cpus

Wei Gao wegao@suse.com
Thu Jun 6 01:39:31 CEST 2024


On Wed, Jun 05, 2024 at 06:05:36PM +0000, Edward Liaw via ltp wrote:
> Use the first available cpu in the sched_getaffinity set.
> 
> This test was failing as a 32bit test for some arm architectures where
> cpu 0 does not support 32bit applications.
> 
> Signed-off-by: Edward Liaw <edliaw@google.com>
> ---
>  .../kernel/sched/cfs-scheduler/starvation.c     | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/sched/cfs-scheduler/starvation.c b/testcases/kernel/sched/cfs-scheduler/starvation.c
> index eb9fd6ff5..e0ea30d19 100644
> --- a/testcases/kernel/sched/cfs-scheduler/starvation.c
> +++ b/testcases/kernel/sched/cfs-scheduler/starvation.c
> @@ -49,13 +49,28 @@ again:
>  static void setup(void)
>  {
>  	cpu_set_t mask;
> +	int cpu = 0;
> +	long ncpus = tst_ncpus_conf();
>  
>  	CPU_ZERO(&mask);
>  
> -	CPU_SET(0, &mask);
> +	/* Restrict test to a single cpu */
> +	TST_EXP_POSITIVE(sched_getaffinity(0, sizeof(mask), &mask));
s/TST_EXP_POSITIVE/TST_EXP_PASS
> +
> +	if (CPU_COUNT(&mask) == 0)
> +		tst_brk(TCONF, "No cpus available");
I suppose this should a bug happen if cpu count is 0, so i suggest
s/TCONF/TBROK. What do you think?

> +
> +	while (CPU_ISSET(cpu, &mask) == 0 && cpu < ncpus)
> +		cpu++;
> +
> +	CPU_ZERO(&mask);
> +
> +	CPU_SET(cpu, &mask);
>  
>  	TST_EXP_POSITIVE(sched_setaffinity(0, sizeof(mask), &mask));
s/TST_EXP_POSITIVE/TST_EXP_PASS
>  
> +	tst_res(TINFO, "Set affinity to CPU %d", cpu);
> +
>  	if (tst_parse_long(str_loop, &loop, 1, LONG_MAX))
>  		tst_brk(TBROK, "Invalid number of loop number '%s'", str_loop);
>  
Others LGTM. Thanks for your nice patch!
> -- 
> 2.45.1.467.gbab1589fc0-goog
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp


More information about the ltp mailing list