If NUMA node number is not continuous, such as: [root@localhost ~]# numactl -H available: 4 nodes (1,3,5,7) ... the node numbers are 1 3 5 7
Or it is not begin with 0, such as: [root@localhost ~]# numactl -H available: 3 nodes (1-3) ... it's begin with 1 not 0 Under the above two cases, count_numa() will return a wrong number: 0 Signed-off-by: Zhouping Liu <[email protected]> --- testcases/kernel/mem/lib/mem.c | 9 +++++++-- testcases/kernel/mem/oom/oom02.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index cce7751..25cdfd4 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -16,6 +16,7 @@ #include "safe_macros.h" #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \ && HAVE_MPOL_CONSTANTS +#include <numa.h> #include <numaif.h> #endif @@ -150,9 +151,13 @@ void testoom(int mempolicy, int lite, int numa) long count_numa(void) { int nnodes = 0; + int max_node; + int i; - while(path_exist(PATH_SYS_SYSTEM "/node/node%d", nnodes)) - nnodes++; + max_node = numa_max_node(); + for(i = 0; i <= max_node; i++) + if(path_exist(PATH_SYS_SYSTEM "/node/node%d", i)) + nnodes++; return nnodes; } diff --git a/testcases/kernel/mem/oom/oom02.c b/testcases/kernel/mem/oom/oom02.c index d867dcb..585ffbf 100644 --- a/testcases/kernel/mem/oom/oom02.c +++ b/testcases/kernel/mem/oom/oom02.c @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) #endif nnodes = count_numa(); - if (count_numa() <= 1) + if (nnodes <= 1) tst_brkm(TCONF, NULL, "required a NUMA system."); setup(); -- 1.7.7.6 ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
