aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/alpha/kernel/setup.c2
-rw-r--r--arch/arm/kernel/setup.c2
-rw-r--r--arch/i386/kernel/topology.c23
-rw-r--r--arch/ia64/kernel/topology.c17
-rw-r--r--arch/m32r/kernel/setup.c2
-rw-r--r--arch/mips/kernel/smp.c2
-rw-r--r--arch/parisc/kernel/topology.c3
-rw-r--r--arch/powerpc/kernel/setup_32.c2
-rw-r--r--arch/powerpc/kernel/sysfs.c12
-rw-r--r--arch/ppc/kernel/setup.c2
-rw-r--r--arch/s390/kernel/smp.c2
-rw-r--r--arch/sh/kernel/setup.c2
-rw-r--r--arch/sh64/kernel/setup.c2
-rw-r--r--arch/sparc64/kernel/setup.c2
-rw-r--r--drivers/base/cpu.c18
-rw-r--r--drivers/base/node.c36
-rw-r--r--include/linux/cpu.h4
-rw-r--r--include/linux/node.h13
18 files changed, 77 insertions, 69 deletions
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index 558b83368559..254c507a608c 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -481,7 +481,7 @@ register_cpus(void)
481 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL); 481 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
482 if (!p) 482 if (!p)
483 return -ENOMEM; 483 return -ENOMEM;
484 register_cpu(p, i, NULL); 484 register_cpu(p, i);
485 } 485 }
486 return 0; 486 return 0;
487} 487}
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 9fc9af88c60c..093ccba0503c 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -808,7 +808,7 @@ static int __init topology_init(void)
808 int cpu; 808 int cpu;
809 809
810 for_each_possible_cpu(cpu) 810 for_each_possible_cpu(cpu)
811 register_cpu(&per_cpu(cpu_data, cpu).cpu, cpu, NULL); 811 register_cpu(&per_cpu(cpu_data, cpu).cpu, cpu);
812 812
813 return 0; 813 return 0;
814} 814}
diff --git a/arch/i386/kernel/topology.c b/arch/i386/kernel/topology.c
index 1eecc2e1bd4b..e2e281d4bcc8 100644
--- a/arch/i386/kernel/topology.c
+++ b/arch/i386/kernel/topology.c
@@ -32,15 +32,8 @@
32 32
33static struct i386_cpu cpu_devices[NR_CPUS]; 33static struct i386_cpu cpu_devices[NR_CPUS];
34 34
35int arch_register_cpu(int num){ 35int arch_register_cpu(int num)
36 struct node *parent = NULL; 36{
37
38#ifdef CONFIG_NUMA
39 int node = cpu_to_node(num);
40 if (node_online(node))
41 parent = &node_devices[parent_node(node)];
42#endif /* CONFIG_NUMA */
43
44 /* 37 /*
45 * CPU0 cannot be offlined due to several 38 * CPU0 cannot be offlined due to several
46 * restrictions and assumptions in kernel. This basically 39 * restrictions and assumptions in kernel. This basically
@@ -50,21 +43,13 @@ int arch_register_cpu(int num){
50 if (!num) 43 if (!num)
51 cpu_devices[num].cpu.no_control = 1; 44 cpu_devices[num].cpu.no_control = 1;
52 45
53 return register_cpu(&cpu_devices[num].cpu, num, parent); 46 return register_cpu(&cpu_devices[num].cpu, num);
54} 47}
55 48
56#ifdef CONFIG_HOTPLUG_CPU 49#ifdef CONFIG_HOTPLUG_CPU
57 50
58void arch_unregister_cpu(int num) { 51void arch_unregister_cpu(int num) {
59 struct node *parent = NULL; 52 return unregister_cpu(&cpu_devices[num].cpu);
60
61#ifdef CONFIG_NUMA
62 int node = cpu_to_node(num);
63 if (node_online(node))
64 parent = &node_devices[parent_node(node)];
65#endif /* CONFIG_NUMA */
66
67 return unregister_cpu(&cpu_devices[num].cpu, parent);
68} 53}
69EXPORT_SYMBOL(arch_register_cpu); 54EXPORT_SYMBOL(arch_register_cpu);
70EXPORT_SYMBOL(arch_unregister_cpu); 55EXPORT_SYMBOL(arch_unregister_cpu);
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 42cb05bdc680..5737c9a061ef 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -30,12 +30,6 @@ static struct ia64_cpu *sysfs_cpus;
30 30
31int arch_register_cpu(int num) 31int arch_register_cpu(int num)
32{ 32{
33 struct node *parent = NULL;
34
35#ifdef CONFIG_NUMA
36 parent = &node_devices[cpu_to_node(num)];
37#endif /* CONFIG_NUMA */
38
39#if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU) 33#if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU)
40 /* 34 /*
41 * If CPEI cannot be re-targetted, and this is 35 * If CPEI cannot be re-targetted, and this is
@@ -45,21 +39,14 @@ int arch_register_cpu(int num)
45 sysfs_cpus[num].cpu.no_control = 1; 39 sysfs_cpus[num].cpu.no_control = 1;
46#endif 40#endif
47 41
48 return register_cpu(&sysfs_cpus[num].cpu, num, parent); 42 return register_cpu(&sysfs_cpus[num].cpu, num);
49} 43}
50 44
51#ifdef CONFIG_HOTPLUG_CPU 45#ifdef CONFIG_HOTPLUG_CPU
52 46
53void arch_unregister_cpu(int num) 47void arch_unregister_cpu(int num)
54{ 48{
55 struct node *parent = NULL; 49 return unregister_cpu(&sysfs_cpus[num].cpu);
56
57#ifdef CONFIG_NUMA
58 int node = cpu_to_node(num);
59 parent = &node_devices[node];
60#endif /* CONFIG_NUMA */
61
62 return unregister_cpu(&sysfs_cpus[num].cpu, parent);
63} 50}
64EXPORT_SYMBOL(arch_register_cpu); 51EXPORT_SYMBOL(arch_register_cpu);
65EXPORT_SYMBOL(arch_unregister_cpu); 52EXPORT_SYMBOL(arch_unregister_cpu);
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index 3cd3c2988a48..1ff483c8a4c9 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -275,7 +275,7 @@ static int __init topology_init(void)
275 int i; 275 int i;
276 276
277 for_each_present_cpu(i) 277 for_each_present_cpu(i)
278 register_cpu(&cpu_devices[i], i, NULL); 278 register_cpu(&cpu_devices[i], i);
279 279
280 return 0; 280 return 0;
281} 281}
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 298f82fe8440..9096a5ea4229 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -446,7 +446,7 @@ static int __init topology_init(void)
446 int ret; 446 int ret;
447 447
448 for_each_present_cpu(cpu) { 448 for_each_present_cpu(cpu) {
449 ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu, NULL); 449 ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu);
450 if (ret) 450 if (ret)
451 printk(KERN_WARNING "topology_init: register_cpu %d " 451 printk(KERN_WARNING "topology_init: register_cpu %d "
452 "failed (%d)\n", cpu, ret); 452 "failed (%d)\n", cpu, ret);
diff --git a/arch/parisc/kernel/topology.c b/arch/parisc/kernel/topology.c
index 3ba040050e4c..068b20d822e7 100644
--- a/arch/parisc/kernel/topology.c
+++ b/arch/parisc/kernel/topology.c
@@ -26,11 +26,10 @@ static struct cpu cpu_devices[NR_CPUS] __read_mostly;
26 26
27static int __init topology_init(void) 27static int __init topology_init(void)
28{ 28{
29 struct node *parent = NULL;
30 int num; 29 int num;
31 30
32 for_each_present_cpu(num) { 31 for_each_present_cpu(num) {
33 register_cpu(&cpu_devices[num], num, parent); 32 register_cpu(&cpu_devices[num], num);
34 } 33 }
35 return 0; 34 return 0;
36} 35}
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index e5a44812441a..0932a62a1c96 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -215,7 +215,7 @@ int __init ppc_init(void)
215 215
216 /* register CPU devices */ 216 /* register CPU devices */
217 for_each_possible_cpu(i) 217 for_each_possible_cpu(i)
218 register_cpu(&cpu_devices[i], i, NULL); 218 register_cpu(&cpu_devices[i], i);
219 219
220 /* call platform init */ 220 /* call platform init */
221 if (ppc_md.init != NULL) { 221 if (ppc_md.init != NULL) {
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 338491d1604a..412ad00e222d 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -348,23 +348,13 @@ static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL);
348static int __init topology_init(void) 348static int __init topology_init(void)
349{ 349{
350 int cpu; 350 int cpu;
351 struct node *parent = NULL;
352 351
353 register_nodes(); 352 register_nodes();
354
355 register_cpu_notifier(&sysfs_cpu_nb); 353 register_cpu_notifier(&sysfs_cpu_nb);
356 354
357 for_each_possible_cpu(cpu) { 355 for_each_possible_cpu(cpu) {
358 struct cpu *c = &per_cpu(cpu_devices, cpu); 356 struct cpu *c = &per_cpu(cpu_devices, cpu);
359 357
360#ifdef CONFIG_NUMA
361 /* The node to which a cpu belongs can't be known
362 * until the cpu is made present.
363 */
364 parent = NULL;
365 if (cpu_present(cpu))
366 parent = &node_devices[cpu_to_node(cpu)];
367#endif
368 /* 358 /*
369 * For now, we just see if the system supports making 359 * For now, we just see if the system supports making
370 * the RTAS calls for CPU hotplug. But, there may be a 360 * the RTAS calls for CPU hotplug. But, there may be a
@@ -376,7 +366,7 @@ static int __init topology_init(void)
376 c->no_control = 1; 366 c->no_control = 1;
377 367
378 if (cpu_online(cpu) || (c->no_control == 0)) { 368 if (cpu_online(cpu) || (c->no_control == 0)) {
379 register_cpu(c, cpu, parent); 369 register_cpu(c, cpu);
380 370
381 sysdev_create_file(&c->sysdev, &attr_physical_id); 371 sysdev_create_file(&c->sysdev, &attr_physical_id);
382 } 372 }
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index 1f79e84ab464..4b4607d89bfa 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -475,7 +475,7 @@ int __init ppc_init(void)
475 475
476 /* register CPU devices */ 476 /* register CPU devices */
477 for_each_possible_cpu(i) 477 for_each_possible_cpu(i)
478 register_cpu(&cpu_devices[i], i, NULL); 478 register_cpu(&cpu_devices[i], i);
479 479
480 /* call platform init */ 480 /* call platform init */
481 if (ppc_md.init != NULL) { 481 if (ppc_md.init != NULL) {
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 343120c9223d..8e03219eea76 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -869,7 +869,7 @@ static int __init topology_init(void)
869 int ret; 869 int ret;
870 870
871 for_each_possible_cpu(cpu) { 871 for_each_possible_cpu(cpu) {
872 ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu, NULL); 872 ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu);
873 if (ret) 873 if (ret)
874 printk(KERN_WARNING "topology_init: register_cpu %d " 874 printk(KERN_WARNING "topology_init: register_cpu %d "
875 "failed (%d)\n", cpu, ret); 875 "failed (%d)\n", cpu, ret);
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index bb229ef030f3..9af22116c9a2 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -402,7 +402,7 @@ static int __init topology_init(void)
402 int cpu_id; 402 int cpu_id;
403 403
404 for_each_possible_cpu(cpu_id) 404 for_each_possible_cpu(cpu_id)
405 register_cpu(&cpu[cpu_id], cpu_id, NULL); 405 register_cpu(&cpu[cpu_id], cpu_id);
406 406
407 return 0; 407 return 0;
408} 408}
diff --git a/arch/sh64/kernel/setup.c b/arch/sh64/kernel/setup.c
index d2711c9c9d13..da98d8dbcf95 100644
--- a/arch/sh64/kernel/setup.c
+++ b/arch/sh64/kernel/setup.c
@@ -309,7 +309,7 @@ static struct cpu cpu[1];
309 309
310static int __init topology_init(void) 310static int __init topology_init(void)
311{ 311{
312 return register_cpu(cpu, 0, NULL); 312 return register_cpu(cpu, 0);
313} 313}
314 314
315subsys_initcall(topology_init); 315subsys_initcall(topology_init);
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index a6a7d8168346..116d9632002d 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -537,7 +537,7 @@ static int __init topology_init(void)
537 for_each_possible_cpu(i) { 537 for_each_possible_cpu(i) {
538 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL); 538 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
539 if (p) { 539 if (p) {
540 register_cpu(p, i, NULL); 540 register_cpu(p, i);
541 err = 0; 541 err = 0;
542 } 542 }
543 } 543 }
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index dd712b24ec91..3972d8ac9786 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -8,6 +8,7 @@
8#include <linux/cpu.h> 8#include <linux/cpu.h>
9#include <linux/topology.h> 9#include <linux/topology.h>
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/node.h>
11 12
12#include "base.h" 13#include "base.h"
13 14
@@ -57,13 +58,12 @@ static void __devinit register_cpu_control(struct cpu *cpu)
57{ 58{
58 sysdev_create_file(&cpu->sysdev, &attr_online); 59 sysdev_create_file(&cpu->sysdev, &attr_online);
59} 60}
60void unregister_cpu(struct cpu *cpu, struct node *root) 61void unregister_cpu(struct cpu *cpu)
61{ 62{
62 int logical_cpu = cpu->sysdev.id; 63 int logical_cpu = cpu->sysdev.id;
63 64
64 if (root) 65 unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu));
65 sysfs_remove_link(&root->sysdev.kobj, 66
66 kobject_name(&cpu->sysdev.kobj));
67 sysdev_remove_file(&cpu->sysdev, &attr_online); 67 sysdev_remove_file(&cpu->sysdev, &attr_online);
68 68
69 sysdev_unregister(&cpu->sysdev); 69 sysdev_unregister(&cpu->sysdev);
@@ -109,23 +109,21 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
109 * 109 *
110 * Initialize and register the CPU device. 110 * Initialize and register the CPU device.
111 */ 111 */
112int __devinit register_cpu(struct cpu *cpu, int num, struct node *root) 112int __devinit register_cpu(struct cpu *cpu, int num)
113{ 113{
114 int error; 114 int error;
115
116 cpu->node_id = cpu_to_node(num); 115 cpu->node_id = cpu_to_node(num);
117 cpu->sysdev.id = num; 116 cpu->sysdev.id = num;
118 cpu->sysdev.cls = &cpu_sysdev_class; 117 cpu->sysdev.cls = &cpu_sysdev_class;
119 118
120 error = sysdev_register(&cpu->sysdev); 119 error = sysdev_register(&cpu->sysdev);
121 if (!error && root) 120
122 error = sysfs_create_link(&root->sysdev.kobj,
123 &cpu->sysdev.kobj,
124 kobject_name(&cpu->sysdev.kobj));
125 if (!error && !cpu->no_control) 121 if (!error && !cpu->no_control)
126 register_cpu_control(cpu); 122 register_cpu_control(cpu);
127 if (!error) 123 if (!error)
128 cpu_sys_devices[num] = &cpu->sysdev; 124 cpu_sys_devices[num] = &cpu->sysdev;
125 if (!error)
126 register_cpu_under_node(num, cpu_to_node(num));
129 127
130#ifdef CONFIG_KEXEC 128#ifdef CONFIG_KEXEC
131 if (!error) 129 if (!error)
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
15static struct sysdev_class node_class = { 16static 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
193struct node node_devices[MAX_NUMNODES]; 194struct node node_devices[MAX_NUMNODES];
194 195
196/*
197 * register cpu under node
198 */
199int 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
213int 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
195int register_one_node(int nid) 224int 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;
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 08d50c53aab4..b23bf1c8addc 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -31,10 +31,10 @@ struct cpu {
31 struct sys_device sysdev; 31 struct sys_device sysdev;
32}; 32};
33 33
34extern int register_cpu(struct cpu *, int, struct node *); 34extern int register_cpu(struct cpu *cpu, int num);
35extern struct sys_device *get_cpu_sysdev(unsigned cpu); 35extern struct sys_device *get_cpu_sysdev(unsigned cpu);
36#ifdef CONFIG_HOTPLUG_CPU 36#ifdef CONFIG_HOTPLUG_CPU
37extern void unregister_cpu(struct cpu *, struct node *); 37extern void unregister_cpu(struct cpu *cpu);
38#endif 38#endif
39struct notifier_block; 39struct notifier_block;
40 40
diff --git a/include/linux/node.h b/include/linux/node.h
index 1e5347527fa8..81dcec84cd8f 100644
--- a/include/linux/node.h
+++ b/include/linux/node.h
@@ -32,6 +32,19 @@ extern int register_node(struct node *, int, struct node *);
32extern void unregister_node(struct node *node); 32extern void unregister_node(struct node *node);
33extern int register_one_node(int nid); 33extern int register_one_node(int nid);
34extern void unregister_one_node(int nid); 34extern void unregister_one_node(int nid);
35#ifdef CONFIG_NUMA
36extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
37extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
38#else
39static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
40{
41 return 0;
42}
43static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
44{
45 return 0;
46}
47#endif
35 48
36#define to_node(sys_device) container_of(sys_device, struct node, sysdev) 49#define to_node(sys_device) container_of(sys_device, struct node, sysdev)
37 50