Blame SOURCES/0006-Fix-move_pages-test-for-non-contiguous-nodes.patch

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