From: David Rientjes 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 Signed-off-by: Rohit Seth Signed-off-by: David Rientjes Cc: Paul Jackson Cc: Christoph Lameter Signed-off-by: Andrew Morton --- drivers/base/node.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff -puN drivers/base/node.c~x86_64-export-physnode-mapping-to-userspace drivers/base/node.c --- a/drivers/base/node.c~x86_64-export-physnode-mapping-to-userspace +++ a/drivers/base/node.c @@ -131,6 +131,13 @@ static ssize_t node_read_distance(struct } 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 sysfs device for a node. @@ -151,6 +158,9 @@ int register_node(struct node *node, int 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; } @@ -168,6 +178,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); } _