numa_helper: get nodes with mem/cpu/both
PATCH 1/2 numa_helper: add flag to get_allowed_nodes()
In reply to Jan Stancekadd flag, so testcases can request nodes with available memory/cpus or both.
Also add small debug function.
--- testcases/kernel/syscalls/numa/lib/numa_helper.c | 211 ++++++++++++++++------ testcases/kernel/syscalls/numa/lib/numa_helper.h | 8 +- 2 files changed, 162 insertions(+), 57 deletions(-)
testcases/kernel/syscalls/numa/lib/numa_helper.c +156 -55
@@ -27,6 +27,7 @@#include <stdarg.h> #include <stdio.h> #include <string.h> +#include <stdlib.h> #include <unistd.h> #include <errno.h>
@@ -36,26 +37,10 @@#include "numa_helper.h" #include "linux_syscall_numbers.h" -/* -* get_allowed_nodes_arr - get number and array of available nodes -* @num_allowed_nodes: pointer where number of available nodes will be stored -* @allowed_nodes: array of available node ids, this is MPOL_F_MEMS_ALLOWED -* node bitmask compacted (without holes), so that each field -* contains node number. If NULL only num_allowed_nodes is -* returned, otherwise it cotains new allocated array, -* which caller is responsible to free. -* RETURNS: -* 0 on success -* -1 on allocation failure -* -2 on get_mempolicy failure -*/ -int get_allowed_nodes_arr (int *num_allowed_nodes,int **allowed_nodes) -{#if HAVE_NUMA_H -int i; -nodemask_t *allowed_nodemask =NULL ; -unsigned long max_node; - +static unsigned long get_max_node () +{ +unsigned long max_node =0 ;#if !defined(LIBNUMA_API_VERSION ) ||LIBNUMA_API_VERSION <2 max_node =NUMA_NUM_NODES ;/*
@@ -68,61 +53,150 @@ int get_allowed_nodes_arr(int *num_allowed_nodes, int **allowed_nodes)#else max_node =numa_max_possible_node () +1 ;#endif -#endif /* HAVE_NUMA_H */ +return max_node; +} - *num_allowed_nodes =0 ; -if (allowed_nodes) - *allowed_nodes =NULL ; +static void get_nodemask_allnodes (nodemask_t *nodemask, +unsigned long max_node) +{ +unsigned long nodemask_size = max_node/8 +1 ; +int i; +char fn[64 ]; +struct stat st; -#if HAVE_NUMA_H - allowed_nodemask =malloc (max_node/8 +1 ); -if (allowed_nodemask ==NULL ) -return -1 ; -nodemask_zero (allowed_nodemask); - -if (allowed_nodes) { - *allowed_nodes =malloc (sizeof (int )*max_node); -if (*allowed_nodes ==NULL ) { -free (allowed_nodemask); -return -1 ; - } +memset (nodemask,0 , nodemask_size); +for (i =0 ; i < max_node; i++) { +sprintf (fn,"/sys/devices/system/node/node%d" , i); +if (stat (fn, &st) ==0 ) +nodemask_set (nodemask, i); } +} +static int filter_nodemask_mem (nodemask_t *nodemask,unsigned long max_node) +{#if MPOL_F_MEMS_ALLOWED +unsigned long nodemask_size = max_node/8 +1 ; +memset (nodemask,0 , nodemask_size);/* * avoid numa_get_mems_allowed(), because of bug in getpol() * utility function in older versions: * http://www.spinics.net/lists/linux-numa/msg00849.html */ -if (syscall (__NR_get_mempolicy,NULL , allowed_nodemask->n, - max_node,0 ,MPOL_F_MEMS_ALLOWED ) <0 ) { -free (allowed_nodemask); -if (allowed_nodes) { -free (*allowed_nodes); - *allowed_nodes =NULL ; - } +if (syscall (__NR_get_mempolicy,NULL , nodemask->n, + max_node,0 ,MPOL_F_MEMS_ALLOWED ) <0 )return -2 ; - }#else +int i;/* * old libnuma/kernel don't have MPOL_F_MEMS_ALLOWED, so let's assume * that we can use any node with memory > 0 */ -for (i =0 ; i < max_node; i++) -if (numa_node_size64 (i,NULL ) >0 ) -nodemask_set (allowed_nodemask, i); - +for (i =0 ; i < max_node; i++) { +if (!nodemask_isset (nodemask, i)) +continue ; +if (numa_node_size64 (i,NULL ) <=0 ) +nodemask_clr (nodemask, i); + }#endif /* MPOL_F_MEMS_ALLOWED */ +return 0 ; +} + +static int cpumask_has_cpus (char *cpumask,size_t len) +{ +int j; +for (j =0 ; j < len; j++) +if (cpumask[j] =='\0' ) +return 0 ; +else if ((cpumask[j] >'0' && cpumask[j] <='9' ) || + (cpumask[j] >='a' && cpumask[j] <='f' )) +return 1 ; +return 0 ; + +} + +static void filter_nodemask_cpu (nodemask_t *nodemask,unsigned long max_node) +{ +char *cpumask =NULL ; +char fn[64 ]; +FILE *f; +size_t len; +int i, ret; +for (i =0 ; i < max_node; i++) { -if (nodemask_isset (allowed_nodemask, i)) { -if (allowed_nodes) - (*allowed_nodes)[*num_allowed_nodes] = i; - (*num_allowed_nodes)++; +if (!nodemask_isset (nodemask, i)) +continue ; +sprintf (fn,"/sys/devices/system/node/node%d/cpumap" , i); + f =fopen (fn,"r" ); +if (f) { + ret =getdelim (&cpumask, &len,'\n' , f); +if ((ret >0 ) && (!cpumask_has_cpus (cpumask, len))) +nodemask_clr (nodemask, i); +fclose (f); } } -free (allowed_nodemask); +free (cpumask); +}#endif /* HAVE_NUMA_H */ -return 0 ; + +/* +* get_allowed_nodes_arr - get number and array of available nodes +* @num_nodes: pointer where number of available nodes will be stored +* @nodes: array of available node ids, this is MPOL_F_MEMS_ALLOWED +* node bitmask compacted (without holes), so that each field +* contains node number. If NULL only num_nodes is +* returned, otherwise it cotains new allocated array, +* which caller is responsible to free. +* RETURNS: +* 0 on success +* -1 on allocation failure +* -2 on get_mempolicy failure +*/ +int get_allowed_nodes_arr (int flag,int *num_nodes,int **nodes) +{ +int ret =0 ; +#if HAVE_NUMA_H +int i; +nodemask_t *nodemask =NULL ; +#endif + *num_nodes =0 ; +if (nodes) + *nodes =NULL ; + +#if HAVE_NUMA_H +unsigned long max_node =get_max_node (); +unsigned long nodemask_size = max_node/8 +1 ; + + nodemask =malloc (nodemask_size); +if (nodes) + *nodes =malloc (sizeof (int )*max_node); + +do { +if (nodemask ==NULL || (nodes && (*nodes ==NULL ))) { + ret =-1 ; +break ; + } + +/* allow all nodes at start, then filter based on flags */ +get_nodemask_allnodes (nodemask, max_node); +if ((flag &NH_MEMS ) ==NH_MEMS ) { + ret =filter_nodemask_mem (nodemask, max_node); +if (ret <0 ) +break ; + } +if ((flag &NH_CPUS ) ==NH_CPUS ) +filter_nodemask_cpu (nodemask, max_node); + +for (i =0 ; i < max_node; i++) { +if (nodemask_isset (nodemask, i)) { +if (nodes) + (*nodes)[*num_nodes] = i; + (*num_nodes)++; + } + } + }while (0 ); +free (nodemask); +#endif +return ret; }/*
@@ -135,7 +209,7 @@ int get_allowed_nodes_arr(int *num_allowed_nodes, int **allowed_nodes)* -2 on get_mempolicy failure * -3 on not enough allowed nodes */ -int get_allowed_nodes (int count, ...) +int get_allowed_nodes (int flag,int count, ...) {int ret;int i, *nodep;
@@ -143,7 +217,7 @@ int get_allowed_nodes(int count, ...)int num_nodes =0 ;int *nodes =NULL ; - ret =get_allowed_nodes_arr (&num_nodes, &nodes); + ret =get_allowed_nodes_arr (flag, &num_nodes, &nodes);if (ret <0 )return ret;
@@ -163,3 +237,30 @@ int get_allowed_nodes(int count, ...)return ret; } + +static void print_node_info (int flag) +{ +int *allowed_nodes =NULL ; +int i, ret, num_nodes; + + ret =get_allowed_nodes_arr (flag, &num_nodes, &allowed_nodes); +printf ("nodes (flag=%d): " , flag); +if (ret ==0 ) { +for (i =0 ; i < num_nodes; i++) +printf ("%d " , allowed_nodes[i]); +printf ("\n" ); + }else +printf ("error(%d)\n" , ret); +free (allowed_nodes); +} + +/* +* nh_dump_nodes - dump info about nodes to stdout +*/ +void nh_dump_nodes () +{ +print_node_info (0 ); +print_node_info (NH_MEMS ); +print_node_info (NH_CPUS ); +print_node_info (NH_MEMS |NH_CPUS ); +}
testcases/kernel/syscalls/numa/lib/numa_helper.h +6 -2
@@ -27,7 +27,11 @@#include <numaif.h> #endif -int get_allowed_nodes_arr (int *num_allowed_nodes,int **allowed_nodes); -int get_allowed_nodes (int count, ...); +#define NH_MEMS (1 << 0) +#define NH_CPUS (1 << 1) + +int get_allowed_nodes_arr (int flag,int *num_nodes,int **nodes); +int get_allowed_nodes (int flag,int count, ...); +void nh_dump_nodes ();#endif
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
cover numa_helper: get nodes with mem/cpu/both
numa_helper has been used for syscalls testcases, which care about nodes with memory. Based on discussion here:
http://article.gmane.org/gmane.linux.ltp/16325
it was deemed, that 'flag' extension would be useful, to allow tests to ask for nodes with memory/cpu/both.
This patch series is introducing flag to get_allowed_nodes().
For example, a config like this one:
# numactl -H available: 3 nodes (2,4-5) node 2 cpus: 0 node 2 size: 511 MB node 2 free: 88 MB node 4 cpus: node 4 size: 256 MB node 4 free: 34 MB node 5 cpus: node 5 size: 255 MB node 5 free: 59 MB
would return:
nodes (flag=0): 2 4 5 (any)
nodes (flag=1): 2 4 5 (mem)
nodes (flag=2): 2 (cpus)
nodes (flag=3): 2 (mem and cpus)
Tested with:
numactl-devel-0.9.8-7.el5
numactl-devel-2.0.3-9.el6
numactl-devel-2.0.7-6.el7
numa_node_to_cpus() is broken in older libnuma < 1, so cpumap is used instead.
Next step (not part of this series) is to move it outside syscalls area, so it can be used by other testcases.
Jan Stancek (2):
numa_helper: add flag to get_allowed_nodes() update testcases to use flag for get_allowed_nodes()
.../syscalls/get_mempolicy/get_mempolicy01.c | 5 +- testcases/kernel/syscalls/mbind/mbind01.c | 5 +- .../kernel/syscalls/move_pages/move_pages02.c | 5 +- .../kernel/syscalls/move_pages/move_pages03.c | 5 +- .../kernel/syscalls/move_pages/move_pages04.c | 5 +- .../kernel/syscalls/move_pages/move_pages05.c | 5 +- .../kernel/syscalls/move_pages/move_pages06.c | 5 +- .../kernel/syscalls/move_pages/move_pages07.c | 5 +- .../kernel/syscalls/move_pages/move_pages08.c | 5 +- .../kernel/syscalls/move_pages/move_pages09.c | 5 +- .../kernel/syscalls/move_pages/move_pages10.c | 5 +- .../kernel/syscalls/move_pages/move_pages11.c | 5 +- .../syscalls/move_pages/move_pages_support.c | 8 +- testcases/kernel/syscalls/numa/lib/numa_helper.c | 211 +++++++++++++++----- testcases/kernel/syscalls/numa/lib/numa_helper.h | 8 +- 15 files changed, 203 insertions(+), 84 deletions(-)
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH 2/2 update testcases to use flag for get_allowed_nodes()
Interface of get_allowed_nodes() now requires a flag, update all testcases using this interface.
Also fix some checkpatch warnings.
--- .../syscalls/get_mempolicy/get_mempolicy01.c | 5 +++-- testcases/kernel/syscalls/mbind/mbind01.c | 5 +++-- .../kernel/syscalls/move_pages/move_pages02.c | 5 +++-- .../kernel/syscalls/move_pages/move_pages03.c | 5 +++-- .../kernel/syscalls/move_pages/move_pages04.c | 5 +++-- .../kernel/syscalls/move_pages/move_pages05.c | 5 +++-- .../kernel/syscalls/move_pages/move_pages06.c | 5 +++-- .../kernel/syscalls/move_pages/move_pages07.c | 5 +++-- .../kernel/syscalls/move_pages/move_pages08.c | 5 +++-- .../kernel/syscalls/move_pages/move_pages09.c | 5 +++-- .../kernel/syscalls/move_pages/move_pages10.c | 5 +++-- .../kernel/syscalls/move_pages/move_pages11.c | 5 +++-- .../syscalls/move_pages/move_pages_support.c | 8 +++++--- 13 files changed, 41 insertions(+), 27 deletions(-)
testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c +3 -2
@@ -234,8 +234,9 @@ static int do_test(struct test_case *tc)unsigned long len =MEM_LENGTH ;int test_node =-1 ; -if ((ret =get_allowed_nodes (1 , &test_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,1 , &test_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);#if !defined(LIBNUMA_API_VERSION ) ||LIBNUMA_API_VERSION <2 nodemask =malloc (sizeof (nodemask_t));nodemask_zero (nodemask);
testcases/kernel/syscalls/mbind/mbind01.c +3 -2
@@ -220,8 +220,9 @@ static int do_test(struct test_case *tc)unsigned long *invalid_nodemask;int test_node =-1 ; -if ((ret =get_allowed_nodes (1 , &test_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,1 , &test_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);#if !defined(LIBNUMA_API_VERSION ) ||LIBNUMA_API_VERSION <2 nodemask =malloc (sizeof (nodemask_t));
testcases/kernel/syscalls/move_pages/move_pages02.c +3 -2
@@ -87,8 +87,9 @@ int main(int argc, char **argv)unsigned int to_node;int ret; -if ((ret =get_allowed_nodes (2 , &from_node, &to_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,2 , &from_node, &to_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {
testcases/kernel/syscalls/move_pages/move_pages03.c +3 -2
@@ -126,8 +126,9 @@ int main(int argc, char **argv)unsigned int to_node;int ret; -if ((ret =get_allowed_nodes (2 , &from_node, &to_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,2 , &from_node, &to_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {
testcases/kernel/syscalls/move_pages/move_pages04.c +3 -2
@@ -93,8 +93,9 @@ int main(int argc, char **argv)unsigned int to_node;int ret; -if ((ret =get_allowed_nodes (2 , &from_node, &to_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,2 , &from_node, &to_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {
testcases/kernel/syscalls/move_pages/move_pages05.c +3 -2
@@ -127,8 +127,9 @@ int main(int argc, char **argv)unsigned int to_node;int ret; -if ((ret =get_allowed_nodes (2 , &from_node, &to_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,2 , &from_node, &to_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {
testcases/kernel/syscalls/move_pages/move_pages06.c +3 -2
@@ -87,8 +87,9 @@ int main(int argc, char **argv)unsigned int to_node;int ret; -if ((ret =get_allowed_nodes (1 , &from_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,1 , &from_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {
testcases/kernel/syscalls/move_pages/move_pages07.c +3 -2
@@ -87,8 +87,9 @@ int main(int argc, char **argv)unsigned int to_node;int ret; -if ((ret =get_allowed_nodes (2 , &from_node, &to_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,2 , &from_node, &to_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {
testcases/kernel/syscalls/move_pages/move_pages08.c +3 -2
@@ -85,8 +85,9 @@ int main(int argc, char **argv)unsigned int to_node;int ret; -if ((ret =get_allowed_nodes (2 , &from_node, &to_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,2 , &from_node, &to_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {
testcases/kernel/syscalls/move_pages/move_pages09.c +3 -2
@@ -84,8 +84,9 @@ int main(int argc, char **argv)unsigned int from_node;int ret; -if ((ret =get_allowed_nodes (1 , &from_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,1 , &from_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {
testcases/kernel/syscalls/move_pages/move_pages10.c +3 -2
@@ -87,8 +87,9 @@ int main(int argc, char **argv)unsigned int to_node;int ret; -if ((ret =get_allowed_nodes (2 , &from_node, &to_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,2 , &from_node, &to_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {
testcases/kernel/syscalls/move_pages/move_pages11.c +3 -2
@@ -126,8 +126,9 @@ int main(int argc, char **argv)unsigned int to_node;int ret; -if ((ret =get_allowed_nodes (2 , &from_node, &to_node)) <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes(): %d" , ret); + ret =get_allowed_nodes (NH_MEMS ,2 , &from_node, &to_node); +if (ret <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"get_allowed_nodes: %d" , ret);/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {
testcases/kernel/syscalls/move_pages/move_pages_support.c +5 -3
@@ -120,7 +120,8 @@ int alloc_pages_linear(void **pages, unsigned int num)int *allowed_nodes;int ret; - ret =get_allowed_nodes_arr (&num_allowed_nodes, &allowed_nodes); + ret =get_allowed_nodes_arr (NH_MEMS , &num_allowed_nodes, + &allowed_nodes);if (ret <0 )tst_brkm (TBROK |TERRNO ,NULL ,"get_allowed_nodes(): %d" , ret);
@@ -223,7 +224,8 @@ void verify_pages_linear(void **pages, int *status, unsigned int num)int *allowed_nodes;int ret; - ret =get_allowed_nodes_arr (&num_allowed_nodes, &allowed_nodes); + ret =get_allowed_nodes_arr (NH_MEMS , &num_allowed_nodes, + &allowed_nodes);if (ret <0 )tst_brkm (TBROK |TERRNO ,NULL ,"get_allowed_nodes(): %d" , ret);
@@ -396,7 +398,7 @@ void check_config(unsigned int min_nodes)int num_allowed_nodes;int ret; - ret =get_allowed_nodes_arr (&num_allowed_nodes,NULL ); + ret =get_allowed_nodes_arr (NH_MEMS , &num_allowed_nodes,NULL );if (ret <0 )tst_brkm (TBROK |TERRNO ,NULL ,"get_allowed_nodes(): %d" , ret);
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 42 lines · Jan Stancek
numa_helperhas been used for syscalls testcases, which care about nodes with memory. Based on discussion here:
http://article.gmane.org/gmane.linux.ltp/16325
it was deemed, that 'flag' extension would be useful, to allow tests to ask for nodes with memory/cpu/both.This patch series is introducing flag to
get_allowed_nodes().For example, a config like this one:
# numactl -H available: 3 nodes (2,4-5) node 2 cpus: 0 node 2 size: 511 MB node 2 free: 88 MB node 4 cpus: node 4 size: 256 MB node 4 free: 34 MB node 5 cpus: node 5 size: 255 MB node 5 free: 59 MBwould return:
nodes (flag=0): 2 4 5 (any) nodes (flag=1): 2 4 5 (mem) nodes (flag=2): 2 (cpus) nodes (flag=3): 2 (mem and cpus)Tested with:
numactl-devel-0.9.8-7.el5
numactl-devel-2.0.3-9.el6
numactl-devel-2.0.7-6.el7
numa_node_to_cpus()is broken in older libnuma < 1, so cpumap is used instead.Next step (not part of this series) is to move it outside syscalls area, so it can be used by other testcases.
Jan Stancek (2):
numa_helper: add flag toget_allowed_nodes()update testcases to use flag forget_allowed_nodes()
Quoted 18 lines
.../syscalls/get_mempolicy/get_mempolicy01.c | 5 +- testcases/kernel/syscalls/mbind/mbind01.c | 5 +- .../kernel/syscalls/move_pages/move_pages02.c | 5 +- .../kernel/syscalls/move_pages/move_pages03.c | 5 +- .../kernel/syscalls/move_pages/move_pages04.c | 5 +- .../kernel/syscalls/move_pages/move_pages05.c | 5 +- .../kernel/syscalls/move_pages/move_pages06.c | 5 +- .../kernel/syscalls/move_pages/move_pages07.c | 5 +- .../kernel/syscalls/move_pages/move_pages08.c | 5 +- .../kernel/syscalls/move_pages/move_pages09.c | 5 +- .../kernel/syscalls/move_pages/move_pages10.c | 5 +- .../kernel/syscalls/move_pages/move_pages11.c | 5 +- .../syscalls/move_pages/move_pages_support.c | 8 +- testcases/kernel/syscalls/numa/lib/numa_helper.c | 211 +++++++++++++++----- testcases/kernel/syscalls/numa/lib/numa_helper.h | 8 +- 15 files changed, 203 insertions(+), 84 deletions(-)
Thanks Jan for your patches! I want to test the patchset on all arches and on major releases, so would you mind if I hold on pushing until I finish the testing next week?
Also during that period, any comments from anyone is welcomed.
Thanks,
Caspar
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
----- Original Message -----
Quoted 69 lines
From: "Caspar Zhang" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Friday, 20 July, 2012 1:02:47 PM
Subject: Re: [LTP] [PATCH 0/2]numa_helper: get nodes with mem/cpu/bothQuoted 51 lines · Jan Stancek
numa_helperhas been used for syscalls testcases, which care about nodes with memory. Based on discussion here:
http://article.gmane.org/gmane.linux.ltp/16325
it was deemed, that 'flag' extension would be useful, to allow tests to ask for nodes with memory/cpu/both.This patch series is introducing flag to
get_allowed_nodes().For example, a config like this one:
# numactl -H available: 3 nodes (2,4-5) node 2 cpus: 0 node 2 size: 511 MB node 2 free: 88 MB node 4 cpus: node 4 size: 256 MB node 4 free: 34 MB node 5 cpus: node 5 size: 255 MB node 5 free: 59 MBwould return:
nodes (flag=0): 2 4 5 (any) nodes (flag=1): 2 4 5 (mem) nodes (flag=2): 2 (cpus) nodes (flag=3): 2 (mem and cpus)Tested with:
numactl-devel-0.9.8-7.el5
numactl-devel-2.0.3-9.el6
numactl-devel-2.0.7-6.el7
numa_node_to_cpus()is broken in older libnuma < 1, so cpumap is used instead.Next step (not part of this series) is to move it outside syscalls area, so it can be used by other testcases.
Jan Stancek (2):
numa_helper: add flag toget_allowed_nodes()update testcases to use flag forget_allowed_nodes().../syscalls/get_mempolicy/get_mempolicy01.c | 5 +- testcases/kernel/syscalls/mbind/mbind01.c | 5 +- .../kernel/syscalls/move_pages/move_pages02.c | 5 +- .../kernel/syscalls/move_pages/move_pages03.c | 5 +- .../kernel/syscalls/move_pages/move_pages04.c | 5 +- .../kernel/syscalls/move_pages/move_pages05.c | 5 +- .../kernel/syscalls/move_pages/move_pages06.c | 5 +- .../kernel/syscalls/move_pages/move_pages07.c | 5 +- .../kernel/syscalls/move_pages/move_pages08.c | 5 +-Quoted 10 lines
.../kernel/syscalls/move_pages/move_pages09.c | 5 +- .../kernel/syscalls/move_pages/move_pages10.c | 5 +- .../kernel/syscalls/move_pages/move_pages11.c | 5 +- .../syscalls/move_pages/move_pages_support.c | 8 +- testcases/kernel/syscalls/numa/lib/numa_helper.c | 211 +++++++++++++++----- testcases/kernel/syscalls/numa/lib/numa_helper.h | 8 +- 15 files changed, 203 insertions(+), 84 deletions(-)
Quoted 4 lines
Thanks Jan for your patches! I want to test the patchset on all arches
and on major releases, so would you mind if I hold on pushing until I finish the testing next week?
Sure, no time pressure here.
Thank you,
Jan
Quoted 7 lines
Also during that period, any comments from anyone is welcomed.
Thanks,
Caspar
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
----- Original Message -----
Quoted 69 lines
From: "Caspar Zhang" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Friday, 20 July, 2012 1:02:47 PM
Subject: Re: [LTP] [PATCH 0/2]numa_helper: get nodes with mem/cpu/bothQuoted 51 lines · Jan Stancek
numa_helperhas been used for syscalls testcases, which care about nodes with memory. Based on discussion here:
http://article.gmane.org/gmane.linux.ltp/16325
it was deemed, that 'flag' extension would be useful, to allow tests to ask for nodes with memory/cpu/both.This patch series is introducing flag to
get_allowed_nodes().For example, a config like this one:
# numactl -H available: 3 nodes (2,4-5) node 2 cpus: 0 node 2 size: 511 MB node 2 free: 88 MB node 4 cpus: node 4 size: 256 MB node 4 free: 34 MB node 5 cpus: node 5 size: 255 MB node 5 free: 59 MBwould return:
nodes (flag=0): 2 4 5 (any) nodes (flag=1): 2 4 5 (mem) nodes (flag=2): 2 (cpus) nodes (flag=3): 2 (mem and cpus)Tested with:
numactl-devel-0.9.8-7.el5
numactl-devel-2.0.3-9.el6
numactl-devel-2.0.7-6.el7
numa_node_to_cpus()is broken in older libnuma < 1, so cpumap is used instead.Next step (not part of this series) is to move it outside syscalls area, so it can be used by other testcases.
Jan Stancek (2):
numa_helper: add flag toget_allowed_nodes()update testcases to use flag forget_allowed_nodes().../syscalls/get_mempolicy/get_mempolicy01.c | 5 +- testcases/kernel/syscalls/mbind/mbind01.c | 5 +- .../kernel/syscalls/move_pages/move_pages02.c | 5 +- .../kernel/syscalls/move_pages/move_pages03.c | 5 +- .../kernel/syscalls/move_pages/move_pages04.c | 5 +- .../kernel/syscalls/move_pages/move_pages05.c | 5 +- .../kernel/syscalls/move_pages/move_pages06.c | 5 +- .../kernel/syscalls/move_pages/move_pages07.c | 5 +- .../kernel/syscalls/move_pages/move_pages08.c | 5 +-Quoted 10 lines
.../kernel/syscalls/move_pages/move_pages09.c | 5 +- .../kernel/syscalls/move_pages/move_pages10.c | 5 +- .../kernel/syscalls/move_pages/move_pages11.c | 5 +- .../syscalls/move_pages/move_pages_support.c | 8 +- testcases/kernel/syscalls/numa/lib/numa_helper.c | 211 +++++++++++++++----- testcases/kernel/syscalls/numa/lib/numa_helper.h | 8 +- 15 files changed, 203 insertions(+), 84 deletions(-)
Quoted 6 lines
Thanks Jan for your patches! I want to test the patchset on all arches
and on major releases, so would you mind if I hold on pushing until I finish the testing next week?Also during that period, any comments from anyone is welcomed.
I came across one issue. This happens on some arches, which do not support numa/get_mempolicy.
What happens with v1 of this patch is:
# ./mbind01 mbind01 0 TINFO : (case00) START mbind01 1 TBROK : get_allowed_nodes(): -3: errno=EINVAL(22): Invalid argument mbind01 2 TBROK : Remaining cases broken which is bad, because it should end with TCONF stating, that numa is not supported.
What happens with current HEAD depends on libnuma version. The problem is the same here: we use libnuma functions in numa_helper even when numa is not supported.
mbind and get_mempolicy testcases (and numa_helper) check only for HAVE_NUMA_H, etc. but they don't check numa_available().
Regards,
Jan
Quoted 5 lines
Thanks,
Caspar
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 82 lines · Jan Stancek
----- Original Message -----
Quoted 69 lines
From: "Caspar Zhang" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Friday, 20 July, 2012 1:02:47 PM
Subject: Re: [LTP] [PATCH 0/2]numa_helper: get nodes with mem/cpu/bothQuoted 51 lines · Jan Stancek
numa_helperhas been used for syscalls testcases, which care about nodes with memory. Based on discussion here:
http://article.gmane.org/gmane.linux.ltp/16325
it was deemed, that 'flag' extension would be useful, to allow tests to ask for nodes with memory/cpu/both.This patch series is introducing flag to
get_allowed_nodes().For example, a config like this one:
# numactl -H available: 3 nodes (2,4-5) node 2 cpus: 0 node 2 size: 511 MB node 2 free: 88 MB node 4 cpus: node 4 size: 256 MB node 4 free: 34 MB node 5 cpus: node 5 size: 255 MB node 5 free: 59 MBwould return:
nodes (flag=0): 2 4 5 (any) nodes (flag=1): 2 4 5 (mem) nodes (flag=2): 2 (cpus) nodes (flag=3): 2 (mem and cpus)Tested with:
numactl-devel-0.9.8-7.el5
numactl-devel-2.0.3-9.el6
numactl-devel-2.0.7-6.el7
numa_node_to_cpus()is broken in older libnuma < 1, so cpumap is used instead.Next step (not part of this series) is to move it outside syscalls area, so it can be used by other testcases.
Jan Stancek (2):
numa_helper: add flag toget_allowed_nodes()update testcases to use flag forget_allowed_nodes().../syscalls/get_mempolicy/get_mempolicy01.c | 5 +- testcases/kernel/syscalls/mbind/mbind01.c | 5 +- .../kernel/syscalls/move_pages/move_pages02.c | 5 +- .../kernel/syscalls/move_pages/move_pages03.c | 5 +- .../kernel/syscalls/move_pages/move_pages04.c | 5 +- .../kernel/syscalls/move_pages/move_pages05.c | 5 +- .../kernel/syscalls/move_pages/move_pages06.c | 5 +- .../kernel/syscalls/move_pages/move_pages07.c | 5 +- .../kernel/syscalls/move_pages/move_pages08.c | 5 +-Quoted 10 lines
.../kernel/syscalls/move_pages/move_pages09.c | 5 +- .../kernel/syscalls/move_pages/move_pages10.c | 5 +- .../kernel/syscalls/move_pages/move_pages11.c | 5 +- .../syscalls/move_pages/move_pages_support.c | 8 +- testcases/kernel/syscalls/numa/lib/numa_helper.c | 211 +++++++++++++++----- testcases/kernel/syscalls/numa/lib/numa_helper.h | 8 +- 15 files changed, 203 insertions(+), 84 deletions(-)Quoted 6 lines
Thanks Jan for your patches! I want to test the patchset on all arches
and on major releases, so would you mind if I hold on pushing until I finish the testing next week?Also during that period, any comments from anyone is welcomed.
I came across one issue. This happens on some arches, which do not support numa/get_mempolicy.
Quoted 9 lines
What happens with v1 of this patch is:
# ./mbind01 mbind01 0 TINFO : (case00) START mbind01 1 TBROK : get_allowed_nodes(): -3: errno=EINVAL(22): Invalid argument mbind01 2 TBROK : Remaining cases broken which is bad, because it should end with TCONF stating, that numa is not supported.
ya, I encountered this too. I have a patch for it, and will send it along with other numa related patches.
Caspar
Quoted 6 lines
What happens with current HEAD depends on libnuma version. The problem is the
same here: we use libnuma functions innuma_helpereven when numa is not supported.
Quoted 13 lines
mbind and
get_mempolicytestcases (andnuma_helper) check only forHAVE_NUMA_H, etc.
but they don't checknuma_available().Regards,
JanQuoted 5 lines
Thanks,
Caspar
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH 1/1 syscalls/numa: check syscall availability
In reply to Jan Stanceksome NUMA related syscalls: mbind, get_mempolicy are not supported on some arches (e.g. i386), I use TEST macro to test the syscall in setup() function, if the syscall is not implemented on the system, a TCONF message will given like this:
get_mempolicy01 1 TCONF : syscall __NR_get_mempolicy01 not supported on your arch
--- .../syscalls/get_mempolicy/get_mempolicy01.c | 3 +++ testcases/kernel/syscalls/mbind/mbind01.c | 3 +++ 2 files changed, 6 insertions(+), 0 deletions(-)
testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c +3 -0
@@ -339,6 +339,9 @@ static void cleanup(void)static void setup (void ) { +/* check syscall availability */ +TEST (syscall (__NR_get_mempolicy,NULL ,NULL ,0 ,NULL ,0 )); +TEST_PAUSE ;tst_tmpdir (); }
testcases/kernel/syscalls/mbind/mbind01.c +3 -0
@@ -300,6 +300,9 @@ TEST_END:static void setup (void ) { +/* check syscall availability */ +TEST (syscall (__NR_mbind,NULL ,0 ,0 ,NULL ,0 ,0 )); +TEST_PAUSE ;tst_tmpdir (); }
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH] syscalls/numa: check syscall availability
Quoted 7 lines · Caspar Zhang
some NUMA related syscalls: mbind,
get_mempolicyare not supported on some arches (e.g. i386), I use TEST macro to test the syscall insetup()function, if the syscall is not implemented on the system, a TCONF message will given like this:
get_mempolicy011 TCONF : syscall__NR_get_mempolicy01not supported on your arch
Using TEST isn't necessary to be honest: the syscall wrapper
handles the (if you add a comment as to why things are being done in a single line, untested, that should be ok).
Thanks!
-Garrett
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH] syscalls/numa: check syscall availability
Quoted 7 lines · Garrett Cooper
Quoted 6 lines · Caspar Zhang
some NUMA related syscalls: mbind,
get_mempolicyare not supported on some arches (e.g. i386), I use TEST macro to test the syscall insetup()function, if the syscall is not implemented on the system, a TCONF message will given like this:
Quoted 8 lines
Quoted 1 line
get_mempolicy011 TCONF : syscall__NR_get_mempolicy01not supported on your archUsing TEST isn't necessary to be honest: the syscall wrapper
handles the (if you add a comment as to why things are being done in a single line, untested, that should be ok).
Thanks!
-Garrett
Hi Garrett, sorry I'm kind of not catching you :-( what's your suggestion of correcting/improving this message?
Thanks,
Caspar
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH] syscalls/numa: check syscall availability
Quoted 10 lines · Caspar Zhang
Quoted 9 lines · Garrett Cooper
Quoted 7 lines · Caspar Zhang
some NUMA related syscalls: mbind,
get_mempolicyare not supported on some arches (e.g. i386), I use TEST macro to test the syscall insetup()function, if the syscall is not implemented on the system, a TCONF message will given like this:
get_mempolicy011 TCONF : syscall__NR_get_mempolicy01not supported on your arch
Quoted 8 lines
Quoted 6 lines
Using TEST isn't necessary to be honest: the syscall wrapper
handles the (if you add a comment as to why things are being done in a single line, untested, that should be ok).
Thanks!
-GarrettHi Garrett, sorry I'm kind of not catching you :-( what's your suggestion of correcting/improving this message?
I'd remove "TEST(..)" from the line and just use the syscall function call. If you want, we can make syscall more explicit as far as a custom wrapper goes.
Cheers!
-Garrett
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH] syscalls/numa: check syscall availability
Quoted 19 lines · Garrett Cooper
Quoted 17 lines · Caspar Zhang
Quoted 15 lines · Garrett Cooper
Quoted 7 lines · Caspar Zhang
some NUMA related syscalls: mbind,
get_mempolicyare not supported on some arches (e.g. i386), I use TEST macro to test the syscall insetup()function, if the syscall is not implemented on the system, a TCONF message will given like this:
get_mempolicy011 TCONF : syscall__NR_get_mempolicy01not supported on your archUsing TEST isn't necessary to be honest: the syscall wrapper
handles the (if you add a comment as to why things are being done in a single line, untested, that should be ok).
Thanks!
-Garrett
Quoted 4 lines
Quoted 1 line
Hi Garrett, sorry I'm kind of not catching you :-( what's your suggestion of correcting/improving this message?
I'd remove "TEST(..)" from the line and just use the syscall function call. If you want, we can make syscall more explicit as far as a custom wrapper goes.
OK, I'll remove TEST() and resend the patch.
Thanks,
Caspar
Quoted 3 lines
Cheers!
-Garrett
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list