mm/oom: extend the coverage of OOM
v2 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...
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 | 25 ++++++ testcases/kernel/mem/include/mem.h | 4 +- testcases/kernel/mem/lib/mem.c | 145 ++++++++++++++++++++------------ 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, 328 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
PATCH v2 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
@@ -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
PATCH v2 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 | 56 ++++++++++++++++++++++++++++------------ testcases/kernel/mem/oom/oom02.c | 20 +++++++++----- 2 files changed, 52 insertions(+), 24 deletions(-)
testcases/kernel/mem/lib/mem.c +39 -17
@@ -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,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; +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));
testcases/kernel/mem/oom/oom02.c +13 -7
@@ -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
PATCH v2 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 | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+)
testcases/kernel/include/numa_helper.h +1 -0
@@ -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 +25 -0
@@ -265,3 +265,28 @@ 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 ; +int *nodes =NULL ; + + ret =get_allowed_nodes_arr (NH_MEMS , &numa_nodes, &nodes); +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
PATCH v2 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
@@ -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
@@ -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
PATCH v2 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
@@ -25,8 +25,8 @@#define KSM 4long 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
@@ -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
@@ -132,20 +132,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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 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
@@ -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
PATCH v2 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
@@ -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 ;
@@ -147,7 +147,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 ];
@@ -162,7 +162,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;
@@ -203,24 +203,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;
@@ -329,12 +329,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 ); } }
@@ -435,19 +435,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);
@@ -455,11 +455,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 )
@@ -501,7 +501,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;
@@ -600,7 +600,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
Re: [LTP] [PATCH v2 3/7] numa_helper: added a new function is_numa()
In reply to Zhouping Liu----- Original Message -----
Quoted 44 lines
From: "Zhouping Liu" <[email protected]>
To: "LTP List" <[email protected]>
Sent: Friday, 15 March, 2013 4:03:08 PM
Subject: [LTP] [PATCH v2 3/7]numa_helper: added a new functionis_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.Signed-off-by Zhouping Liu <[email protected]>--- testcases/kernel/include/numa_helper.h | 1 + testcases/kernel/lib/numa_helper.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+)testcases/kernel/include/numa_helper.h +1
-0@@ -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 +7
-0@@ -265,3 +265,28 @@ 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:
testcases/kernel/lib/numa_helper.c void nh_dump_nodes() · line 284
Quoted 10 lines
testcases/kernel/lib/numa_helper.c +10
-0+* 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 ; +int *nodes =NULL ; + + ret =get_allowed_nodes_arr (NH_MEMS , &numa_nodes, &nodes);
If you don't need node ids, you can pass NULL:
ret = get_allowed_nodes_arr(NH_MEMS, &numa_nodes, NULL);
Otherwise you should free 'nodes' variable.
Quoted 12 lines
testcases/kernel/lib/numa_helper.c +8
-1+if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup_fn,"get_allowed_nodes_arr" ); + +if (numa_nodes >1 ) +return 1 ; +else +return 0 ; +} --1.7.11.7
Quoted 10 lines
------------------------------------------------------------------------------
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
------------------------------------------------------------------------------
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
Re: [LTP] [PATCH v2 3/7] numa_helper: added a new function is_numa()
----- Original Message -----
Quoted 66 lines
From: "Jan Stancek" <[email protected]>
To: "Zhouping Liu" <[email protected]>
Cc: "LTP List" <[email protected]>
Sent: Saturday, March 16, 2013 12:09:57 AM
Subject: Re: [LTP] [PATCH v2 3/7]numa_helper: added a new functionis_numa()----- Original Message -----
Quoted 45 lines
From: "Zhouping Liu" <[email protected]>
To: "LTP List" <[email protected]>
Sent: Friday, 15 March, 2013 4:03:08 PM
Subject: [LTP] [PATCH v2 3/7]numa_helper: added a new functionis_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.Signed-off-by Zhouping Liu <[email protected]>--- testcases/kernel/include/numa_helper.h | 1 + testcases/kernel/lib/numa_helper.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+)testcases/kernel/include/numa_helper.h +1
-0@@ -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 +7
-0@@ -265,3 +265,28 @@ 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: testcases/kernel/lib/numa_helper.c void nh_dump_nodes() · line 284
Quoted 10 lines
testcases/kernel/lib/numa_helper.c +10
-0+* 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 ; +int *nodes =NULL ; + + ret =get_allowed_nodes_arr (NH_MEMS , &numa_nodes, &nodes);If you don't need node ids, you can pass NULL:
Quoted 2 lines
ret = get_allowed_nodes_arr(NH_MEMS, &numa_nodes, NULL);Otherwise you should free 'nodes' variable.
OK, I will free 'nodes' variable in V3.
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