|
|
c88143 |
From bad479d2fe1075cfc83ffbd4ad39bcc6e800e7ca Mon Sep 17 00:00:00 2001
|
|
|
c88143 |
From: Harish <harish@linux.vnet.ibm.com>
|
|
|
c88143 |
Date: Thu, 5 Jul 2018 12:08:33 +0530
|
|
|
c88143 |
Subject: [PATCH 6/7] Fix: move_pages test for non-contiguous nodes
|
|
|
c88143 |
|
|
|
c88143 |
Patch fixes move_pages test for non-contiguous memory nodes and
|
|
|
c88143 |
distributed pages among existing memory nodes instead of assuming
|
|
|
c88143 |
continuous node IDs.
|
|
|
c88143 |
|
|
|
c88143 |
Signed-off-by: Harish <harish@linux.vnet.ibm.com>
|
|
|
c88143 |
Signed-off-by: Pingfan Liu <piliu@redhat.com>
|
|
|
c88143 |
---
|
|
|
c88143 |
test/move_pages.c | 28 +++++++++++++++++++++++++---
|
|
|
c88143 |
1 file changed, 25 insertions(+), 3 deletions(-)
|
|
|
c88143 |
|
|
|
c88143 |
diff --git a/test/move_pages.c b/test/move_pages.c
|
|
|
c88143 |
index c5010e2..4b207e8 100644
|
|
|
c88143 |
--- a/test/move_pages.c
|
|
|
c88143 |
+++ b/test/move_pages.c
|
|
|
c88143 |
@@ -21,6 +21,24 @@ int *status;
|
|
|
c88143 |
int *nodes;
|
|
|
c88143 |
int errors;
|
|
|
c88143 |
int nr_nodes;
|
|
|
c88143 |
+int *node_to_use;
|
|
|
c88143 |
+
|
|
|
c88143 |
+int get_node_list()
|
|
|
c88143 |
+{
|
|
|
c88143 |
+ int a, got_nodes = 0, max_node, numnodes;
|
|
|
c88143 |
+ long free_node_sizes;
|
|
|
c88143 |
+
|
|
|
c88143 |
+ numnodes = numa_num_configured_nodes();
|
|
|
c88143 |
+ node_to_use = (int *)malloc(numnodes * sizeof(int));
|
|
|
c88143 |
+ max_node = numa_max_node();
|
|
|
c88143 |
+ for (a = 0; a <= max_node; a++) {
|
|
|
c88143 |
+ if (numa_node_size(a, &free_node_sizes) > 0)
|
|
|
c88143 |
+ node_to_use[got_nodes++] = a;
|
|
|
c88143 |
+ }
|
|
|
c88143 |
+ if(got_nodes != numnodes)
|
|
|
c88143 |
+ return -1;
|
|
|
c88143 |
+ return got_nodes;
|
|
|
c88143 |
+}
|
|
|
c88143 |
|
|
|
c88143 |
int main(int argc, char **argv)
|
|
|
c88143 |
{
|
|
|
c88143 |
@@ -28,12 +46,16 @@ int main(int argc, char **argv)
|
|
|
c88143 |
|
|
|
c88143 |
pagesize = getpagesize();
|
|
|
c88143 |
|
|
|
c88143 |
- nr_nodes = numa_max_node() + 1;
|
|
|
c88143 |
+ nr_nodes = get_node_list();
|
|
|
c88143 |
|
|
|
c88143 |
if (nr_nodes < 2) {
|
|
|
c88143 |
printf("A minimum of 2 nodes is required for this test.\n");
|
|
|
c88143 |
exit(1);
|
|
|
c88143 |
}
|
|
|
c88143 |
+ if (nr_nodes == -1) {
|
|
|
c88143 |
+ printf("Mismatch between congfigured nodes and memory-rich nodes.\n");
|
|
|
c88143 |
+ exit(1);
|
|
|
c88143 |
+ }
|
|
|
c88143 |
|
|
|
c88143 |
setbuf(stdout, NULL);
|
|
|
c88143 |
printf("move_pages() test ......\n");
|
|
|
c88143 |
@@ -58,7 +80,7 @@ int main(int argc, char **argv)
|
|
|
c88143 |
/* We leave page 2 unallocated */
|
|
|
c88143 |
pages[ i * pagesize ] = (char) i;
|
|
|
c88143 |
addr[i] = pages + i * pagesize;
|
|
|
c88143 |
- nodes[i] = (i % nr_nodes);
|
|
|
c88143 |
+ nodes[i] = node_to_use[(i % nr_nodes)];
|
|
|
c88143 |
status[i] = -123;
|
|
|
c88143 |
}
|
|
|
c88143 |
|
|
|
c88143 |
@@ -82,7 +104,7 @@ int main(int argc, char **argv)
|
|
|
c88143 |
if (i != 2) {
|
|
|
c88143 |
if (pages[ i* pagesize ] != (char) i)
|
|
|
c88143 |
errors++;
|
|
|
c88143 |
- else if (nodes[i] != (i % nr_nodes))
|
|
|
c88143 |
+ else if (nodes[i] != node_to_use[(i % nr_nodes)])
|
|
|
c88143 |
errors++;
|
|
|
c88143 |
}
|
|
|
c88143 |
}
|
|
|
c88143 |
--
|
|
|
c88143 |
2.7.4
|
|
|
c88143 |
|