Skip to contentSkip to conversation

mm/oom: extend the coverage of OOM

PATCH Superseded Zhouping Liu 2 participants 13 messages Mar 18, 2013 – Mar 20, 2013

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover mm/oom: extend the coverage of OOM

changed log from v1 to v2:
1. added a new is_numa() function instead of ISNUMA global variable;
2. added new patch to remove the prefix underscroe '_' of the

    internal function name;

3. used SAFE_FILE_SCANF() instead of read_file().
4. some cleanup...

changed log from v2 to v3:
1. as Jan's suggestion, pass 'nodes=NULL' to get_allowed_nodes_arr() in is_numa(), and free 'nodes' variable when it passed a non-NULL value inside testoom().

The patch set updated all OOM testcases, and added a new testcase.

Inside old version, OOM only test MPOL_MBIND mempolicy in NUMA system, and the combination of CPUSET, MEMCG & NUMA is complex, and not clear. Also CPUSET is only used in NUMA system.

These patch set adjust them, now we can coverage the below tests:
1) OOM under normal - oom01
2) OOM under all mempolicy - oom02
3) OOM under MEMCG (+ mempolicy) - oom03
4) OOM under CPUSET (+ mempolicy) - oom04
5) OOM under CPUSET & MEMCG - oom05

tested the V2 patch set, no regression found.

Zhouping Liu (7):
lib/mem: modified _gather_cpus() as _gather_node_cpus() mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy'
numa_helper: added a new function is_numa() mm/oom0[3|4]: added 'OOM for CPUSET' and moved 'OOM with MEMCG &
numa' to oom03
lib/mem: updated testoom() and oom() funcs
mm/oom05: new testcase
lib/mem: removed the prefix underscore '_' of the internal function
name

 runtest/mm                             |   1 +
 testcases/kernel/include/numa_helper.h |   1 +
 testcases/kernel/lib/numa_helper.c     |  24 ++++++
 testcases/kernel/mem/include/mem.h     |   4 +-
 testcases/kernel/mem/lib/mem.c         | 147 +++++++++++++++++++++------------
 testcases/kernel/mem/oom/oom01.c       |   6 +-
 testcases/kernel/mem/oom/oom02.c       |  20 +++--
 testcases/kernel/mem/oom/oom03.c       |  24 +++++-
 testcases/kernel/mem/oom/oom04.c       |  60 ++++++--------
 testcases/kernel/mem/oom/oom05.c       | 147 +++++++++++++++++++++++++++++++++
 10 files changed, 329 insertions(+), 105 deletions(-)
 create mode 100644 testcases/kernel/mem/oom/oom05.c
Signature · 12 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

PATCH v3 1/7 lib/mem: modified _gather_cpus() as _gather_node_cpus()

The previous _gather_cpus() tried to collect all the specified node's cpus, but it didn't pay attention to the offline cpus, if one cpu in the specified node were offline, it can't write the cpu number to cgroups/*.cpus, and return -EINVAL.

The patch fixed it, and modified the function name, as the new name make more sense.

---
 testcases/kernel/mem/lib/mem.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
testcases/kernel/mem/lib/mem.c +22 -4
index a827b25..72ac06d 100644
@@ -20,6 +20,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "safe_file_ops.h"
 #include "_private.h"
 #include "mem.h"
 #include "numa_helper.h"
@@ -481,20 +482,37 @@ void ksm_usage(void)
 
 /* cpuset/memcg */
 
-static void _gather_cpus(char *cpus, long nd)
+static void _gather_node_cpus(char *cpus, long nd)
 {
 	int ncpus = 0;
 	int i;
+	long online;
 	char buf[BUFSIZ];
+	char path[BUFSIZ], path1[BUFSIZ];
 
 	while (path_exist(PATH_SYS_SYSTEM "/cpu/cpu%d", ncpus))
 		ncpus++;
 
-	for (i = 0; i < ncpus; i++)
-		if (path_exist(PATH_SYS_SYSTEM "/node/node%ld/cpu%d", nd, i)) {
+	for (i = 0; i < ncpus; i++) {
+		snprintf(path, BUFSIZ,
+			 PATH_SYS_SYSTEM "/node/node%ld/cpu%d", nd, i);
+		if (path_exist(path, nd, i)) {
+			snprintf(path1, BUFSIZ, "%s/online", path);
+			/*
+			 * No cpu0/online knob, as it can't support to
+			 * on/offline cpu0, so if the 'nd' node contains
+			 * cpu0, it should skip to check cpu0/online's value.
+			 */
+			if (i == 0)
+				goto next;
+			SAFE_FILE_SCANF(cleanup, path1, "%ld", &online);
+			if (online == 0)
+				continue;
+next:
 			sprintf(buf, "%d,", i);
 			strcat(cpus, buf);
 		}
+	}
 	/* Remove the trailing comma. */
 	cpus[strlen(cpus) - 1] = '\0';
 }
@@ -563,7 +581,7 @@ void write_cpusets(long nd)
 	snprintf(buf, BUFSIZ, "%ld", nd);
 	write_cpuset_files(CPATH_NEW, "mems", buf);
 
-	_gather_cpus(cpus, nd);
+	_gather_node_cpus(cpus, nd);
 	write_cpuset_files(CPATH_NEW, "cpus", cpus);
 
 	snprintf(buf, BUFSIZ, "%d", getpid());
Signature · 12 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#2 lore raw

PATCH v3 2/7 mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy'

NUMA mechanism can be interpreted as 'memory policy', there are several mempolicys, such as MPOL_BIND, MPOL_INTERLEAVE, MPOL_PREFERRED etc, not only MPOL_BIND, so the patch extended OOM on NUMA system, added MPOL_INTERLEAVE and MPOL_PREFERRED mempolicy.

And the patch also moved 'set_mempolicy()' from child process, and made it executed inside testoom() func, which is easy to control.

---
 testcases/kernel/mem/lib/mem.c   | 58 ++++++++++++++++++++++++++++------------
 testcases/kernel/mem/oom/oom02.c | 20 +++++++++-----
 2 files changed, 54 insertions(+), 24 deletions(-)
testcases/kernel/mem/lib/mem.c +41 -17
index 72ac06d..0b8974c 100644
@@ -65,32 +65,17 @@ void oom(int testcase, int mempolicy, int lite)
 {
 	pid_t pid;
 	int status;
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
-	unsigned long nmask = 0;
-	unsigned int node;
-
-	if (mempolicy)
-		node = get_a_numa_node(cleanup);
-	nmask += 1 << node;
-#endif
 
 	switch (pid = fork()) {
 	case -1:
 		tst_brkm(TBROK | TERRNO, cleanup, "fork");
 	case 0:
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
-		if (mempolicy)
-			if (set_mempolicy(MPOL_BIND, &nmask, MAXNODES) == -1)
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "set_mempolicy");
-#endif
 		_test_alloc(testcase, lite);
 		exit(0);
 	default:
 		break;
 	}
+
 	tst_resm(TINFO, "expected victim is %d.", pid);
 	if (waitpid(-1, &status, 0) == -1)
 		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
@@ -108,7 +93,46 @@ void oom(int testcase, int mempolicy, int lite)
 
 void testoom(int mempolicy, int lite, int numa)
 {
-	long nodes[MAXNODES];
+#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
+	&& HAVE_MPOL_CONSTANTS
+	unsigned long nmask = 0;
+	unsigned int num_nodes, *nodes;
+	int ret;
+
+	if (mempolicy) {
+		ret = get_allowed_nodes_arr(NH_MEMS|NH_CPUS, &num_nodes, &nodes);
+		if (ret != 0)
+			tst_brkm(TBROK|TERRNO, cleanup,
+				 "get_allowed_nodes_arr");
+		if (num_nodes < 2) {
+			tst_resm(TINFO, "mempolicy need NUMA system support");
+			free(nodes);
+			return;
+		}
+		switch(mempolicy) {
+		case MPOL_BIND:
+			/* bind the second node */
+			nmask = 1 << nodes[1];
+			break;
+		case MPOL_INTERLEAVE:
+		case MPOL_PREFERRED:
+			if (num_nodes == 2) {
+				tst_resm(TINFO, "The mempolicy need "
+					 "more than 2 numa nodes");
+				free(nodes);
+				return;
+			} else {
+				/* Using the 2nd,3rd node */
+				nmask = (1 << nodes[1]) | (1 << nodes[2]);
+			}
+			break;
+		default:
+			tst_brkm(TBROK|TERRNO, cleanup, "Bad mempolicy mode");
+		}
+		if (set_mempolicy(mempolicy, &nmask, MAXNODES) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "set_mempolicy");
+	}
+#endif
 
 	if (numa && !mempolicy)
 		write_cpusets(get_a_numa_node(cleanup));
testcases/kernel/mem/oom/oom02.c +13 -7
index abd8aa2..31ec73f 100644
@@ -1,5 +1,5 @@
 /*
- * Out Of Memory (OOM) for NUMA
+ * Out Of Memory (OOM) for mempolicy - need NUMA system support
  *
  * The program is designed to cope with unpredictable like amount and
  * system physical memory, swap size and other VMM technology like KSM,
@@ -44,6 +44,8 @@ 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;
@@ -62,11 +64,14 @@ int main(int argc, char *argv[])
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		tst_count = 0;
 
-		tst_resm(TINFO, "process mempolicy.");
-		testoom(1, 0, 1);
+		tst_resm(TINFO, "OOM on MPOL_BIND mempolicy...");
+		testoom(MPOL_BIND, 0, 1);
+
+		tst_resm(TINFO, "OOM on MPOL_INTERLEAVE mempolicy...");
+		testoom(MPOL_INTERLEAVE, 0, 1);
 
-		tst_resm(TINFO, "process cpuset.");
-		testoom(0, 0, 1);
+		tst_resm(TINFO, "OOM on MPOL_PREFERRED mempolicy...");
+		testoom(MPOL_PREFERRED, 0, 1);
 	}
 	cleanup();
 	tst_exit();
@@ -78,15 +83,16 @@ void setup(void)
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 	TEST_PAUSE;
 
+	/* Judge a NUMA system through get_a_numa_node */
+	get_a_numa_node(NULL);
+
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
-	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
 }
 
 void cleanup(void)
 {
 	set_sys_tune("overcommit_memory", overcommit, 0);
-	umount_mem(CPATH, CPATH_NEW);
 
 	TEST_CLEANUP;
 }
Signature · 12 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#3 lore raw

PATCH v3 3/7 numa_helper: added a new function is_numa()

Added a new function is_numa(), which is desinged to judge whether a system contains more than 1 available numa nodes or not, and lots of cases need it.

---
 testcases/kernel/include/numa_helper.h |  1 +
 testcases/kernel/lib/numa_helper.c     | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)
testcases/kernel/include/numa_helper.h +1 -0
index 8e82d7b..251fd54 100644
@@ -34,5 +34,6 @@ unsigned long get_max_node(void);
 int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes);
 int get_allowed_nodes(int flag, int count, ...);
 void nh_dump_nodes();
+int is_numa(void (*cleanup_fn)(void));
 
 #endif
testcases/kernel/lib/numa_helper.c +24 -0
index 4ab8e3c..4157816 100644
@@ -265,3 +265,27 @@ void nh_dump_nodes()
 	print_node_info(NH_CPUS);
 	print_node_info(NH_MEMS | NH_CPUS);
 }
+
+/*
+ * is_numa - judge a system is NUMA system or not
+ * NOTE: the function is designed to try to find more than
+ *       1 available node, at least each node contains memory.
+ * WARN: Don't use this func in child, as it calls tst_brkm()
+ * RETURNS:
+ *     0 - it's not a NUMA system
+ *     1 - it's a NUMA system
+ */
+int is_numa(void (*cleanup_fn)(void))
+{
+	int ret;
+	int numa_nodes = 0;
+
+	ret = get_allowed_nodes_arr(NH_MEMS, &numa_nodes, NULL);
+	if (ret < 0)
+		tst_brkm(TBROK | TERRNO, cleanup_fn, "get_allowed_nodes_arr");
+
+	if (numa_nodes > 1)
+		return 1;
+	else
+		return 0;
+}
Signature · 12 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#4 lore raw

PATCH v3 4/7 mm/oom0[3|4]: added 'OOM for CPUSET' and moved 'OOM with MEMCG & numa' to oom03

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

also used is_numa() instead of the old method.

---
 testcases/kernel/mem/oom/oom02.c |  6 ++--
 testcases/kernel/mem/oom/oom03.c | 20 ++++++++++++++
 testcases/kernel/mem/oom/oom04.c | 60 +++++++++++++++-------------------------
 3 files changed, 46 insertions(+), 40 deletions(-)
testcases/kernel/mem/oom/oom02.c +3 -3
index 31ec73f..3bc8567 100644
@@ -35,6 +35,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include "numa_helper.h"
 #include "test.h"
 #include "usctest.h"
 #include "mem.h"
@@ -44,7 +45,6 @@ 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[])
 {
@@ -83,8 +83,8 @@ void setup(void)
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 	TEST_PAUSE;
 
-	/* Judge a NUMA system through get_a_numa_node */
-	get_a_numa_node(NULL);
+	if (!is_numa(NULL))
+		tst_brkm(TCONF, NULL, "The case need a NUMA system.");
 
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
testcases/kernel/mem/oom/oom03.c +20 -0
index 95e34d5..c2171fd 100644
@@ -33,6 +33,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include "numa_helper.h"
 #include "test.h"
 #include "usctest.h"
 #include "mem.h"
@@ -40,6 +41,9 @@
 char *TCID = "oom03";
 int TST_TOTAL = 1;
 
+#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
+	&& HAVE_MPOL_CONSTANTS
+
 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 (is_numa(cleanup)) {
+			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();
@@ -99,3 +111,11 @@ void cleanup(void)
 
 	TEST_CLEANUP;
 }
+
+#else
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
+}
+#endif
+
testcases/kernel/mem/oom/oom04.c +23 -37

99 lines not on this page · raw message

Signature · 12 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#5 lore raw

PATCH v3 5/7 lib/mem: updated testoom() and oom() funcs

the 'numa' parameter inside testoom() and 'mempolicy' inside oom() were useless, so removed them.

---
 testcases/kernel/mem/include/mem.h |  4 ++--
 testcases/kernel/mem/lib/mem.c     | 13 +++++--------
 testcases/kernel/mem/oom/oom01.c   |  6 +++---
 testcases/kernel/mem/oom/oom02.c   |  6 +++---
 testcases/kernel/mem/oom/oom03.c   | 10 +++++-----
 testcases/kernel/mem/oom/oom04.c   |  4 ++--
 6 files changed, 20 insertions(+), 23 deletions(-)
testcases/kernel/mem/include/mem.h +2 -2
index 1233493..fdf558e 100644
@@ -25,8 +25,8 @@
 #define KSM			4
 
 long overcommit;
-void oom(int testcase, int mempolicy, int lite);
-void testoom(int mempolicy, int lite, int numa);
+void oom(int testcase, int lite);
+void testoom(int mempolicy, int lite);
 
 /* KSM */
 
testcases/kernel/mem/lib/mem.c +5 -8
index 0b8974c..2c2ab5d 100644
@@ -61,7 +61,7 @@ static void _test_alloc(int testcase, int lite)
 				return;
 }
 
-void oom(int testcase, int mempolicy, int lite)
+void oom(int testcase, int lite)
 {
 	pid_t pid;
 	int status;
@@ -91,7 +91,7 @@ void oom(int testcase, int mempolicy, int lite)
 	}
 }
 
-void testoom(int mempolicy, int lite, int numa)
+void testoom(int mempolicy, int lite)
 {
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
@@ -134,20 +134,17 @@ void testoom(int mempolicy, int lite, int numa)
 	}
 #endif
 
-	if (numa && !mempolicy)
-		write_cpusets(get_a_numa_node(cleanup));
-
 	tst_resm(TINFO, "start normal OOM testing.");
-	oom(NORMAL, mempolicy, lite);
+	oom(NORMAL, lite);
 
 	tst_resm(TINFO, "start OOM testing for mlocked pages.");
-	oom(MLOCK, mempolicy, lite);
+	oom(MLOCK, lite);
 
 	if (access(PATH_KSM, F_OK) == -1)
 		tst_brkm(TCONF, NULL, "KSM configuration is not enabled");
 
 	tst_resm(TINFO, "start OOM testing for KSM pages.");
-	oom(KSM, mempolicy, lite);
+	oom(KSM, lite);
 }
 
 /* KSM */
testcases/kernel/mem/oom/oom01.c +3 -3
index 0401e31..43a5319 100644
@@ -61,13 +61,13 @@ int main(int argc, char *argv[])
 		tst_count = 0;
 
 		set_sys_tune("overcommit_memory", 2, 1);
-		oom(OVERCOMMIT, 0, 0);
+		oom(OVERCOMMIT, 0);
 
 		set_sys_tune("overcommit_memory", 0, 1);
-		oom(OVERCOMMIT, 0, 0);
+		oom(OVERCOMMIT, 0);
 
 		set_sys_tune("overcommit_memory", 1, 1);
-		testoom(0, 0, 0);
+		testoom(0, 0);
 	}
 	cleanup();
 	tst_exit();
testcases/kernel/mem/oom/oom02.c +3 -3
index 3bc8567..1fd199b 100644
@@ -65,13 +65,13 @@ int main(int argc, char *argv[])
 		tst_count = 0;
 
 		tst_resm(TINFO, "OOM on MPOL_BIND mempolicy...");
-		testoom(MPOL_BIND, 0, 1);
+		testoom(MPOL_BIND, 0);
 
 		tst_resm(TINFO, "OOM on MPOL_INTERLEAVE mempolicy...");
-		testoom(MPOL_INTERLEAVE, 0, 1);
+		testoom(MPOL_INTERLEAVE, 0);
 
 		tst_resm(TINFO, "OOM on MPOL_PREFERRED mempolicy...");
-		testoom(MPOL_PREFERRED, 0, 1);
+		testoom(MPOL_PREFERRED, 0);
 	}
 	cleanup();
 	tst_exit();
testcases/kernel/mem/oom/oom03.c +5 -5
index c2171fd..d99534b 100644
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
 
 		snprintf(mem, BUFSIZ, "%ld", TESTMEM);
 		write_file(MEMCG_PATH_NEW "/memory.limit_in_bytes", mem);
-		testoom(0, 0, 0);
+		testoom(0, 0);
 
 		if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
 			if (errno == ENOENT)
@@ -78,15 +78,15 @@ int main(int argc, char *argv[])
 				tst_brkm(TBROK | TERRNO, cleanup, "access");
 		} else {
 			write_file(MEMCG_SW_LIMIT, mem);
-			testoom(0, 1, 0);
+			testoom(0, 1);
 		}
 
 		/* OOM for MEMCG with mempolicy */
 		if (is_numa(cleanup)) {
 			tst_resm(TINFO, "OOM on MEMCG & mempolicy...");
-			testoom(MPOL_BIND, 0, 1);
-			testoom(MPOL_INTERLEAVE, 0, 1);
-			testoom(MPOL_PREFERRED, 0, 1);
+			testoom(MPOL_BIND, 0);
+			testoom(MPOL_INTERLEAVE, 0);
+			testoom(MPOL_PREFERRED, 0);
 		}
 	}
 	cleanup();
testcases/kernel/mem/oom/oom04.c +2 -2
index 1ad7334..4d3f2f4 100644
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
 		tst_count = 0;
 
 		tst_resm(TINFO, "OOM on CPUSET...");
-		testoom(0, 0, 0);
+		testoom(0, 0);
 
 		if (is_numa(cleanup)) {
 			/*
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
 			write_cpuset_files(CPATH_NEW,
 					   "memory_migrate", "1");
 			tst_resm(TINFO, "OOM on CPUSET with mem migrate:");
-			testoom(0, 0, 0);
+			testoom(0, 0);
 		}
 	}
 	cleanup();
Signature · 12 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#6 lore raw

PATCH v3 6/7 mm/oom05: new testcase

added a new case to test OOM under the combination of MEMCG and CPUSET.

---
 runtest/mm                       |   1 +
 testcases/kernel/mem/oom/oom05.c | 147 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+)
 create mode 100644 testcases/kernel/mem/oom/oom05.c
runtest/mm +1 -0
index a8bd605..56b83f8 100644
@@ -77,6 +77,7 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+oom05 oom05
 
 swapping01 swapping01 -i 5
 
testcases/kernel/mem/oom/oom05.c new file +147 -0

147 lines not on this page · raw message

Signature · 12 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#7 lore raw

PATCH v3 7/7 lib/mem: removed the prefix underscore '_' of the internal function name

as chrubis' suggestion, the prefix that start with _ or __ are reserved for compiler/libc implementation, inside this patch, I removed all the prefix '_' of the internal function name.

---
 testcases/kernel/mem/lib/mem.c | 56 +++++++++++++++++++++---------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
testcases/kernel/mem/lib/mem.c +28 -28
index 2c2ab5d..c9525e5 100644
@@ -27,7 +27,7 @@
 
 /* OOM */
 
-static int _alloc_mem(long int length, int testcase)
+static int alloc_mem(long int length, int testcase)
 {
 	void *s;
 
@@ -51,13 +51,13 @@ static int _alloc_mem(long int length, int testcase)
 	return 0;
 }
 
-static void _test_alloc(int testcase, int lite)
+static void test_alloc(int testcase, int lite)
 {
 	if (lite)
-		_alloc_mem(TESTMEM + MB, testcase);
+		alloc_mem(TESTMEM + MB, testcase);
 	else
 		while (1)
-			if (_alloc_mem(LENGTH, testcase))
+			if (alloc_mem(LENGTH, testcase))
 				return;
 }
 
@@ -70,7 +70,7 @@ void oom(int testcase, int lite)
 	case -1:
 		tst_brkm(TBROK | TERRNO, cleanup, "fork");
 	case 0:
-		_test_alloc(testcase, lite);
+		test_alloc(testcase, lite);
 		exit(0);
 	default:
 		break;
@@ -149,7 +149,7 @@ void testoom(int mempolicy, int lite)
 
 /* KSM */
 
-static void _check(char *path, long int value)
+static void check(char *path, long int value)
 {
 	FILE *fp;
 	char buf[BUFSIZ], fullpath[BUFSIZ];
@@ -164,7 +164,7 @@ static void _check(char *path, long int value)
 		tst_resm(TFAIL, "%s is not %ld.", path, value);
 }
 
-static void _wait_ksmd_done(void)
+static void wait_ksmd_done(void)
 {
 	char buf[BUFSIZ];
 	long pages_shared, pages_sharing, pages_volatile, pages_unshared;
@@ -205,24 +205,24 @@ static void _wait_ksmd_done(void)
 		 count * 10);
 }
 
-static void _group_check(int run, int pages_shared, int pages_sharing,
+static void group_check(int run, int pages_shared, int pages_sharing,
 			 int pages_volatile, int pages_unshared,
 			 int sleep_millisecs, int pages_to_scan)
 {
 	/* wait for ksm daemon to scan all mergeable pages. */
-	_wait_ksmd_done();
+	wait_ksmd_done();
 
 	tst_resm(TINFO, "check!");
-	_check("run", run);
-	_check("pages_shared", pages_shared);
-	_check("pages_sharing", pages_sharing);
-	_check("pages_volatile", pages_volatile);
-	_check("pages_unshared", pages_unshared);
-	_check("sleep_millisecs", sleep_millisecs);
-	_check("pages_to_scan", pages_to_scan);
+	check("run", run);
+	check("pages_shared", pages_shared);
+	check("pages_sharing", pages_sharing);
+	check("pages_volatile", pages_volatile);
+	check("pages_unshared", pages_unshared);
+	check("sleep_millisecs", sleep_millisecs);
+	check("pages_to_scan", pages_to_scan);
 }
 
-static void _verify(char **memory, char value, int proc,
+static void verify(char **memory, char value, int proc,
 		    int start, int end, int start2, int end2)
 {
 	int i, j;
@@ -331,12 +331,12 @@ static void create_ksm_child(int child_num, int size, int unit,
 			tst_brkm(TBROK|TERRNO, tst_exit, "kill");
 
 		if (ksm_merge_data[j].mergeable_size < size * MB) {
-			_verify(memory, 'e', child_num, total_unit - 1,
+			verify(memory, 'e', child_num, total_unit - 1,
 				total_unit, unit * MB - 1, unit * MB);
-			_verify(memory, ksm_merge_data[j].data, child_num,
+			verify(memory, ksm_merge_data[j].data, child_num,
 				0, total_unit, 0, unit * MB - 1);
 		} else {
-			_verify(memory, ksm_merge_data[j].data, child_num,
+			verify(memory, ksm_merge_data[j].data, child_num,
 				0, total_unit, 0, unit * MB);
 		}
 	}
@@ -437,19 +437,19 @@ void create_same_memory(int size, int num, int unit)
 	write_file(PATH_KSM "sleep_millisecs", "0");
 
 	resume_ksm_children(child, num);
-	_group_check(1, 2, size * num * pages - 2, 0, 0, 0, size * pages * num);
+	group_check(1, 2, size * num * pages - 2, 0, 0, 0, size * pages * num);
 
 	stop_ksm_children(child, num);
 	resume_ksm_children(child, num);
-	_group_check(1, 3, size * num * pages - 3, 0, 0, 0, size * pages * num);
+	group_check(1, 3, size * num * pages - 3, 0, 0, 0, size * pages * num);
 
 	stop_ksm_children(child, num);
 	resume_ksm_children(child, num);
-	_group_check(1, 1, size * num * pages - 1, 0, 0, 0, size * pages * num);
+	group_check(1, 1, size * num * pages - 1, 0, 0, 0, size * pages * num);
 
 	stop_ksm_children(child, num);
 	resume_ksm_children(child, num);
-	_group_check(1, 1, size * num * pages - 2, 0, 1, 0, size * pages * num);
+	group_check(1, 1, size * num * pages - 2, 0, 1, 0, size * pages * num);
 
 	stop_ksm_children(child, num);
 
@@ -457,11 +457,11 @@ void create_same_memory(int size, int num, int unit)
 	write_file(PATH_KSM "run", "2");
 
 	resume_ksm_children(child, num);
-	_group_check(2, 0, 0, 0, 0, 0, size * pages * num);
+	group_check(2, 0, 0, 0, 0, 0, size * pages * num);
 
 	tst_resm(TINFO, "stop KSM.");
 	write_file(PATH_KSM "run", "0");
-	_group_check(0, 0, 0, 0, 0, 0, size * pages * num);
+	group_check(0, 0, 0, 0, 0, 0, size * pages * num);
 
 	while (waitpid(-1, &status, WUNTRACED | WCONTINUED) > 0)
 		if (WEXITSTATUS(status) != 0)
@@ -503,7 +503,7 @@ void ksm_usage(void)
 
 /* cpuset/memcg */
 
-static void _gather_node_cpus(char *cpus, long nd)
+static void gather_node_cpus(char *cpus, long nd)
 {
 	int ncpus = 0;
 	int i;
@@ -602,7 +602,7 @@ void write_cpusets(long nd)
 	snprintf(buf, BUFSIZ, "%ld", nd);
 	write_cpuset_files(CPATH_NEW, "mems", buf);
 
-	_gather_node_cpus(cpus, nd);
+	gather_node_cpus(cpus, nd);
 	write_cpuset_files(CPATH_NEW, "cpus", cpus);
 
 	snprintf(buf, BUFSIZ, "%d", getpid());
Signature · 12 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#9 lore raw

Re: [LTP] [PATCH v3 4/7] mm/oom0[3|4]: added 'OOM for CPUSET' and moved 'OOM with MEMCG & numa' to oom03

In reply to Zhouping Liu
Quoted 82 lines · Zhouping Liu

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

also used is_numa() instead of the old method.

---
 testcases/kernel/mem/oom/oom02.c |  6 ++--
 testcases/kernel/mem/oom/oom03.c | 20 ++++++++++++++
 testcases/kernel/mem/oom/oom04.c | 60 +++++++++++++++-------------------------
 3 files changed, 46 insertions(+), 40 deletions(-)
testcases/kernel/mem/oom/oom02.c +3 -3
index 31ec73f..3bc8567 100644
@@ -35,6 +35,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include "numa_helper.h"
 #include "test.h"
 #include "usctest.h"
 #include "mem.h"
@@ -44,7 +45,6 @@ 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[])
 {
@@ -83,8 +83,8 @@ void setup(void)
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 	TEST_PAUSE;
 
-	/* Judge a NUMA system through get_a_numa_node */
-	get_a_numa_node(NULL);
+	if (!is_numa(NULL))
+		tst_brkm(TCONF, NULL, "The case need a NUMA system.");
 
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
testcases/kernel/mem/oom/oom03.c +12 -0
index 95e34d5..c2171fd 100644
@@ -33,6 +33,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include "numa_helper.h"
 #include "test.h"
 #include "usctest.h"
 #include "mem.h"
@@ -40,6 +41,9 @@
 char *TCID = "oom03";
 int TST_TOTAL = 1;
 
+#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
+	&& HAVE_MPOL_CONSTANTS
+
 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 (is_numa(cleanup)) {
+			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();
@@ -99,3 +111,11 @@ void cleanup(void)
 

testcases/kernel/mem/oom/oom03.c void cleanup(void) · line 121

Quoted 10 lines
testcases/kernel/mem/oom/oom03.c +8 -0
 	TEST_CLEANUP;
 }
+
+#else
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
+}
+#endif
+

Here added a new line at EOF, if you want to just modify the patch, please remove this line, and change "@@ -99,3 +111,11" to "@@ -99,3 +111,10".

Thanks,
Wanlong Gao

Quoted 99 lines
testcases/kernel/mem/oom/oom04.c +23 -36
index bc51046..1ad7334 100644
@@ -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,
@@ -35,6 +35,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include "numa_helper.h"
 #include "test.h"
 #include "usctest.h"
 #include "mem.h"
@@ -44,12 +45,11 @@ int TST_TOTAL = 1;
 
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
+
 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 (is_numa(cleanup)) {
+			/*
+			 * 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();
@@ -110,15 +91,20 @@ 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);
+	if (is_numa(cleanup) > 0)
+		/* 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);

testcases/kernel/mem/oom/oom04.c void setup(void) · line 110

Quoted 10 lines
testcases/kernel/mem/oom/oom04.c +0 -1
 }
 
 void cleanup(void)
 {
 	set_sys_tune("overcommit_memory", overcommit, 0);
 	umount_mem(CPATH, CPATH_NEW);
-	umount_mem(MEMCG_PATH, MEMCG_PATH_NEW);
 
 	TEST_CLEANUP;
 }

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#8 lore raw

Re: [LTP] [PATCH v3 6/7] mm/oom05: new testcase

In reply to Zhouping Liu
Quoted 92 lines · Zhouping Liu

added a new case to test OOM under the combination of MEMCG and CPUSET.

---
 runtest/mm                       |   1 +
 testcases/kernel/mem/oom/oom05.c | 147 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+)
 create mode 100644 testcases/kernel/mem/oom/oom05.c
runtest/mm +1 -0
index a8bd605..56b83f8 100644
@@ -77,6 +77,7 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+oom05 oom05
 
 swapping01 swapping01 -i 5
 
testcases/kernel/mem/oom/oom05.c new file +64 -0
new file mode 100644
index 0000000..0176d42
@@ -0,0 +1,147 @@
+/*
+ * Out Of Memory (OOM) for MEMCG and CPUSET
+ *
+ * The program is designed to cope with unpredictable like amount and
+ * system physical memory, swap size and other VMM technology like KSM,
+ * memcg, memory hotplug and so on which may affect the OOM
+ * behaviours. It simply increase the memory consumption 3G each time
+ * until all the available memory is consumed and OOM is triggered.
+ *
+ * Copyright (C) 2013  Red Hat, Inc.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it
+ * is free of the rightful claim of any third person regarding
+ * infringement or the like.  Any license provided herein, whether
+ * implied or otherwise, applies only to this software file.  Patent
+ * licenses, if any, provided herein do not apply to combinations of
+ * this program with other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include "config.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include "numa_helper.h"
+#include "test.h"
+#include "usctest.h"
+#include "mem.h"
+
+char *TCID = "oom05";
+int TST_TOTAL = 1;
+
+#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
+	&& HAVE_MPOL_CONSTANTS
+
+int main(int argc, char *argv[])
+{
+	char *msg;
+	int lc;
+	int swap_acc_on = 1;
+	char mem[BUFSIZ];
+
+	msg = parse_opts(argc, argv, NULL, NULL);
+	if (msg != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+#if __WORDSIZE == 32
+	tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
+#endif
+
+	setup();

testcases/kernel/mem/oom/oom05.c line 74

Quoted 10 lines
testcases/kernel/mem/oom/oom05.c new file +10 -0
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+
+		tst_resm(TINFO, "OOM on CPUSET & MEMCG...");
+		testoom(0, 0);
+
+		/*
+		 * Under NUMA system, the migration of cpuset's memory
+ 		 * is in charge of cpuset.memory_migrate, we can write

This line has a space before tab warning.
If you should respin the patchset, please fix it, otherwise I can fix it by hand when applying the patch.

Thanks,
Wanlong Gao

Quoted 64 lines
testcases/kernel/mem/oom/oom05.c new file +63 -0
+		 * 1 to cpuset.memory_migrate to enable the migration.
+		 */
+		if (is_numa(cleanup)) {
+			write_cpuset_files(CPATH_NEW, "memory_migrate", "1");
+			tst_resm(TINFO, "OOM on CPUSET & MEMCG with "
+					"cpuset.memory_migrate=1");
+			testoom(0, 0);
+		}
+
+		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");
+		}
+
+		if (swap_acc_on) {
+			tst_resm(TINFO, "OOM on CPUSET & MEMCG with "
+					"special memswap limitation:");
+			snprintf(mem, BUFSIZ, "%ld", TESTMEM);
+			write_file(MEMCG_SW_LIMIT, mem);
+			testoom(0, 0);
+
+			tst_resm(TINFO, "OOM on CPUSET & MEMCG with "
+					"disabled memswap limitation:");
+			write_file(MEMCG_SW_LIMIT, "-1");
+			testoom(0, 0);
+		}
+	}
+
+	cleanup();
+	tst_exit();
+}
+
+void setup(void)
+{
+	tst_require_root(NULL);
+	tst_sig(FORK, DEF_HANDLER, cleanup);
+	TEST_PAUSE;
+
+	mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
+	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
+	write_memcg();
+
+	set_sys_tune("overcommit_memory", 1, 1);
+
+	if (is_numa(cleanup))
+		/* 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);
+
+	overcommit = get_sys_tune("overcommit_memory");
+}
+
+void cleanup(void)
+{
+	set_sys_tune("overcommit_memory", overcommit, 0);
+	umount_mem(CPATH, CPATH_NEW);
+	umount_mem(MEMCG_PATH, MEMCG_PATH_NEW);

testcases/kernel/mem/oom/oom05.c line 147

Quoted 10 lines
testcases/kernel/mem/oom/oom05.c new file +10 -0
+
+	TEST_CLEANUP;
+}
+
+#else /* no NUMA */
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
+}
+#endif

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Acked-by on the v3 series
#11 lore raw
In reply to Zhouping Liu
Quoted 18 lines · Zhouping Liu

changed log from v1 to v2:
1. added a new is_numa() function instead of ISNUMA global variable;
2. added new patch to remove the prefix underscroe '_' of the

    internal function name;

3. used SAFE_FILE_SCANF() instead of read_file().
4. some cleanup...

changed log from v2 to v3:
1. as Jan's suggestion, pass 'nodes=NULL' to get_allowed_nodes_arr() in is_numa(), and free 'nodes' variable when it passed a non-NULL value inside testoom().

The patch set updated all OOM testcases, and added a new testcase.

Inside old version, OOM only test MPOL_MBIND mempolicy in NUMA system, and the combination of CPUSET, MEMCG & NUMA is complex, and not clear. Also CPUSET is only used in NUMA system.

Quoted 8 lines

These patch set adjust them, now we can coverage the below tests:
1) OOM under normal - oom01
2) OOM under all mempolicy - oom02
3) OOM under MEMCG (+ mempolicy) - oom03
4) OOM under CPUSET (+ mempolicy) - oom04
5) OOM under CPUSET & MEMCG - oom05

tested the V2 patch set, no regression found.

For this series,

Quoted 12 lines

Zhouping Liu (7):
lib/mem: modified _gather_cpus() as _gather_node_cpus() mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy'
numa_helper: added a new function is_numa() mm/oom0[3|4]: added 'OOM for CPUSET' and moved 'OOM with MEMCG &
numa' to oom03
lib/mem: updated testoom() and oom() funcs
mm/oom05: new testcase
lib/mem: removed the prefix underscore '_' of the internal function
name

Quoted 13 lines
 runtest/mm                             |   1 +
 testcases/kernel/include/numa_helper.h |   1 +
 testcases/kernel/lib/numa_helper.c     |  24 ++++++
 testcases/kernel/mem/include/mem.h     |   4 +-
 testcases/kernel/mem/lib/mem.c         | 147 +++++++++++++++++++++------------
 testcases/kernel/mem/oom/oom01.c       |   6 +-
 testcases/kernel/mem/oom/oom02.c       |  20 +++--
 testcases/kernel/mem/oom/oom03.c       |  24 +++++-
 testcases/kernel/mem/oom/oom04.c       |  60 ++++++--------
 testcases/kernel/mem/oom/oom05.c       | 147 +++++++++++++++++++++++++++++++++
 10 files changed, 329 insertions(+), 105 deletions(-)
 create mode 100644 testcases/kernel/mem/oom/oom05.c

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#10 lore raw

Re: [LTP] [PATCH v3 4/7] mm/oom0[3|4]: added 'OOM for CPUSET' and moved 'OOM with MEMCG & numa' to oom03

In reply to Wanlong Gao

----- Original Message -----

Quoted 92 lines

From: "Wanlong Gao" <[email protected]>
To: "Zhouping Liu" <[email protected]>
Cc: "LTP List" <[email protected]>
Sent: Tuesday, March 19, 2013 11:10:27 AM
Subject: Re: [LTP] [PATCH v3 4/7] mm/oom0[3|4]: added 'OOM for CPUSET' and moved 'OOM with MEMCG & numa' to oom03

Quoted 85 lines · Zhouping Liu

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

also used is_numa() instead of the old method.

---
 testcases/kernel/mem/oom/oom02.c |  6 ++--
 testcases/kernel/mem/oom/oom03.c | 20 ++++++++++++++
 testcases/kernel/mem/oom/oom04.c | 60
 +++++++++++++++-------------------------
 3 files changed, 46 insertions(+), 40 deletions(-)
testcases/kernel/mem/oom/oom02.c +3 -3
index 31ec73f..3bc8567 100644
@@ -35,6 +35,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include "numa_helper.h"
 #include "test.h"
 #include "usctest.h"
 #include "mem.h"
@@ -44,7 +45,6 @@ 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[])
 {
@@ -83,8 +83,8 @@ void setup(void)
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 	TEST_PAUSE;
 
-	/* Judge a NUMA system through get_a_numa_node */
-	get_a_numa_node(NULL);
+	if (!is_numa(NULL))
+		tst_brkm(TCONF, NULL, "The case need a NUMA system.");
 
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
testcases/kernel/mem/oom/oom03.c +12 -0
index 95e34d5..c2171fd 100644
@@ -33,6 +33,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include "numa_helper.h"
 #include "test.h"
 #include "usctest.h"
 #include "mem.h"
@@ -40,6 +41,9 @@
 char *TCID = "oom03";
 int TST_TOTAL = 1;
 
+#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
+	&& HAVE_MPOL_CONSTANTS
+
 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 (is_numa(cleanup)) {
+			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();
@@ -99,3 +111,11 @@ void cleanup(void)
 
Quoted 15 lines

testcases/kernel/mem/oom/oom03.c void cleanup(void) · line 121

Quoted 10 lines
testcases/kernel/mem/oom/oom03.c +8 -0
 	TEST_CLEANUP;
 }
+
+#else
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
+}
+#endif
+

Here added a new line at EOF, if you want to just modify the patch, please remove this line, and change "@@ -99,3 +111,11" to "@@ -99,3 +111,10".

Wanlong, thanks for your reviewing, I will prepare V4.

Signature · 12 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Acked-by on the v3 series
#12 lore raw
In reply to Zhouping Liu
Quoted 18 lines · Zhouping Liu

changed log from v1 to v2:
1. added a new is_numa() function instead of ISNUMA global variable;
2. added new patch to remove the prefix underscroe '_' of the

    internal function name;

3. used SAFE_FILE_SCANF() instead of read_file().
4. some cleanup...

changed log from v2 to v3:
1. as Jan's suggestion, pass 'nodes=NULL' to get_allowed_nodes_arr() in is_numa(), and free 'nodes' variable when it passed a non-NULL value inside testoom().

The patch set updated all OOM testcases, and added a new testcase.

Inside old version, OOM only test MPOL_MBIND mempolicy in NUMA system, and the combination of CPUSET, MEMCG & NUMA is complex, and not clear. Also CPUSET is only used in NUMA system.

Quoted 8 lines

These patch set adjust them, now we can coverage the below tests:
1) OOM under normal - oom01
2) OOM under all mempolicy - oom02
3) OOM under MEMCG (+ mempolicy) - oom03
4) OOM under CPUSET (+ mempolicy) - oom04
5) OOM under CPUSET & MEMCG - oom05

tested the V2 patch set, no regression found.

Quoted 12 lines

Zhouping Liu (7):
lib/mem: modified _gather_cpus() as _gather_node_cpus() mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy'
numa_helper: added a new function is_numa() mm/oom0[3|4]: added 'OOM for CPUSET' and moved 'OOM with MEMCG &
numa' to oom03
lib/mem: updated testoom() and oom() funcs
mm/oom05: new testcase
lib/mem: removed the prefix underscore '_' of the internal function
name

Quoted 13 lines
 runtest/mm                             |   1 +
 testcases/kernel/include/numa_helper.h |   1 +
 testcases/kernel/lib/numa_helper.c     |  24 ++++++
 testcases/kernel/mem/include/mem.h     |   4 +-
 testcases/kernel/mem/lib/mem.c         | 147 +++++++++++++++++++++------------
 testcases/kernel/mem/oom/oom01.c       |   6 +-
 testcases/kernel/mem/oom/oom02.c       |  20 +++--
 testcases/kernel/mem/oom/oom03.c       |  24 +++++-
 testcases/kernel/mem/oom/oom04.c       |  60 ++++++--------
 testcases/kernel/mem/oom/oom05.c       | 147 +++++++++++++++++++++++++++++++++
 10 files changed, 329 insertions(+), 105 deletions(-)
 create mode 100644 testcases/kernel/mem/oom/oom05.c

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list