move_pages: dont use hardcoded NUMA node ids
PATCH 4/4 move_pages: dont use hardcoded NUMA node ids
--- testcases/kernel/syscalls/move_pages/Makefile | 5 +-- .../kernel/syscalls/move_pages/move_pages02.c | 12 +++++-- .../kernel/syscalls/move_pages/move_pages03.c | 12 +++++-- .../kernel/syscalls/move_pages/move_pages04.c | 12 +++++-- .../kernel/syscalls/move_pages/move_pages05.c | 12 +++++-- .../kernel/syscalls/move_pages/move_pages06.c | 10 ++++-- .../kernel/syscalls/move_pages/move_pages07.c | 12 +++++-- .../kernel/syscalls/move_pages/move_pages08.c | 10 ++++-- .../kernel/syscalls/move_pages/move_pages09.c | 8 +++- .../kernel/syscalls/move_pages/move_pages10.c | 12 +++++-- .../kernel/syscalls/move_pages/move_pages11.c | 12 +++++-- .../syscalls/move_pages/move_pages_support.c | 34 ++++++++++++------- .../syscalls/move_pages/move_pages_support.h | 1 + 13 files changed, 100 insertions(+), 52 deletions(-)
testcases/kernel/syscalls/move_pages/Makefile +2 -3
@@ -22,8 +22,6 @@ include $(top_srcdir)/include/mk/testcases.mk CPPFLAGS += -I$(abs_srcdir)/../utils -LDLIBS += $(NUMA_LIBS) - INSTALL_TARGETS := move_pages.sh MAKE_TARGETS := $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*[0-9].c))
@@ -35,6 +33,7 @@ move_pages_support.o: CFLAGS += -Wno-unused-function $(MAKE_TARGETS): %: %.o move_pages_support.o -LDLIBS += $(NUMA_LIBS) -lpthread -lrt +LDLIBS += -lpthread -lrt +include $(abs_srcdir)/../numa/Makefile.inc include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/move_pages/move_pages02.c +8 -4
@@ -83,15 +83,19 @@ int main(int argc, char **argv)#if HAVE_NUMA_MOVE_PAGES unsigned int i;int lc;/* loop counter */ -unsigned int from_node =0 ; -unsigned int to_node =1 ; +unsigned int from_node; +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); + }/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {void *pages[TEST_PAGES ] = {0 };int nodes[TEST_PAGES ];int status[TEST_PAGES ]; -int ret;/* reset Tst_count in case we are looping */ Tst_count =0 ;
@@ -156,4 +160,4 @@ void cleanup(void)*/ TEST_CLEANUP ; - } + }
testcases/kernel/syscalls/move_pages/move_pages03.c +8 -4
@@ -122,15 +122,19 @@ int main(int argc, char **argv)#if HAVE_NUMA_MOVE_PAGES unsigned int i;int lc;/* loop counter */ -unsigned int from_node =0 ; -unsigned int to_node =1 ; +unsigned int from_node; +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); + }/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {void *pages[TEST_PAGES ] = {0 };int nodes[TEST_PAGES ];int status[TEST_PAGES ]; -int ret;pid_t cpid;sem_t *sem;
@@ -223,4 +227,4 @@ void cleanup(void)*/ TEST_CLEANUP ; - } + }
testcases/kernel/syscalls/move_pages/move_pages04.c +8 -4
@@ -89,15 +89,19 @@ int main(int argc, char **argv)#if HAVE_NUMA_MOVE_PAGES unsigned int i;int lc;/* loop counter */ -unsigned int from_node =0 ; -unsigned int to_node =1 ; +unsigned int from_node; +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); + }/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {void *pages[TEST_PAGES ] = {0 };int nodes[TEST_PAGES ];int status[TEST_PAGES ]; -int ret;unsigned long onepage =get_page_size ();/* reset Tst_count in case we are looping */
@@ -175,4 +179,4 @@ void cleanup(void)*/ TEST_CLEANUP ; - } + }
testcases/kernel/syscalls/move_pages/move_pages05.c +8 -4
@@ -123,15 +123,19 @@ int main(int argc, char **argv)#if HAVE_NUMA_MOVE_PAGES unsigned int i;int lc;/* loop counter */ -unsigned int from_node =0 ; -unsigned int to_node =1 ; +unsigned int from_node; +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); + }/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {void *pages[N_TEST_PAGES ] = {0 };int nodes[N_TEST_PAGES ];int status[N_TEST_PAGES ]; -int ret;pid_t cpid;sem_t *sem;
@@ -237,4 +241,4 @@ void cleanup(void)*/ TEST_CLEANUP ; - } + }
testcases/kernel/syscalls/move_pages/move_pages06.c +7 -3
@@ -83,15 +83,19 @@ int main(int argc, char **argv)#if HAVE_NUMA_MOVE_PAGES unsigned int i;int lc;/* loop counter */ -unsigned int from_node =0 ; +unsigned int from_node;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); + }/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {void *pages[TEST_PAGES ] = {0 };int nodes[TEST_PAGES ];int status[TEST_PAGES ]; -int ret;/* reset Tst_count in case we are looping */ Tst_count =0 ;
@@ -152,4 +156,4 @@ void cleanup(void)*/ TEST_CLEANUP ; - } + }
testcases/kernel/syscalls/move_pages/move_pages07.c +8 -4
@@ -83,15 +83,19 @@ int main(int argc, char **argv)#if HAVE_NUMA_MOVE_PAGES unsigned int i;int lc;/* loop counter */ -unsigned int from_node =0 ; -unsigned int to_node =1 ; +unsigned int from_node; +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); + }/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {void *pages[TEST_PAGES ] = {0 };int nodes[TEST_PAGES ];int status[TEST_PAGES ]; -int ret;int ipid;/* reset Tst_count in case we are looping */
@@ -163,4 +167,4 @@ void cleanup(void)*/ TEST_CLEANUP ; - } + }
testcases/kernel/syscalls/move_pages/move_pages08.c +7 -3
@@ -81,15 +81,19 @@ int main(int argc, char **argv)#if HAVE_NUMA_MOVE_PAGES unsigned int i;int lc;/* loop counter */ -unsigned int from_node =0 ; -unsigned int to_node =1 ; +unsigned int from_node; +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); + }/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {void *pages[TEST_PAGES ] = {0 };int nodes[TEST_PAGES ];int status[TEST_PAGES ]; -int ret;/* reset Tst_count in case we are looping */ Tst_count =0 ;
testcases/kernel/syscalls/move_pages/move_pages09.c +6 -2
@@ -81,14 +81,18 @@ int main(int argc, char **argv)#if HAVE_NUMA_MOVE_PAGES unsigned int i;int lc;/* loop counter */ -unsigned int from_node =0 ; +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); + }/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {void *pages[TEST_PAGES ] = {0 };int nodes[TEST_PAGES ];int status[TEST_PAGES ]; -int ret;/* reset Tst_count in case we are looping */ Tst_count =0 ;
testcases/kernel/syscalls/move_pages/move_pages10.c +8 -4
@@ -83,15 +83,19 @@ int main(int argc, char **argv)#if HAVE_NUMA_MOVE_PAGES unsigned int i;int lc;/* loop counter */ -unsigned int from_node =0 ; -unsigned int to_node =1 ; +unsigned int from_node; +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); + }/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {void *pages[TEST_PAGES ] = {0 };int nodes[TEST_PAGES ];int status[TEST_PAGES ]; -int ret;/* reset Tst_count in case we are looping */ Tst_count =0 ;
@@ -151,4 +155,4 @@ void cleanup(void)*/ TEST_CLEANUP ; - } + }
testcases/kernel/syscalls/move_pages/move_pages11.c +8 -4
@@ -122,15 +122,19 @@ int main(int argc, char **argv)#if HAVE_NUMA_MOVE_PAGES unsigned int i;int lc;/* loop counter */ -unsigned int from_node =0 ; -unsigned int to_node =1 ; +unsigned int from_node; +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); + }/* check for looping state if -i option is given */ for (lc =0 ;TEST_LOOPING (lc); lc++) {void *pages[TEST_PAGES ] = {0 };int nodes[TEST_PAGES ];int status[TEST_PAGES ]; -int ret;pid_t cpid;sem_t *sem;
@@ -241,4 +245,4 @@ void cleanup(void)*/ TEST_CLEANUP ; - } + }
testcases/kernel/syscalls/move_pages/move_pages_support.c +21 -13
@@ -97,6 +97,7 @@ int alloc_pages_on_nodes(void **pages, unsigned int num, int *nodes)return -1 ; } +/* * alloc_pages_linear() - allocate pages in each NUMA node * @pages: array in which the page pointers will be stored
@@ -114,16 +115,18 @@ int alloc_pages_linear(void **pages, unsigned int num)#if HAVE_NUMA_H unsigned int i; -unsigned int n; +unsigned int n =0 ; +int num_allowed_nodes; +int *allowed_nodes; - n =0 ; +get_allowed_nodes_arr (&num_allowed_nodes, &allowed_nodes);for (i =0 ; i < num; i++) { - nodes[i] = n; - + nodes[i] = allowed_nodes[n]; n++; -if (n >numa_max_node ()) +if (n >= num_allowed_nodes) n =0 ; } +free (allowed_nodes);#endif return alloc_pages_on_nodes (pages, num, nodes);
@@ -210,18 +213,19 @@ void verify_pages_linear(void **pages, int *status, unsigned int num) {#if HAVE_NUMA_H unsigned int i; -unsigned int n; +unsigned int n =0 ;int nodes[num]; +int num_allowed_nodes; +int *allowed_nodes; - n =0 ; - +get_allowed_nodes_arr (&num_allowed_nodes, &allowed_nodes);for (i =0 ; i < num; i++) { - nodes[i] = i; - + nodes[i] = allowed_nodes[n]; n++; -if (n >numa_max_node ()) +if (n >= num_allowed_nodes) n =0 ; } +free (allowed_nodes);verify_pages_on_nodes (pages, status, num, nodes);#endif
@@ -381,10 +385,14 @@ void free_sem(sem_t * sem, int num)void check_config (unsigned int min_nodes) {#if HAVE_NUMA_H &&HAVE_NUMAIF_H +int num_allowed_nodes; +get_allowed_nodes_arr (&num_allowed_nodes,NULL ); +if (numa_available () <0 ) {tst_brkm (TCONF ,NULL ,"NUMA support is not available" ); - }else if (numa_max_node () < (min_nodes -1 )) { -tst_brkm (TCONF ,NULL ,"atleast 2 NUMA nodes are required" ); + }else if (num_allowed_nodes < min_nodes) { +tst_brkm (TCONF ,NULL ,"at least %d allowed NUMA nodes" +" are required" , min_nodes); }else if (tst_kvercmp (2 ,6 ,18 ) <0 ) {tst_brkm (TCONF ,NULL ,"2.6.18 or greater kernel required" ); }
testcases/kernel/syscalls/move_pages/move_pages_support.h +1 -0
@@ -27,6 +27,7 @@#include <numaif.h> #endif #include <semaphore.h> +#include "numa_helper.h" long get_page_size ();
------------------------------------------------------------------------------
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 2 lines · Jan Stancek
Signed-off-by Jan Stancek <[email protected]>
My comment about TERRNO from the other patch applies to this as well, but this looks ok.
-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