Skip to contentSkip to conversation

- Externel SLIT table information thru sysfs

PATCH In review Jack Steiner 3 participants 5 messages Nov 24, 2004 – Nov 27, 2004 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 - Externel SLIT table information thru sysfs

The ACPI SLIT table provides useful information on internode distances. Here is a patch to externalize the SLIT information.

For example:

        # cd /sys/devices/system
        # find .
        ./node
        ./node/node5
        ./node/node5/distance
        ./node/node5/numastat
        ./node/node5/meminfo
        ./node/node5/cpumap
        # cat ./node/node0/distance
        10 20 64 42 42 22
        # cat node/*/distance
        10 20 64 42 42 22
        20 10 42 22 64 84
        64 42 10 20 22 42
        42 22 20 10 42 62
        42 64 22 42 10 20
        22 84 42 62 20 10

Add SLIT (inter node distance) information to sysfs.

drivers/base/node.c +19 -0
Index: linux/drivers/base/node.c
===================================================================
@@ -111,6 +111,24 @@ static ssize_t node_read_numastat(struct
 }
 static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
 
+static ssize_t node_read_distance(struct sys_device * dev, char * buf)
+{
+	int nid = dev->id;
+	int len = 0;
+	int i;
+
+	/* buf currently PAGE_SIZE, need ~4 chars per node */
+	BUILD_BUG_ON(NR_NODES*4 > PAGE_SIZE/2);
+
+	for (i = 0; i < numnodes; i++)
+		len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i));
+		
+	len += sprintf(buf + len, "\n");
+	return len;
+}
+static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL);
+
+
 /*
  * register_node - Setup a driverfs device for a node.
  * @num - Node number to use when creating the device.
@@ -129,6 +147,7 @@ int __init register_node(struct node *no
 		sysdev_create_file(&node->sysdev, &attr_cpumap);
 		sysdev_create_file(&node->sysdev, &attr_meminfo);
 		sysdev_create_file(&node->sysdev, &attr_numastat);
+		sysdev_create_file(&node->sysdev, &attr_distance);
 	}
 	return error;
 }
include/asm-i386/topology.h +0 -3
Index: linux/include/asm-i386/topology.h
===================================================================
@@ -66,9 +66,6 @@ static inline cpumask_t pcibus_to_cpumas
 	return node_to_cpumask(mp_bus_id_to_node[bus]);
 }
 
-/* Node-to-Node distance */
-#define node_distance(from, to) ((from) != (to))
-
 /* sched_domains SD_NODE_INIT for NUMAQ machines */
 #define SD_NODE_INIT (struct sched_domain) {		\
 	.span			= CPU_MASK_NONE,	\
include/linux/topology.h +4 -1
Index: linux/include/linux/topology.h
===================================================================
@@ -55,7 +55,10 @@ static inline int __next_node_with_cpus(
 	for (node = 0; node < numnodes; node = __next_node_with_cpus(node))
 
 #ifndef node_distance
-#define node_distance(from,to)	((from) != (to))
+/* Conform to ACPI 2.0 SLIT distance definitions */
+#define LOCAL_DISTANCE		10
+#define REMOTE_DISTANCE		20
+#define node_distance(from,to)	((from) == (to) ? LOCAL_DISTANCE : REMOTE_DISTANCE)
 #endif
 #ifndef PENALTY_FOR_NODE_WITH_CPUS
 #define PENALTY_FOR_NODE_WITH_CPUS	(1)
Signature · 4 lines
Thanks

Jack Steiner ([email protected])          651-683-5302
Principal Engineer                      SGI - Silicon Graphics, Inc.
#1 lore raw
Quoted 17 lines · Jack Steiner

The ACPI SLIT table provides useful information on internode distances. Here is a patch to externalize the SLIT information.

For example:

        # cd /sys/devices/system
        # find .
        ./node
        ./node/node5
        ./node/node5/distance
        ./node/node5/numastat
        ./node/node5/meminfo
        ./node/node5/cpumap
        # cat ./node/node0/distance
        10 20 64 42 42 22
Quoted 7 lines
        # cat node/*/distance
        10 20 64 42 42 22
        20 10 42 22 64 84
        64 42 10 20 22 42
        42 22 20 10 42 62
        42 64 22 42 10 20
        22 84 42 62 20 10

Apparently I'm easily confused, but node_distance() {near end} seems to evaluate to either 10 or 20 (only), so what are all of these other numbers here?

And how many nodes are in this example?
Maybe 6, numbered 0 thru 5? Plz correct this guess....

Quoted 31 lines

Index: linux/drivers/base/node.c
===================================================================

drivers/base/node.c +18 -0
@@ -111,6 +111,24 @@ static ssize_t node_read_numastat(struct
 }
 static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
 
+static ssize_t node_read_distance(struct sys_device * dev, char * buf)
+{
+	int nid = dev->id;
+	int len = 0;
+	int i;
+
+	/* buf currently PAGE_SIZE, need ~4 chars per node */
+	BUILD_BUG_ON(NR_NODES*4 > PAGE_SIZE/2);
+
+	for (i = 0; i < numnodes; i++)
+		len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i));
+		
+	len += sprintf(buf + len, "\n");
+	return len;
+}
+static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL);
+
+

Index: linux/include/linux/topology.h
===================================================================

include/linux/topology.h static inline int __next_node_with_cpus( · line 61

Quoted 8 lines
include/linux/topology.h +4 -1
@@ -55,7 +55,10 @@ static inline int __next_node_with_cpus(
 	for (node = 0; node < numnodes; node = __next_node_with_cpus(node))
 
 #ifndef node_distance
-#define node_distance(from,to)	((from) != (to))
+/* Conform to ACPI 2.0 SLIT distance definitions */
+#define LOCAL_DISTANCE		10
+#define REMOTE_DISTANCE		20
+#define node_distance(from,to)	((from) == (to) ? LOCAL_DISTANCE : REMOTE_DISTANCE)

Please add a space after "from,".

Quoted 1 line
include/linux/topology.h +0 -0
 #endif
Signature · 1 line
~Randy
#2 lore raw
Quoted 15 lines · Randy.Dunlap
Quoted 14 lines · Jack Steiner

The ACPI SLIT table provides useful information on internode distances. Here is a patch to externalize the SLIT information.

For example:

       # cd /sys/devices/system
       # find .
       ./node
       ./node/node5
       ./node/node5/distance
       ./node/node5/numastat
       ./node/node5/meminfo
       ./node/node5/cpumap
Quoted 2 lines
Quoted 2 lines
       # cat ./node/node0/distance
       10 20 64 42 42 22

Care to turn this into a one value per file implementation instead of this? That will make it easier to determine exactly what the data in each file is, and follow the sysfs rules.

thanks,

greg k-h

#3 lore raw

(resend - first bounced)

Quoted 26 lines · Randy.Dunlap
Quoted 17 lines · Jack Steiner

The ACPI SLIT table provides useful information on internode distances. Here is a patch to externalize the SLIT information.

For example:

       # cd /sys/devices/system
       # find .
       ./node
       ./node/node5
       ./node/node5/distance
       ./node/node5/numastat
       ./node/node5/meminfo
       ./node/node5/cpumap
       # cat ./node/node0/distance
       10 20 64 42 42 22
Quoted 7 lines
       # cat node/*/distance
       10 20 64 42 42 22
       20 10 42 22 64 84
       64 42 10 20 22 42
       42 22 20 10 42 62
       42 64 22 42 10 20
       22 84 42 62 20 10
Quoted 3 lines

Apparently I'm easily confused, but node_distance() {near end} seems to evaluate to either 10 or 20 (only), so what are all of these other numbers here?

On systems that provide the ACPI SLIT table, the distances come from the SLIT table. (See the ACPI spec for the full definition). The example above is from the ACPI SLIT table of a 6-node SGI Altix system and the table is provided by the BIOS.

If the BIOS does not provide a SLIT table, the default distance is 10 for local & 20 for remote. The value of 10 conforms to the spec for local distance, 20 is arbitrary but indicates further than local.

Quoted 3 lines

And how many nodes are in this example?
Maybe 6, numbered 0 thru 5? Plz correct this guess....

Good guess.

Quoted 49 lines
Quoted 34 lines

Index: linux/drivers/base/node.c
===================================================================

drivers/base/node.c +18 -0
@@ -111,6 +111,24 @@ static ssize_t node_read_numastat(struct
 }
 static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
 
+static ssize_t node_read_distance(struct sys_device * dev, char * buf)
+{
+	int nid = dev->id;
+	int len = 0;
+	int i;
+
+	/* buf currently PAGE_SIZE, need ~4 chars per node */
+	BUILD_BUG_ON(NR_NODES*4 > PAGE_SIZE/2);
+
+	for (i = 0; i < numnodes; i++)
+		len += sprintf(buf + len, "%s%d", i ? " " : "", 
 node_distance(nid, i));
+		
+	len += sprintf(buf + len, "\n");
+	return len;
+}
+static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL);
+
+

Index: linux/include/linux/topology.h
===================================================================
--- linux.orig/include/linux/topology.h 2004-11-05
08:34:57.492932000 -0600
+++ linux/include/linux/topology.h 2004-11-23 10:03:26.700821978 -0600

drivers/base/node.c static inline int __next_node_with_cpus( · line 62

Quoted 9 lines
drivers/base/node.c +4 -1
@@ -55,7 +55,10 @@ static inline int __next_node_with_cpus(
 	for (node = 0; node < numnodes; node = __next_node_with_cpus(node))
 
 #ifndef node_distance
-#define node_distance(from,to)	((from) != (to))
+/* Conform to ACPI 2.0 SLIT distance definitions */
+#define LOCAL_DISTANCE		10
+#define REMOTE_DISTANCE		20
+#define node_distance(from,to)	((from) == (to) ? LOCAL_DISTANCE : 
 REMOTE_DISTANCE)

Please add a space after "from,".

Quoted 1 line
drivers/base/node.c +0 -0
 #endif
Signature · 1 line
~Randy
Signature · 4 lines
Thanks

Jack Steiner ([email protected])          651-683-5302
Principal Engineer                      SGI - Silicon Graphics, Inc.
#4 lore raw
In reply to Randy.Dunlap
Quoted 26 lines · Randy.Dunlap
Quoted 17 lines · Jack Steiner

The ACPI SLIT table provides useful information on internode distances. Here is a patch to externalize the SLIT information.

For example:

       # cd /sys/devices/system
       # find .
       ./node
       ./node/node5
       ./node/node5/distance
       ./node/node5/numastat
       ./node/node5/meminfo
       ./node/node5/cpumap
       # cat ./node/node0/distance
       10 20 64 42 42 22
Quoted 7 lines
       # cat node/*/distance
       10 20 64 42 42 22
       20 10 42 22 64 84
       64 42 10 20 22 42
       42 22 20 10 42 62
       42 64 22 42 10 20
       22 84 42 62 20 10
Quoted 3 lines

Apparently I'm easily confused, but node_distance() {near end} seems to evaluate to either 10 or 20 (only), so what are all of these other numbers here?

On systems that provide the ACPI SLIT table, the distances come from the SLIT table. (See the ACPI spec for the full definition). The example above is from the ACPI SLIT table of a 6-node SGI Altix system and the table is provided by the BIOS.

If the BIOS does not provide a SLIT table, the default distance is 10 for local & 20 for remote. The value of 10 conforms to the spec for local distance, 20 is arbitrary but indicates further than local.

Quoted 3 lines

And how many nodes are in this example?
Maybe 6, numbered 0 thru 5? Plz correct this guess....

Good guess.

Quoted 49 lines
Quoted 34 lines

Index: linux/drivers/base/node.c
===================================================================

drivers/base/node.c +18 -0
@@ -111,6 +111,24 @@ static ssize_t node_read_numastat(struct
 }
 static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
 
+static ssize_t node_read_distance(struct sys_device * dev, char * buf)
+{
+	int nid = dev->id;
+	int len = 0;
+	int i;
+
+	/* buf currently PAGE_SIZE, need ~4 chars per node */
+	BUILD_BUG_ON(NR_NODES*4 > PAGE_SIZE/2);
+
+	for (i = 0; i < numnodes; i++)
+		len += sprintf(buf + len, "%s%d", i ? " " : "", 
 node_distance(nid, i));
+		
+	len += sprintf(buf + len, "\n");
+	return len;
+}
+static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL);
+
+

Index: linux/include/linux/topology.h
===================================================================
--- linux.orig/include/linux/topology.h 2004-11-05
08:34:57.492932000 -0600
+++ linux/include/linux/topology.h 2004-11-23 10:03:26.700821978 -0600

drivers/base/node.c static inline int __next_node_with_cpus( · line 62

Quoted 9 lines
drivers/base/node.c +4 -1
@@ -55,7 +55,10 @@ static inline int __next_node_with_cpus(
 	for (node = 0; node < numnodes; node = __next_node_with_cpus(node))
 
 #ifndef node_distance
-#define node_distance(from,to)	((from) != (to))
+/* Conform to ACPI 2.0 SLIT distance definitions */
+#define LOCAL_DISTANCE		10
+#define REMOTE_DISTANCE		20
+#define node_distance(from,to)	((from) == (to) ? LOCAL_DISTANCE : 
 REMOTE_DISTANCE)

Please add a space after "from,".

Quoted 1 line
drivers/base/node.c +0 -0
 #endif
Signature · 1 line
~Randy
Signature · 4 lines
Thanks

Jack Steiner ([email protected])          651-683-5302
Principal Engineer                      SGI - Silicon Graphics, Inc.