public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH V2 03/14] mem/oom: fix the timeout issue
Date: Mon, 10 Apr 2017 18:05:45 +0800	[thread overview]
Message-ID: <20170410100556.4465-4-liwang@redhat.com> (raw)
In-Reply-To: <20170410100556.4465-1-liwang@redhat.com>

OOM spend time is depend on amount of RAM+Swap, it's hard to get a standard
to measure how long it takes, so that we cann't set tst_test->timeout easily.

In this patch, we divide the tests into two part:

1. OOM takes original way on small(mem_total <= 100G) RAM, and with setting
   the .timeout according to the worst spending on 100G system. Here gives
   double(.timeout = 1200) cost in order to make sure time is long enough.

2. If system RAM is larger than 100G, OOM goes to the cgroup limited way.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/mem/oom/oom01.c | 12 ++++++++++++
 testcases/kernel/mem/oom/oom02.c | 12 ++++++++++++
 testcases/kernel/mem/oom/oom03.c |  1 +
 testcases/kernel/mem/oom/oom04.c | 11 +++++++++++
 testcases/kernel/mem/oom/oom05.c |  1 +
 5 files changed, 37 insertions(+)

diff --git a/testcases/kernel/mem/oom/oom01.c b/testcases/kernel/mem/oom/oom01.c
index 64a368e..056e02a 100644
--- a/testcases/kernel/mem/oom/oom01.c
+++ b/testcases/kernel/mem/oom/oom01.c
@@ -29,6 +29,8 @@
 #include <unistd.h>
 #include "mem.h"
 
+static unsigned long mem_total;
+
 static void verify_oom(void)
 {
 #if __WORDSIZE == 32
@@ -50,11 +52,20 @@ static void verify_oom(void)
 
 static void setup(void)
 {
+	mem_total = SAFE_READ_MEMINFO("MemTotal:");
+	if (mem_total > TESTMEM/1024*100L) {
+		tst_res(TINFO, "System RAM is larger than 100G, test in memory cgroup");
+		mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
+		write_memcg();
+	}
+
 	overcommit = get_sys_tune("overcommit_memory");
 }
 
 static void cleanup(void)
 {
+	if (mem_total > TESTMEM/1024*100L)
+		umount_mem(MEMCG_PATH, MEMCG_PATH_NEW);
 	set_sys_tune("overcommit_memory", overcommit, 0);
 }
 
@@ -62,6 +73,7 @@ static struct tst_test test = {
 	.tid = "oom01",
 	.needs_root = 1,
 	.forks_child = 1,
+	.timeout = 1200,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_oom,
diff --git a/testcases/kernel/mem/oom/oom02.c b/testcases/kernel/mem/oom/oom02.c
index f315ee2..a1be806 100644
--- a/testcases/kernel/mem/oom/oom02.c
+++ b/testcases/kernel/mem/oom/oom02.c
@@ -32,6 +32,8 @@
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
 
+static unsigned long mem_total;
+
 static void verify_oom(void)
 {
 #if __WORDSIZE == 32
@@ -50,6 +52,13 @@ static void verify_oom(void)
 
 static void setup(void)
 {
+	mem_total = SAFE_READ_MEMINFO("MemTotal:");
+	if (mem_total > TESTMEM/1024*100L) {
+		tst_res(TINFO, "System RAM is larger than 100G, test in memory cgroup");
+		mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
+		write_memcg();
+	}
+
 	if (!is_numa(NULL, NH_MEMS, 2))
 		tst_brk(TCONF, "The case need a NUMA system.");
 
@@ -59,6 +68,8 @@ static void setup(void)
 
 static void cleanup(void)
 {
+	if (mem_total > TESTMEM/1024*100L)
+		umount_mem(MEMCG_PATH, MEMCG_PATH_NEW);
 	set_sys_tune("overcommit_memory", overcommit, 0);
 }
 
@@ -66,6 +77,7 @@ static struct tst_test test = {
 	.tid = "oom02",
 	.needs_root = 1,
 	.forks_child = 1,
+	.timeout = 1200,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_oom,
diff --git a/testcases/kernel/mem/oom/oom03.c b/testcases/kernel/mem/oom/oom03.c
index d3aed60..48c1ea5 100644
--- a/testcases/kernel/mem/oom/oom03.c
+++ b/testcases/kernel/mem/oom/oom03.c
@@ -79,6 +79,7 @@ static struct tst_test test = {
 	.tid = "oom03",
 	.needs_root = 1,
 	.forks_child = 1,
+	.timeout = 1200,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_oom,
diff --git a/testcases/kernel/mem/oom/oom04.c b/testcases/kernel/mem/oom/oom04.c
index afe35b2..179a98a 100644
--- a/testcases/kernel/mem/oom/oom04.c
+++ b/testcases/kernel/mem/oom/oom04.c
@@ -32,6 +32,8 @@
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
 
+static unsigned long mem_total;
+
 static void verify_oom(void)
 {
 #if __WORDSIZE == 32
@@ -63,6 +65,12 @@ static void setup(void)
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
 
+	mem_total = SAFE_READ_MEMINFO("MemTotal:");
+	if (mem_total > TESTMEM/1024*100L) {
+		tst_res(TINFO, "System RAM is larger than 100G, test in memory cgroup");
+		mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
+		write_memcg();
+	}
 	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
 
 	/*
@@ -80,6 +88,8 @@ static void setup(void)
 
 static void cleanup(void)
 {
+	if (mem_total > TESTMEM/1024*100L)
+		umount_mem(MEMCG_PATH, MEMCG_PATH_NEW);
 	set_sys_tune("overcommit_memory", overcommit, 0);
 	umount_mem(CPATH, CPATH_NEW);
 }
@@ -88,6 +98,7 @@ static struct tst_test test = {
 	.tid = "oom04",
 	.needs_root = 1,
 	.forks_child = 1,
+	.timeout = 1200,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_oom,
diff --git a/testcases/kernel/mem/oom/oom05.c b/testcases/kernel/mem/oom/oom05.c
index d97fe7d..39361a9 100644
--- a/testcases/kernel/mem/oom/oom05.c
+++ b/testcases/kernel/mem/oom/oom05.c
@@ -116,6 +116,7 @@ static struct tst_test test = {
 	.tid = "oom05",
 	.needs_root = 1,
 	.forks_child = 1,
+	.timeout = 1200,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_oom,
-- 
2.9.3


  parent reply	other threads:[~2017-04-10 10:05 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 10:05 [LTP] [PATCH V2 00/14] Convert LTP kernel/mem/testcase to New API Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 01/14] mem/lib: convert to new API Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 02/14] mem/oom: " Li Wang
2017-04-10 10:05 ` Li Wang [this message]
2017-07-07 15:11   ` [LTP] [PATCH V2 03/14] mem/oom: fix the timeout issue Cyril Hrubis
2017-07-10  7:01     ` Li Wang
2017-07-13  9:06       ` Richard Palethorpe
2017-07-14  3:16         ` Li Wang
2017-07-10  7:38     ` Jan Stancek
2017-04-10 10:05 ` [LTP] [PATCH V2 04/14] mem/ksm: convert to new API Li Wang
2017-07-07 14:49   ` Cyril Hrubis
2017-07-07 15:29     ` Cyril Hrubis
2017-07-10  7:33     ` Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 05/14] mem/thp: " Li Wang
2017-07-07 15:27   ` Cyril Hrubis
2017-07-11  4:32     ` Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 06/14] mem/hugetlb: " Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 07/14] mem/hugemmap: " Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 08/14] mem/hugeshmat: " Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 09/14] mem/hugeshmctl: " Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 10/14] mm/hugeshmdt: " Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 11/14] mem/hugeshmget: " Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 12/14] mem/cpuset: " Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 13/14] mem/swapping: " Li Wang
2017-04-10 10:05 ` [LTP] [PATCH V2 14/14] mem/tunable: " Li Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170410100556.4465-4-liwang@redhat.com \
    --to=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox