[patch -mm 7/7] x86_64: export physnode mapping to userspace

From: David Rientjes
Date: Wed Jan 31 2007 - 10:20:15 EST


Exports the physical NUMA node to fake NUMA node mapping to user-space via
sysfs. The information is now accessible via the 'physnode' file.

Cc: Andi Kleen <ak@xxxxxxx>
Signed-off-by: Rohit Seth <rohitseth@xxxxxxxxxx>
Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>
---
drivers/base/node.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 001e6f6..548d365 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -136,6 +136,13 @@ static ssize_t node_read_distance(struct sys_device * dev, char * buf)
}
static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL);

+#ifdef CONFIG_NUMA_EMU
+static ssize_t node_read_physnode(struct sys_device *dev, char *buf)
+{
+ return sprintf(buf, "%d\n", get_phys_node(dev->id));
+}
+static SYSDEV_ATTR(physnode, S_IRUGO, node_read_physnode, NULL);
+#endif

/*
* register_node - Setup a driverfs device for a node.
@@ -156,6 +163,9 @@ int register_node(struct node *node, int num, struct node *parent)
sysdev_create_file(&node->sysdev, &attr_meminfo);
sysdev_create_file(&node->sysdev, &attr_numastat);
sysdev_create_file(&node->sysdev, &attr_distance);
+#ifdef CONFIG_NUMA_EMU
+ sysdev_create_file(&node->sysdev, &attr_physnode);
+#endif
}
return error;
}
@@ -173,6 +183,9 @@ void unregister_node(struct node *node)
sysdev_remove_file(&node->sysdev, &attr_meminfo);
sysdev_remove_file(&node->sysdev, &attr_numastat);
sysdev_remove_file(&node->sysdev, &attr_distance);
+#ifdef CONFIG_NUMA_EMU
+ sysdev_remove_file(&node->sysdev, &attr_physnode);
+#endif

sysdev_unregister(&node->sysdev);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/