[LTP] [PATCH v2] ksm: Add max_runtime to tests

Cyril Hrubis chrubis@suse.cz
Fri Sep 16 10:40:43 CEST 2022


Hi!
> ksm02, ksm04 and ksm05 take 10+ seconds to finish. Set max_runtime to avoid
> random timeout issues.

The patch looks good. I guess that the ksm05 in the description is a
leftover and should be removed before applying, right?

> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
> ---
> 
> Changes since v1:
> - Increased max_runtime from 20s to 32s
> - Added dynamic runtime calculation for non-default memsize
> 
> After some experiments it turns out that the total amount of RAM doesn't
> matter, ksmd will scan only pages marked with MADV_MERGEABLE. So unless
> another process interferes with the test, we can calculate max_runtime
> from the memory size parameter.
> 
> The create_same_memory() function will run 4 ksm scan on each call which
> takes about 2 seconds with the default memory size. Both ksm02 and ksm04
> call it twice which means 16 seconds of runtime by default. Let's raise it
> to 32 for some safety margin on slower systems.
> 
>  testcases/kernel/mem/ksm/ksm02.c      | 4 ++++
>  testcases/kernel/mem/ksm/ksm04.c      | 4 ++++
>  testcases/kernel/mem/ksm/ksm_common.h | 4 +++-
>  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/mem/ksm/ksm02.c b/testcases/kernel/mem/ksm/ksm02.c
> index 1cb7d8e73..4183108d5 100644
> --- a/testcases/kernel/mem/ksm/ksm02.c
> +++ b/testcases/kernel/mem/ksm/ksm02.c
> @@ -85,6 +85,9 @@ static void verify_ksm(void)
>  static void setup(void)
>  {
>  	parse_ksm_options(opt_sizestr, &size, opt_numstr, &num, opt_unitstr, &unit);
> +
> +	if (opt_sizestr && size > DEFAULT_MEMSIZE)
> +		tst_set_max_runtime(32 * (size / DEFAULT_MEMSIZE));
>  }
>  
>  static struct tst_test test = {
> @@ -110,6 +113,7 @@ static struct tst_test test = {
>  	},
>  	.test_all = verify_ksm,
>  	.min_kver = "2.6.32",
> +	.max_runtime = 32,
>  	.needs_cgroup_ctrls = (const char *const []){ "cpuset", NULL },
>  };
>  
> diff --git a/testcases/kernel/mem/ksm/ksm04.c b/testcases/kernel/mem/ksm/ksm04.c
> index 39c741876..9fe9d6dd5 100644
> --- a/testcases/kernel/mem/ksm/ksm04.c
> +++ b/testcases/kernel/mem/ksm/ksm04.c
> @@ -87,6 +87,9 @@ static void setup(void)
>  	parse_ksm_options(opt_sizestr, &size, opt_numstr, &num, opt_unitstr, &unit);
>  
>  	SAFE_CG_PRINTF(tst_cg, "cgroup.procs", "%d", getpid());
> +
> +	if (opt_sizestr && size > DEFAULT_MEMSIZE)
> +		tst_set_max_runtime(32 * (size / DEFAULT_MEMSIZE));
>  }
>  
>  static struct tst_test test = {
> @@ -112,6 +115,7 @@ static struct tst_test test = {
>  	},
>  	.test_all = verify_ksm,
>  	.min_kver = "2.6.32",
> +	.max_runtime = 32,
>  	.needs_cgroup_ctrls = (const char *const []){
>  		"memory", "cpuset", NULL
>  	},
> diff --git a/testcases/kernel/mem/ksm/ksm_common.h b/testcases/kernel/mem/ksm/ksm_common.h
> index 56faf01e4..a582891c6 100644
> --- a/testcases/kernel/mem/ksm/ksm_common.h
> +++ b/testcases/kernel/mem/ksm/ksm_common.h
> @@ -9,7 +9,9 @@
>  
>  #include "tst_test.h"
>  
> -int size = 128, num = 3, unit = 1;
> +#define DEFAULT_MEMSIZE 128
> +
> +int size = DEFAULT_MEMSIZE, num = 3, unit = 1;
>  char *opt_sizestr, *opt_numstr, *opt_unitstr;
>  
>  static inline void parse_ksm_options(char *str_size, int *size,
> -- 
> 2.37.3
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list