diff options
Diffstat (limited to 'drivers/base/node.c')
| -rw-r--r-- | drivers/base/node.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c index cbd0f62b4870..eae2bdc183bb 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/cpumask.h> | 11 | #include <linux/cpumask.h> |
| 12 | #include <linux/topology.h> | 12 | #include <linux/topology.h> |
| 13 | #include <linux/nodemask.h> | 13 | #include <linux/nodemask.h> |
| 14 | #include <linux/cpu.h> | ||
| 14 | 15 | ||
| 15 | static struct sysdev_class node_class = { | 16 | static struct sysdev_class node_class = { |
| 16 | set_kset_name("node"), | 17 | set_kset_name("node"), |
| @@ -192,9 +193,38 @@ void unregister_node(struct node *node) | |||
| 192 | 193 | ||
| 193 | struct node node_devices[MAX_NUMNODES]; | 194 | struct node node_devices[MAX_NUMNODES]; |
| 194 | 195 | ||
| 196 | /* | ||
| 197 | * register cpu under node | ||
| 198 | */ | ||
| 199 | int register_cpu_under_node(unsigned int cpu, unsigned int nid) | ||
| 200 | { | ||
| 201 | if (node_online(nid)) { | ||
| 202 | struct sys_device *obj = get_cpu_sysdev(cpu); | ||
| 203 | if (!obj) | ||
| 204 | return 0; | ||
| 205 | return sysfs_create_link(&node_devices[nid].sysdev.kobj, | ||
| 206 | &obj->kobj, | ||
| 207 | kobject_name(&obj->kobj)); | ||
| 208 | } | ||
| 209 | |||
| 210 | return 0; | ||
| 211 | } | ||
| 212 | |||
| 213 | int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) | ||
| 214 | { | ||
| 215 | if (node_online(nid)) { | ||
| 216 | struct sys_device *obj = get_cpu_sysdev(cpu); | ||
| 217 | if (obj) | ||
| 218 | sysfs_remove_link(&node_devices[nid].sysdev.kobj, | ||
| 219 | kobject_name(&obj->kobj)); | ||
| 220 | } | ||
| 221 | return 0; | ||
| 222 | } | ||
| 223 | |||
| 195 | int register_one_node(int nid) | 224 | int register_one_node(int nid) |
| 196 | { | 225 | { |
| 197 | int error = 0; | 226 | int error = 0; |
| 227 | int cpu; | ||
| 198 | 228 | ||
| 199 | if (node_online(nid)) { | 229 | if (node_online(nid)) { |
| 200 | int p_node = parent_node(nid); | 230 | int p_node = parent_node(nid); |
| @@ -204,6 +234,12 @@ int register_one_node(int nid) | |||
| 204 | parent = &node_devices[p_node]; | 234 | parent = &node_devices[p_node]; |
| 205 | 235 | ||
| 206 | error = register_node(&node_devices[nid], nid, parent); | 236 | error = register_node(&node_devices[nid], nid, parent); |
| 237 | |||
| 238 | /* link cpu under this node */ | ||
| 239 | for_each_present_cpu(cpu) { | ||
| 240 | if (cpu_to_node(cpu) == nid) | ||
| 241 | register_cpu_under_node(cpu, nid); | ||
| 242 | } | ||
| 207 | } | 243 | } |
| 208 | 244 | ||
| 209 | return error; | 245 | return error; |
