[LTP] [PATCH v3 3/3] max_map_count: replace ifdefs by tst_arch

Cyril Hrubis chrubis@suse.cz
Mon Nov 8 13:44:42 CET 2021


On Mon, Nov 08, 2021 at 10:14:50AM +0800, Li Wang wrote:
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
>  testcases/kernel/mem/tunable/max_map_count.c | 41 +++++++++++---------
>  1 file changed, 23 insertions(+), 18 deletions(-)
> 
> diff --git a/testcases/kernel/mem/tunable/max_map_count.c b/testcases/kernel/mem/tunable/max_map_count.c
> index 4f0ad0037..9da67520c 100644
> --- a/testcases/kernel/mem/tunable/max_map_count.c
> +++ b/testcases/kernel/mem/tunable/max_map_count.c
> @@ -91,24 +91,29 @@ static bool filter_map(const char *line)
>  	if (ret != 1)
>  		return false;
>  
> -#if defined(__x86_64__) || defined(__x86__)
> -	/* On x86, there's an old compat vsyscall page */
> -	if (!strcmp(buf, "[vsyscall]"))
> -		return true;
> -#elif defined(__ia64__)
> -	/* On ia64, the vdso is not a proper mapping */
> -	if (!strcmp(buf, "[vdso]"))
> -		return true;
> -#elif defined(__arm__)
> -	/* Skip it when run it in aarch64 */
> -	if ((!strcmp(un.machine, "aarch64"))
> -	|| (!strcmp(un.machine, "aarch64_be")))
> -		return false;
> -
> -	/* Older arm kernels didn't label their vdso maps */
> -	if (!strncmp(line, "ffff0000-ffff1000", 17))
> -		return true;
> -#endif
> +	switch (tst_arch.type) {
> +	case TST_X86:
> +	case TST_X86_64:
> +		/* On x86, there's an old compat vsyscall page */
> +		if (!strcmp(buf, "[vsyscall]"))
> +			return true;
> +	break;
> +	case TST_IA64:
> +		/* On ia64, the vdso is not a proper mapping */
> +		if (!strcmp(buf, "[vdso]"))
> +			return true;
> +	break;
> +	case TST_ARM:
> +		/* Skip it when run it in aarch64 */
> +		if ((!strcmp(un.machine, "aarch64"))
> +				|| (!strcmp(un.machine, "aarch64_be")))
> +			return false;

		I wonder if this would be better as:

		if (tst_kernel_bits() == 64)
			return false;

Other than this the code looks actually better this way.

> +		/* Older arm kernels didn't label their vdso maps */
> +		if (!strncmp(line, "ffff0000-ffff1000", 17))
> +			return true;
> +	break;
> +	};
>  
>  	return false;
>  }
> -- 
> 2.31.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list