public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa'
  2013-03-14 16:21   ` [LTP] [PATCH 0/5] mm/oom: extend the coverage of OOM Zhouping Liu
@ 2013-03-14 16:21     ` Zhouping Liu
  2013-03-14 16:51       ` chrubis
  0 siblings, 1 reply; 6+ messages in thread
From: Zhouping Liu @ 2013-03-14 16:21 UTC (permalink / raw)
  To: LTP List

OOM with the combination of memcg & numa was moved to oom03,
and the case is re-design to be used to test OOM with CPUSET.

The patch also introduce a new global var ISNUMA, which
is easily used to recognize a NUMA system.

Signed-off-by: Zhouping Liu <zliu@redhat.com>
---
 testcases/kernel/mem/include/mem.h |  2 ++
 testcases/kernel/mem/lib/mem.c     |  2 ++
 testcases/kernel/mem/oom/oom03.c   | 24 +++++++++++++++
 testcases/kernel/mem/oom/oom04.c   | 63 ++++++++++++++++----------------------
 4 files changed, 54 insertions(+), 37 deletions(-)

diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h
index 1233493..de51838 100644
--- a/testcases/kernel/mem/include/mem.h
+++ b/testcases/kernel/mem/include/mem.h
@@ -24,6 +24,8 @@
 #define MLOCK			3
 #define KSM			4
 
+extern int ISNUMA;
+
 long overcommit;
 void oom(int testcase, int mempolicy, int lite);
 void testoom(int mempolicy, int lite, int numa);
diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index a71bc90..e99dae7 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -24,6 +24,8 @@
 #include "mem.h"
 #include "numa_helper.h"
 
+int ISNUMA = 0; /* mark a NUMA system */
+
 /* OOM */
 
 static int _alloc_mem(long int length, int testcase)
diff --git a/testcases/kernel/mem/oom/oom03.c b/testcases/kernel/mem/oom/oom03.c
index 95e34d5..4365c2b 100644
--- a/testcases/kernel/mem/oom/oom03.c
+++ b/testcases/kernel/mem/oom/oom03.c
@@ -40,6 +40,10 @@
 char *TCID = "oom03";
 int TST_TOTAL = 1;
 
+#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
+	&& HAVE_MPOL_CONSTANTS
+#include <numaif.h>
+
 int main(int argc, char *argv[])
 {
 	char *msg;
@@ -76,6 +80,14 @@ int main(int argc, char *argv[])
 			write_file(MEMCG_SW_LIMIT, mem);
 			testoom(0, 1, 0);
 		}
+
+		/* OOM for MEMCG with mempolicy */
+		if (ISNUMA) {
+			tst_resm(TINFO, "OOM on MEMCG & mempolicy...");
+			testoom(MPOL_BIND, 0, 1);
+			testoom(MPOL_INTERLEAVE, 0, 1);
+			testoom(MPOL_PREFERRED, 0, 1);
+		}
 	}
 	cleanup();
 	tst_exit();
@@ -87,6 +99,10 @@ void setup(void)
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 	TEST_PAUSE;
 
+	/* rough estimate a NUMA system by max_node id */
+	if (numa_max_node() > 0)
+		ISNUMA = 1;
+
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
 	mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
@@ -99,3 +115,11 @@ void cleanup(void)
 
 	TEST_CLEANUP;
 }
+
+#else
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
+}
+#endif
+
diff --git a/testcases/kernel/mem/oom/oom04.c b/testcases/kernel/mem/oom/oom04.c
index bc51046..6acc783 100644
--- a/testcases/kernel/mem/oom/oom04.c
+++ b/testcases/kernel/mem/oom/oom04.c
@@ -1,5 +1,5 @@
 /*
- * Out Of Memory (OOM) for Memory Resource Controller and NUMA
+ * Out Of Memory (OOM) for CPUSET
  *
  * The program is designed to cope with unpredictable like amount and
  * system physical memory, swap size and other VMM technology like KSM,
@@ -44,12 +44,12 @@ int TST_TOTAL = 1;
 
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
+#include <numa.h>
+
 int main(int argc, char *argv[])
 {
 	char *msg;
 	int lc;
-	int swap_acc_on = 1;
-	char buf[BUFSIZ], mem[BUFSIZ];
 
 	msg = parse_opts(argc, argv, NULL, NULL);
 	if (msg != NULL)
@@ -64,38 +64,19 @@ int main(int argc, char *argv[])
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		tst_count = 0;
 
-		snprintf(buf, BUFSIZ, "%d", getpid());
-		write_file(MEMCG_PATH_NEW "/tasks", buf);
-
-		snprintf(mem, BUFSIZ, "%ld", TESTMEM);
-		write_file(MEMCG_PATH_NEW "/memory.limit_in_bytes", mem);
-
-		if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
-			if (errno == ENOENT) {
-				tst_resm(TCONF,
-					 "memcg swap accounting is disabled");
-				swap_acc_on = 0;
-			} else
-				tst_brkm(TBROK | TERRNO, cleanup, "access");
-		}
-
-		tst_resm(TINFO, "process mempolicy.");
-		testoom(1, 0, 1);
-
-		if (swap_acc_on) {
-			write_file(MEMCG_SW_LIMIT, mem);
-			testoom(1, 1, 1);
-		}
-
-		tst_resm(TINFO, "process cpuset.");
-
-		if (swap_acc_on)
-			write_file(MEMCG_SW_LIMIT, "-1");
-		testoom(0, 0, 1);
-
-		if (swap_acc_on) {
-			write_file(MEMCG_SW_LIMIT, mem);
-			testoom(0, 1, 1);
+		tst_resm(TINFO, "OOM on CPUSET...");
+		testoom(0, 0, 0);
+
+		if (ISNUMA) {
+			/*
+			 * Under NUMA system, the migration of cpuset's memory
+			 * is in charge of cpuset.memory_migrate, we can write
+			 * 1 to cpuset.memory_migrate to enable the migration.
+			 */
+			write_cpuset_files(CPATH_NEW,
+					   "memory_migrate", "1");
+			tst_resm(TINFO, "OOM on CPUSET with mem migrate:");
+			testoom(0, 0, 0);
 		}
 	}
 	cleanup();
@@ -111,14 +92,22 @@ void setup(void)
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
 	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
-	mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
+
+	/* rough estimate a NUMA system through max_node */
+	if (numa_max_node() > 0) {
+		ISNUMA = 1;
+		/* For NUMA system, using the first node for cpuset.mems */
+		write_cpusets(get_a_numa_node(cleanup));
+	} else {
+		/* For nonNUMA system, using node0 for cpuset.mems */
+		write_cpusets(0);
+	}
 }
 
 void cleanup(void)
 {
 	set_sys_tune("overcommit_memory", overcommit, 0);
 	umount_mem(CPATH, CPATH_NEW);
-	umount_mem(MEMCG_PATH, MEMCG_PATH_NEW);
 
 	TEST_CLEANUP;
 }
-- 
1.7.11.7


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa'
  2013-03-14 16:21     ` [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa' Zhouping Liu
@ 2013-03-14 16:51       ` chrubis
       [not found]         ` <507561236.18941341.1363282016883.JavaMail.root@redhat.com>
  0 siblings, 1 reply; 6+ messages in thread
From: chrubis @ 2013-03-14 16:51 UTC (permalink / raw)
  To: Zhouping Liu; +Cc: LTP List

Hi!
>  testcases/kernel/mem/include/mem.h |  2 ++
>  testcases/kernel/mem/lib/mem.c     |  2 ++
>  testcases/kernel/mem/oom/oom03.c   | 24 +++++++++++++++
>  testcases/kernel/mem/oom/oom04.c   | 63 ++++++++++++++++----------------------
>  4 files changed, 54 insertions(+), 37 deletions(-)
> 
> diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h
> index 1233493..de51838 100644
> --- a/testcases/kernel/mem/include/mem.h
> +++ b/testcases/kernel/mem/include/mem.h
> @@ -24,6 +24,8 @@
>  #define MLOCK			3
>  #define KSM			4
>  
> +extern int ISNUMA;
> +
>  long overcommit;
>  void oom(int testcase, int mempolicy, int lite);
>  void testoom(int mempolicy, int lite, int numa);
> diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
> index a71bc90..e99dae7 100644
> --- a/testcases/kernel/mem/lib/mem.c
> +++ b/testcases/kernel/mem/lib/mem.c
> @@ -24,6 +24,8 @@
>  #include "mem.h"
>  #include "numa_helper.h"
>  
> +int ISNUMA = 0; /* mark a NUMA system */

So you have added variable to the library that is initialized in the
test setup? That is just too messy :(.

> +	/* rough estimate a NUMA system through max_node */
> +	if (numa_max_node() > 0) {
> +		ISNUMA = 1;
> +		/* For NUMA system, using the first node for cpuset.mems */
> +		write_cpusets(get_a_numa_node(cleanup));
> +	} else {
> +		/* For nonNUMA system, using node0 for cpuset.mems */
> +		write_cpusets(0);
> +	}

Why couldn't we have a function is_numa() in the library that would do
something like this snippet of code, i.e. return numa_max_node() > 0
(assuming that the code is needed in other test than this one.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa'
       [not found]         ` <507561236.18941341.1363282016883.JavaMail.root@redhat.com>
@ 2013-03-14 18:32           ` chrubis
  0 siblings, 0 replies; 6+ messages in thread
From: chrubis @ 2013-03-14 18:32 UTC (permalink / raw)
  To: Jan Stancek; +Cc: LTP List

Hi!
> We added numa_helper library to be able to get number of nodes, as well
> as list of nodes (with memory, cpu or both). numa_max_node() > 0 doesn't
> tell you how many nodes you have.
> 
> Here's sample use to get just node count:
> ----------------------------------------------------------------
> #include <stdio.h>
> #include "numa_helper.h"
> 
> const char *TCID="test";
> int main()
> {
>         int num_nodes;
>         int ret = get_allowed_nodes_arr(NH_MEMS | NH_CPUS, &num_nodes, NULL);
>         printf("ret: %d, nodes:%d\n", ret, num_nodes);
>         return 0;
> }
> ----------------------------------------------------------------
> 
> We could add a simple function to numa_helper, but I'm not sure what
> it would return as default, some tests care about nodes with memory.

Maybe we misunderstand about what I see as a problem here. This patch
adds integer variable to the lib/mem.c library and that variable is then
only used within the tests. That just looks like wrong desing to me.

The code snippet "numa_max_node() > 0" was take from one of the tests
that initializes the variable in question (the pattern seems to repeat
in them). So I wasn't proposing any functional changes in the code just
requesting cleaner desing.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa'
       [not found] <51428CEA.6030604@redhat.com>
@ 2013-03-15  9:11 ` Jan Stancek
  2013-03-15 15:41   ` Zhouping Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Stancek @ 2013-03-15  9:11 UTC (permalink / raw)
  To: Zhouping Liu; +Cc: LTP List



----- Original Message -----
> From: "Zhouping Liu" <zliu@redhat.com>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: chrubis@suse.cz, "LTP List" <ltp-list@lists.sourceforge.net>
> Sent: Friday, 15 March, 2013 3:52:26 AM
> Subject: Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa'

> > We could add a simple function to numa_helper, but I'm not sure
> > what
> > it would return as default, some tests care about nodes with
> > memory.
> 
> yes, what you care about is right, but now we only need a function,
> which
> can tell us the system have more than one node, we don't care about
> the
> nodes have
> CPUs or memory.

What I was wondering is why that comment said "rough estimate",
it looks quite accurate. Anyway, thanks for clarifying.

Regards,
Jan

> 
> so I will created is_numa() in numa_helper to implement it.
> 
> Thanks
> Zhouping
> 

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa'
  2013-03-15  9:11 ` [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa' Jan Stancek
@ 2013-03-15 15:41   ` Zhouping Liu
  2013-03-15 16:06     ` Jan Stancek
  0 siblings, 1 reply; 6+ messages in thread
From: Zhouping Liu @ 2013-03-15 15:41 UTC (permalink / raw)
  To: Jan Stancek; +Cc: LTP List



----- Original Message -----
> From: "Jan Stancek" <jstancek@redhat.com>
> To: "Zhouping Liu" <zliu@redhat.com>
> Cc: "LTP List" <ltp-list@lists.sourceforge.net>
> Sent: Friday, March 15, 2013 5:11:57 PM
> Subject: Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa'
> 
> 
> 
> ----- Original Message -----
> > From: "Zhouping Liu" <zliu@redhat.com>
> > To: "Jan Stancek" <jstancek@redhat.com>
> > Cc: chrubis@suse.cz, "LTP List" <ltp-list@lists.sourceforge.net>
> > Sent: Friday, 15 March, 2013 3:52:26 AM
> > Subject: Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET'
> > and updated 'OOM with MEMCG & numa'
> 
> > > We could add a simple function to numa_helper, but I'm not sure
> > > what
> > > it would return as default, some tests care about nodes with
> > > memory.
> > 
> > yes, what you care about is right, but now we only need a function,
> > which
> > can tell us the system have more than one node, we don't care about
> > the
> > nodes have
> > CPUs or memory.
> 
> What I was wondering is why that comment said "rough estimate",

because in the old version, I just used the max node id to judge a NUMA system,
which maybe is not strict.

> it looks quite accurate. Anyway, thanks for clarifying.

in the V2 version, I removed the ISNUMA variable, and added a new function is_numa(),
inside the function, the system, which has 1 more than numa node, and each node at
least contains memory, is regarded as a numa system. I think it's more reasoned,
because NUMA is mainly about memory, more case will fail if the node has no memory.
do you agree?

-- 
Thanks,
Zhouping

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa'
  2013-03-15 15:41   ` Zhouping Liu
@ 2013-03-15 16:06     ` Jan Stancek
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Stancek @ 2013-03-15 16:06 UTC (permalink / raw)
  To: Zhouping Liu; +Cc: LTP List



----- Original Message -----
> From: "Zhouping Liu" <zliu@redhat.com>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: "LTP List" <ltp-list@lists.sourceforge.net>
> Sent: Friday, 15 March, 2013 4:41:29 PM
> Subject: Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa'
> 
> 
> 
> ----- Original Message -----
> > From: "Jan Stancek" <jstancek@redhat.com>
> > To: "Zhouping Liu" <zliu@redhat.com>
> > Cc: "LTP List" <ltp-list@lists.sourceforge.net>
> > Sent: Friday, March 15, 2013 5:11:57 PM
> > Subject: Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET'
> > and updated 'OOM with MEMCG & numa'
> > 
> > 
> > 
> > ----- Original Message -----
> > > From: "Zhouping Liu" <zliu@redhat.com>
> > > To: "Jan Stancek" <jstancek@redhat.com>
> > > Cc: chrubis@suse.cz, "LTP List" <ltp-list@lists.sourceforge.net>
> > > Sent: Friday, 15 March, 2013 3:52:26 AM
> > > Subject: Re: [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for
> > > CPUSET'
> > > and updated 'OOM with MEMCG & numa'
> > 
> > > > We could add a simple function to numa_helper, but I'm not sure
> > > > what
> > > > it would return as default, some tests care about nodes with
> > > > memory.
> > > 
> > > yes, what you care about is right, but now we only need a
> > > function,
> > > which
> > > can tell us the system have more than one node, we don't care
> > > about
> > > the
> > > nodes have
> > > CPUs or memory.
> > 
> > What I was wondering is why that comment said "rough estimate",
> 
> because in the old version, I just used the max node id to judge a
> NUMA system,
> which maybe is not strict.
> 
> > it looks quite accurate. Anyway, thanks for clarifying.
> 
> in the V2 version, I removed the ISNUMA variable, and added a new
> function is_numa(),
> inside the function, the system, which has 1 more than numa node, and
> each node at
> least contains memory, is regarded as a numa system. I think it's
> more reasoned,
> because NUMA is mainly about memory, more case will fail if the node
> has no memory.
> do you agree?

I agree. Some failures on unbalanced NUMA systems led to introducing that check.
I was looking at our system pool and number of such systems is very low,
so I don't think we are loosing very much by requiring 2+ nodes with memory.

> 
> --
> Thanks,
> Zhouping
> 

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2013-03-15 16:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <51428CEA.6030604@redhat.com>
2013-03-15  9:11 ` [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa' Jan Stancek
2013-03-15 15:41   ` Zhouping Liu
2013-03-15 16:06     ` Jan Stancek
2013-03-14 16:21 [LTP] [PATCH 1/5] lib/mem: modified _gather_cpus() as _gather_node_cpus() Zhouping Liu
2013-03-14 16:21 ` [LTP] [PATCH 2/5] mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy' Zhouping Liu
2013-03-14 16:21   ` [LTP] [PATCH 0/5] mm/oom: extend the coverage of OOM Zhouping Liu
2013-03-14 16:21     ` [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa' Zhouping Liu
2013-03-14 16:51       ` chrubis
     [not found]         ` <507561236.18941341.1363282016883.JavaMail.root@redhat.com>
2013-03-14 18:32           ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox