* [LTP] [PATCH 4/4] move_pages: dont use hardcoded NUMA node ids
@ 2012-05-28 11:39 Jan Stancek
2012-05-28 18:32 ` Garrett Cooper
0 siblings, 1 reply; 2+ messages in thread
From: Jan Stancek @ 2012-05-28 11:39 UTC (permalink / raw)
To: ltp-list; +Cc: Jeffrey Burke
[-- Attachment #1: Type: text/plain, Size: 978 bytes --]
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
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(-)
[-- Attachment #2: 0004-move_pages-dont-use-hardcoded-NUMA-node-ids.patch --]
[-- Type: text/x-patch, Size: 13235 bytes --]
diff --git a/testcases/kernel/syscalls/move_pages/Makefile b/testcases/kernel/syscalls/move_pages/Makefile
index d233378..cf2b83f 100644
--- a/testcases/kernel/syscalls/move_pages/Makefile
+++ b/testcases/kernel/syscalls/move_pages/Makefile
@@ -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
diff --git a/testcases/kernel/syscalls/move_pages/move_pages02.c b/testcases/kernel/syscalls/move_pages/move_pages02.c
index cd0e914..75c8caf 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages02.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages02.c
@@ -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;
- }
\ No newline at end of file
+ }
diff --git a/testcases/kernel/syscalls/move_pages/move_pages03.c b/testcases/kernel/syscalls/move_pages/move_pages03.c
index 791835b..3169235 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages03.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages03.c
@@ -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;
- }
\ No newline at end of file
+ }
diff --git a/testcases/kernel/syscalls/move_pages/move_pages04.c b/testcases/kernel/syscalls/move_pages/move_pages04.c
index 4de116b..8fdea00 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages04.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages04.c
@@ -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;
- }
\ No newline at end of file
+ }
diff --git a/testcases/kernel/syscalls/move_pages/move_pages05.c b/testcases/kernel/syscalls/move_pages/move_pages05.c
index 6b2334b..dd7925a 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages05.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages05.c
@@ -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;
- }
\ No newline at end of file
+ }
diff --git a/testcases/kernel/syscalls/move_pages/move_pages06.c b/testcases/kernel/syscalls/move_pages/move_pages06.c
index 16e8206..650508a 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages06.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages06.c
@@ -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;
- }
\ No newline at end of file
+ }
diff --git a/testcases/kernel/syscalls/move_pages/move_pages07.c b/testcases/kernel/syscalls/move_pages/move_pages07.c
index 2d2b1d8..3177590 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages07.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages07.c
@@ -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;
- }
\ No newline at end of file
+ }
diff --git a/testcases/kernel/syscalls/move_pages/move_pages08.c b/testcases/kernel/syscalls/move_pages/move_pages08.c
index 44c9acc..2d10c37 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages08.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages08.c
@@ -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;
diff --git a/testcases/kernel/syscalls/move_pages/move_pages09.c b/testcases/kernel/syscalls/move_pages/move_pages09.c
index 3a626e8..d7e8b66 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages09.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages09.c
@@ -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;
diff --git a/testcases/kernel/syscalls/move_pages/move_pages10.c b/testcases/kernel/syscalls/move_pages/move_pages10.c
index 7af861b..cf1c44e 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages10.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages10.c
@@ -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;
- }
\ No newline at end of file
+ }
diff --git a/testcases/kernel/syscalls/move_pages/move_pages11.c b/testcases/kernel/syscalls/move_pages/move_pages11.c
index 747b9f0..86ed7bf 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages11.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages11.c
@@ -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;
- }
\ No newline at end of file
+ }
diff --git a/testcases/kernel/syscalls/move_pages/move_pages_support.c b/testcases/kernel/syscalls/move_pages/move_pages_support.c
index 320486f..540e22a 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages_support.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages_support.c
@@ -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");
}
diff --git a/testcases/kernel/syscalls/move_pages/move_pages_support.h b/testcases/kernel/syscalls/move_pages/move_pages_support.h
index fd78572..bb8f636 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages_support.h
+++ b/testcases/kernel/syscalls/move_pages/move_pages_support.h
@@ -27,6 +27,7 @@
#include <numaif.h>
#endif
#include <semaphore.h>
+#include "numa_helper.h"
long get_page_size();
[-- Attachment #3: Type: text/plain, Size: 395 bytes --]
------------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH 4/4] move_pages: dont use hardcoded NUMA node ids
2012-05-28 11:39 [LTP] [PATCH 4/4] move_pages: dont use hardcoded NUMA node ids Jan Stancek
@ 2012-05-28 18:32 ` Garrett Cooper
0 siblings, 0 replies; 2+ messages in thread
From: Garrett Cooper @ 2012-05-28 18:32 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list, Jeffrey Burke
On Mon, May 28, 2012 at 4:39 AM, Jan Stancek <jstancek@redhat.com> wrote:
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-05-28 18:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-28 11:39 [LTP] [PATCH 4/4] move_pages: dont use hardcoded NUMA node ids Jan Stancek
2012-05-28 18:32 ` Garrett Cooper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox