Skip to contentSkip to conversation

move_pages: dont use hardcoded NUMA node ids

PATCH Superseded Jan Stancek 1 participant 1 message May 29, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v2 4/4 move_pages: dont use hardcoded NUMA node ids

---
 testcases/kernel/syscalls/move_pages/Makefile      |    5 +-
 .../kernel/syscalls/move_pages/move_pages02.c      |   11 +++--
 .../kernel/syscalls/move_pages/move_pages03.c      |   11 +++--
 .../kernel/syscalls/move_pages/move_pages04.c      |   11 +++--
 .../kernel/syscalls/move_pages/move_pages05.c      |   11 +++--
 .../kernel/syscalls/move_pages/move_pages06.c      |    9 +++-
 .../kernel/syscalls/move_pages/move_pages07.c      |   11 +++--
 .../kernel/syscalls/move_pages/move_pages08.c      |    9 +++-
 .../kernel/syscalls/move_pages/move_pages09.c      |    7 ++-
 .../kernel/syscalls/move_pages/move_pages10.c      |   11 +++--
 .../kernel/syscalls/move_pages/move_pages11.c      |   11 +++--
 .../syscalls/move_pages/move_pages_support.c       |   44 ++++++++++++++-----
 .../syscalls/move_pages/move_pages_support.h       |    1 +
 13 files changed, 101 insertions(+), 51 deletions(-)
testcases/kernel/syscalls/move_pages/Makefile +2 -3
index d233378..cf2b83f 100644
@@ -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 +7 -4
index cd0e914..410e368 100644
@@ -83,15 +83,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 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 +159,4 @@ void cleanup(void)
 	 */
 	TEST_CLEANUP;
 
- }
\ No newline at end of file
+ }
testcases/kernel/syscalls/move_pages/move_pages03.c +7 -4
index 791835b..77de94d 100644
@@ -122,15 +122,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 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 +226,4 @@ void cleanup(void)
 	 */
 	TEST_CLEANUP;
 
- }
\ No newline at end of file
+ }
testcases/kernel/syscalls/move_pages/move_pages04.c +7 -4
index 4de116b..acb4c78 100644
@@ -89,15 +89,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 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 +178,4 @@ void cleanup(void)
 	 */
 	TEST_CLEANUP;
 
- }
\ No newline at end of file
+ }
testcases/kernel/syscalls/move_pages/move_pages05.c +7 -4
index 6b2334b..d2db475 100644
@@ -123,15 +123,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 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 +240,4 @@ void cleanup(void)
 	 */
 	TEST_CLEANUP;
 
- }
\ No newline at end of file
+ }
testcases/kernel/syscalls/move_pages/move_pages06.c +6 -3
index 16e8206..6929f8d 100644
@@ -83,15 +83,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;
 	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 +155,4 @@ void cleanup(void)
 	 */
 	TEST_CLEANUP;
 
- }
\ No newline at end of file
+ }
testcases/kernel/syscalls/move_pages/move_pages07.c +7 -4
index 2d2b1d8..4a1f96a 100644
@@ -83,15 +83,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 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 +166,4 @@ void cleanup(void)
 	 */
 	TEST_CLEANUP;
 
- }
\ No newline at end of file
+ }
testcases/kernel/syscalls/move_pages/move_pages08.c +6 -3
index 44c9acc..9b36a00 100644
@@ -81,15 +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 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 +5 -2
index 3a626e8..8190a26 100644
@@ -81,14 +81,17 @@ 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 +7 -4
index 7af861b..cec114c 100644
@@ -83,15 +83,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 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 +154,4 @@ void cleanup(void)
 	 */
 	TEST_CLEANUP;
 
- }
\ No newline at end of file
+ }
testcases/kernel/syscalls/move_pages/move_pages11.c +7 -4
index 747b9f0..3d82c6f 100644
@@ -122,15 +122,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 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 +244,4 @@ void cleanup(void)
 	 */
 	TEST_CLEANUP;
 
- }
\ No newline at end of file
+ }
testcases/kernel/syscalls/move_pages/move_pages_support.c +32 -12

82 lines not on this page · raw message

testcases/kernel/syscalls/move_pages/move_pages_support.h +1 -0
index fd78572..bb8f636 100644
@@ -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