Commit e2caa640 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Add cpus and NUMA memory nodes to sysfs. Also add cpu physical id.

From: Anton Blanchard <anton@samba.org>

Add cpus and NUMA memory nodes to sysfs. Also add cpu physical id.
parent 1097a979
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/cache.h> #include <linux/cache.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/sysdev.h>
#include <linux/cpu.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/atomic.h> #include <asm/atomic.h>
...@@ -726,3 +728,71 @@ void __init smp_cpus_done(unsigned int max_cpus) ...@@ -726,3 +728,71 @@ void __init smp_cpus_done(unsigned int max_cpus)
set_cpus_allowed(current, old_mask); set_cpus_allowed(current, old_mask);
} }
#ifdef CONFIG_NUMA
static struct node node_devices[MAX_NUMNODES];
static void register_nodes(void)
{
int i;
int ret;
for (i = 0; i < MAX_NUMNODES; i++) {
if (node_online(i)) {
int p_node = parent_node(i);
struct node *parent = NULL;
if (p_node != i)
parent = &node_devices[p_node];
ret = register_node(&node_devices[i], i, parent);
if (ret)
printk(KERN_WARNING "register_nodes: "
"register_node %d failed (%d)", i, ret);
}
}
}
#else
static void register_nodes(void)
{
return;
}
#endif
/* Only valid if CPU is online. */
static ssize_t show_physical_id(struct sys_device *dev, char *buf)
{
struct cpu *cpu = container_of(dev, struct cpu, sysdev);
return sprintf(buf, "%u\n", get_hard_smp_processor_id(cpu->sysdev.id));
}
static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL);
static DEFINE_PER_CPU(struct cpu, cpu_devices);
static int __init topology_init(void)
{
int cpu;
struct node *parent = NULL;
int ret;
register_nodes();
for_each_cpu(cpu) {
#ifdef CONFIG_NUMA
parent = &node_devices[cpu_to_node(cpu)];
#endif
ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu, parent);
if (ret)
printk(KERN_WARNING "topology_init: register_cpu %d "
"failed (%d)\n", cpu, ret);
ret = sysdev_create_file(&per_cpu(cpu_devices, cpu).sysdev,
&attr_physical_id);
if (ret)
printk(KERN_WARNING "toplogy_init: sysdev_create_file "
"%d failed (%d)\n", cpu, ret);
}
return 0;
}
__initcall(topology_init);
...@@ -100,6 +100,8 @@ static int __init parse_numa_properties(void) ...@@ -100,6 +100,8 @@ static int __init parse_numa_properties(void)
if (numa_domain >= MAX_NUMNODES) if (numa_domain >= MAX_NUMNODES)
BUG(); BUG();
node_set_online(numa_domain);
if (max_domain < numa_domain) if (max_domain < numa_domain)
max_domain = numa_domain; max_domain = numa_domain;
...@@ -201,7 +203,7 @@ static int __init parse_numa_properties(void) ...@@ -201,7 +203,7 @@ static int __init parse_numa_properties(void)
return -1; return -1;
} }
void setup_nonnuma(void) static void __init setup_nonnuma(void)
{ {
unsigned long i; unsigned long i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment