[PATCH 1/2] handle NUMA distances properly for non-contiguous nodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patch: numactl-handle-NUMA-dist-properly.patch

This patch fixes the problem of displaying incorrect NUMA distances. It
increases the table size to accomodate node distance information for
nodes from 0 to nodemax. parse_numbers() makes sure not to add distances
for nodes which are not existing.

Signed-off-by: Amit K Arora <aarora@xxxxxxxxxxxxxxxxxx>

diff -Nuarp numactl-2.0.2.ORG/distance.c numactl-2.0.2/distance.c
--- numactl-2.0.2.ORG/distance.c	2009-03-02 02:34:12.000000000 -0600
+++ numactl-2.0.2/distance.c	2009-03-02 05:29:48.000000000 -0600
@@ -26,25 +26,16 @@
 static int distance_numnodes;
 static int *distance_table; 
 
-static int count_numbers(char *s)
-{
-	int n = 0;
-	for (;;) {
-		char *end;  
-		strtoul(s, &end, 0);
-		if (s == end)
-			return n;
-		s = end;
-		n++; 
-	}
-}
-
 static void parse_numbers(char *s, int *iptr, int n)
 {
-	int i;
+	int i, d, j;
 	char *end;
-	for (i = 0; i < n; i++) { 
-		*iptr++ = strtoul(s, &end, 0);
+	for (i = 0, j = 0; i < n; i++, j++) { 
+		d = strtoul(s, &end, 0);
+		/* Skip unavailable nodes */
+		while (j<n &&  !numa_bitmask_isbitset(numa_all_nodes_ptr, j))
+			j++;
+		*(iptr+j) = d;
 		if (s == end)
 			break;
 		s = end; 
@@ -68,7 +59,10 @@ static int read_distance_table(void)
 		if (!dfh) { 
 			if (errno == ENOENT && nd > 0)
 				err = 0;
-			break;
+			if (!err && nd<numa_num_configured_nodes())
+				continue;
+			else
+				break;
 		}
 		len = getdelim(&line, &linelen, '\n', dfh);
 		fclose(dfh);
@@ -76,7 +70,7 @@ static int read_distance_table(void)
 			break;
 
 		if (!table) { 
-			numnodes = count_numbers(line); 
+			numnodes = numa_num_configured_nodes();
 			table = calloc(numnodes * numnodes, sizeof(int)); 
 			if (!table) {
 				errno = ENOMEM; 

--
Regards,
Amit Arora
--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux