* 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
* [LTP] [PATCH 1/5] lib/mem: modified _gather_cpus() as _gather_node_cpus() 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:21 ` [LTP] [PATCH 2/5] mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy' Zhouping Liu 0 siblings, 1 reply; 6+ messages in thread From: Zhouping Liu @ 2013-03-14 16:21 UTC (permalink / raw) To: LTP List 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. Signed-off-by: Zhouping Liu <zliu@redhat.com> --- testcases/kernel/mem/lib/mem.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index a827b25..29de64a 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -481,20 +481,42 @@ 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; + int fd, 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; + fd = open(path1, O_RDONLY); + if (fd == -1) + tst_brkm(TBROK|TERRNO, cleanup, + "open %s", path1); + read_file(path1, buf); + online = SAFE_STRTOL(cleanup, buf, 0, 1); + if (online == 0) + continue; +next: sprintf(buf, "%d,", i); strcat(cpus, buf); } + } /* Remove the trailing comma. */ cpus[strlen(cpus) - 1] = '\0'; } @@ -563,7 +585,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()); -- 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
* [LTP] [PATCH 2/5] mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy' 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:21 ` [LTP] [PATCH 0/5] mm/oom: extend the coverage of OOM Zhouping Liu 0 siblings, 1 reply; 6+ messages in thread From: Zhouping Liu @ 2013-03-14 16:21 UTC (permalink / raw) To: LTP List 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. Signed-off-by: Zhouping Liu <zliu@redhat.com> --- testcases/kernel/mem/lib/mem.c | 56 ++++++++++++++++++++++++++++------------ testcases/kernel/mem/oom/oom02.c | 20 +++++++++----- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index 29de64a..a71bc90 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -64,32 +64,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"); @@ -107,7 +92,44 @@ 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[MAXNODES]; + 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"); + 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"); + 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)); diff --git a/testcases/kernel/mem/oom/oom02.c b/testcases/kernel/mem/oom/oom02.c index abd8aa2..31ec73f 100644 --- a/testcases/kernel/mem/oom/oom02.c +++ b/testcases/kernel/mem/oom/oom02.c @@ -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; } -- 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
* [LTP] [PATCH 0/5] mm/oom: extend the coverage of OOM @ 2013-03-14 16:21 ` 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 0 siblings, 1 reply; 6+ messages in thread From: Zhouping Liu @ 2013-03-14 16:21 UTC (permalink / raw) To: LTP List 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. The 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 - oom03 4) OOM under CPUSET - oom04 5) OOM under CPUSET & MEMCG - oom05 I have tested the patch set, no any regressions found. Zhouping Liu (5): lib/mem: modified _gather_cpus() as _gather_node_cpus() mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy' mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa' lib/mem: updated testoom() and oom() funcs mm/oom05: new testcase runtest/mm | 1 + testcases/kernel/mem/include/mem.h | 6 +- testcases/kernel/mem/lib/mem.c | 101 ++++++++++++++++++------- testcases/kernel/mem/oom/oom01.c | 6 +- testcases/kernel/mem/oom/oom02.c | 20 +++-- testcases/kernel/mem/oom/oom03.c | 28 ++++++- testcases/kernel/mem/oom/oom04.c | 63 +++++++--------- testcases/kernel/mem/oom/oom05.c | 151 +++++++++++++++++++++++++++++++++++++ 8 files changed, 296 insertions(+), 80 deletions(-) create mode 100644 testcases/kernel/mem/oom/oom05.c -- 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 [flat|nested] 6+ messages in thread
* [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
[parent not found: <507561236.18941341.1363282016883.JavaMail.root@redhat.com>]
* 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
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