[PATCH 2/2] make node distance writeable

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

 



This adds the ability to write the node distance for NUMA systems.  This is 
generally handled by the SLIT but unfortunately the large majority of systems 
do not have a SLIT as Windows does not use them. Until now if no SLIT was 
found all remote nodes had a distance of 20 which is ok for 2P systems but 
wrong for 4P and larger.

Signed-off-by: Joachim Deguara <[email protected]>


--
Index: kernel/drivers/base/node.c
===================================================================
--- kernel.orig/drivers/base/node.c
+++ kernel/drivers/base/node.c
@@ -129,7 +129,30 @@ static ssize_t node_read_distance(struct
 	len += sprintf(buf + len, "\n");
 	return len;
 }
-static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL);
+
+//takes a space seperated string as the distances of online nodes
+static ssize_t node_write_distance(struct sys_device * dev, const char * buf,
+					size_t size){
+	int i, ret;
+	u8 dist;
+
+	for_each_online_node(i){
+		if (i){
+			buf = strchr(buf, ' ');
+			buf++;
+		}
+		ret = sscanf(buf, "%hu", &dist);
+		if (!ret)
+			return -EINVAL;
+		if (dist < 10)
+			dist = 10;
+		set_node_distance(dev->id, i, dist);
+	}
+	return size;
+}
+
+static SYSDEV_ATTR(distance, S_IRUGO | S_IWUSR, node_read_distance,
+		node_write_distance);
 
 
 /*
Index: kernel/arch/x86_64/mm/srat.c
===================================================================
--- kernel.orig/arch/x86_64/mm/srat.c
+++ kernel/arch/x86_64/mm/srat.c
@@ -471,6 +471,18 @@ int __node_distance(int a, int b)
 
 EXPORT_SYMBOL(__node_distance);
 
+void __set_node_distance(int a, int b, u8 dist)
+{
+	int index;
+
+	if (!acpi_slit)
+		return;
+	index = acpi_slit->locality_count * node_to_pxm(a);
+	acpi_slit->entry[index + node_to_pxm(b)] = dist;
+}
+
+EXPORT_SYMBOL(__set_node_distance);
+
 int memory_add_physaddr_to_nid(u64 start)
 {
 	int i, ret = 0;
Index: kernel/include/asm-x86_64/topology.h
===================================================================
--- kernel.orig/include/asm-x86_64/topology.h
+++ kernel/include/asm-x86_64/topology.h
@@ -14,7 +14,9 @@ extern cpumask_t     node_to_cpumask[];
 
 #ifdef CONFIG_ACPI_NUMA
 extern int __node_distance(int, int);
+extern void __set_node_distance(int, int, u8);
 #define node_distance(a,b) __node_distance(a,b)
+#define set_node_distance(a,b,dist) __set_node_distance(a,b,dist)
 /* #else fallback version */
 #endif
 


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux