All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] ksm: Add max_runtime to tests
@ 2022-09-15 16:03 Martin Doucha
  2022-09-16  8:40 ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Doucha @ 2022-09-15 16:03 UTC (permalink / raw)
  To: ltp

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

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

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

* Re: [LTP] [PATCH v2] ksm: Add max_runtime to tests
  2022-09-15 16:03 [LTP] [PATCH v2] ksm: Add max_runtime to tests Martin Doucha
@ 2022-09-16  8:40 ` Cyril Hrubis
  2022-09-16  8:46   ` Martin Doucha
  0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2022-09-16  8:40 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

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

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

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

* Re: [LTP] [PATCH v2] ksm: Add max_runtime to tests
  2022-09-16  8:40 ` Cyril Hrubis
@ 2022-09-16  8:46   ` Martin Doucha
  2022-09-16  9:01     ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Doucha @ 2022-09-16  8:46 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

On 16. 09. 22 10:40, Cyril Hrubis wrote:
> 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?

Yes, that's a leftover, ksm05 gets executed for a fixed period of time 
via the -I parameter in runfile so it doesn't need static max_runtime. 
Otherwise the test finishes almost instantly. I forgot to remove the 
mention in commit message, sorry about that.

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


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

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

* Re: [LTP] [PATCH v2] ksm: Add max_runtime to tests
  2022-09-16  8:46   ` Martin Doucha
@ 2022-09-16  9:01     ` Cyril Hrubis
  0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2022-09-16  9:01 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi!
> Yes, that's a leftover, ksm05 gets executed for a fixed period of time 
> via the -I parameter in runfile so it doesn't need static max_runtime. 
> Otherwise the test finishes almost instantly. I forgot to remove the 
> mention in commit message, sorry about that.

I've fixed the commit message and pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

end of thread, other threads:[~2022-09-16  8:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15 16:03 [LTP] [PATCH v2] ksm: Add max_runtime to tests Martin Doucha
2022-09-16  8:40 ` Cyril Hrubis
2022-09-16  8:46   ` Martin Doucha
2022-09-16  9:01     ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.