diff options
author | Yasunori Goto <y-goto@jp.fujitsu.com> | 2006-06-27 05:53:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-27 20:32:36 -0400 |
commit | 0fc44159bfcb5b0afa178f9c3f50db23aebc76ff (patch) | |
tree | d87e47c0f5e6b2eff1d9113d3495d185924734d9 | |
parent | 1f04bbd2d396a701c5af2e5b92bad896c2550c16 (diff) |
[PATCH] Register sysfs file for hotplugged new node
When new node becomes enable by hot-add, new sysfs file must be created for
new node. So, if new node is enabled by add_memory(), register_one_node() is
called to create it. In addition, I386's arch_register_node() and a part of
register_nodes() of powerpc are consolidated to register_one_node() as a
generic_code().
This is tested by Tiger4(IPF) with node hot-plug emulation.
Signed-off-by: Keiichiro Tokunaga <tokuanga.keiich@jp.fujitsu.com>
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/i386/kernel/topology.c | 9 | ||||
-rw-r--r-- | arch/ia64/kernel/topology.c | 15 | ||||
-rw-r--r-- | arch/powerpc/kernel/sysfs.c | 15 | ||||
-rw-r--r-- | drivers/base/node.c | 25 | ||||
-rw-r--r-- | include/asm-i386/cpu.h | 2 | ||||
-rw-r--r-- | include/asm-i386/node.h | 29 | ||||
-rw-r--r-- | include/linux/node.h | 4 | ||||
-rw-r--r-- | mm/memory_hotplug.c | 12 |
8 files changed, 48 insertions, 63 deletions
diff --git a/arch/i386/kernel/topology.c b/arch/i386/kernel/topology.c index 296355292c7c..1eecc2e1bd4b 100644 --- a/arch/i386/kernel/topology.c +++ b/arch/i386/kernel/topology.c | |||
@@ -38,7 +38,7 @@ int arch_register_cpu(int num){ | |||
38 | #ifdef CONFIG_NUMA | 38 | #ifdef CONFIG_NUMA |
39 | int node = cpu_to_node(num); | 39 | int node = cpu_to_node(num); |
40 | if (node_online(node)) | 40 | if (node_online(node)) |
41 | parent = &node_devices[node].node; | 41 | parent = &node_devices[parent_node(node)]; |
42 | #endif /* CONFIG_NUMA */ | 42 | #endif /* CONFIG_NUMA */ |
43 | 43 | ||
44 | /* | 44 | /* |
@@ -61,7 +61,7 @@ void arch_unregister_cpu(int num) { | |||
61 | #ifdef CONFIG_NUMA | 61 | #ifdef CONFIG_NUMA |
62 | int node = cpu_to_node(num); | 62 | int node = cpu_to_node(num); |
63 | if (node_online(node)) | 63 | if (node_online(node)) |
64 | parent = &node_devices[node].node; | 64 | parent = &node_devices[parent_node(node)]; |
65 | #endif /* CONFIG_NUMA */ | 65 | #endif /* CONFIG_NUMA */ |
66 | 66 | ||
67 | return unregister_cpu(&cpu_devices[num].cpu, parent); | 67 | return unregister_cpu(&cpu_devices[num].cpu, parent); |
@@ -74,16 +74,13 @@ EXPORT_SYMBOL(arch_unregister_cpu); | |||
74 | 74 | ||
75 | #ifdef CONFIG_NUMA | 75 | #ifdef CONFIG_NUMA |
76 | #include <linux/mmzone.h> | 76 | #include <linux/mmzone.h> |
77 | #include <asm/node.h> | ||
78 | |||
79 | struct i386_node node_devices[MAX_NUMNODES]; | ||
80 | 77 | ||
81 | static int __init topology_init(void) | 78 | static int __init topology_init(void) |
82 | { | 79 | { |
83 | int i; | 80 | int i; |
84 | 81 | ||
85 | for_each_online_node(i) | 82 | for_each_online_node(i) |
86 | arch_register_node(i); | 83 | register_one_node(i); |
87 | 84 | ||
88 | for_each_present_cpu(i) | 85 | for_each_present_cpu(i) |
89 | arch_register_cpu(i); | 86 | arch_register_cpu(i); |
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c index 879edb51d1e0..42cb05bdc680 100644 --- a/arch/ia64/kernel/topology.c +++ b/arch/ia64/kernel/topology.c | |||
@@ -26,9 +26,6 @@ | |||
26 | #include <asm/numa.h> | 26 | #include <asm/numa.h> |
27 | #include <asm/cpu.h> | 27 | #include <asm/cpu.h> |
28 | 28 | ||
29 | #ifdef CONFIG_NUMA | ||
30 | static struct node *sysfs_nodes; | ||
31 | #endif | ||
32 | static struct ia64_cpu *sysfs_cpus; | 29 | static struct ia64_cpu *sysfs_cpus; |
33 | 30 | ||
34 | int arch_register_cpu(int num) | 31 | int arch_register_cpu(int num) |
@@ -36,7 +33,7 @@ int arch_register_cpu(int num) | |||
36 | struct node *parent = NULL; | 33 | struct node *parent = NULL; |
37 | 34 | ||
38 | #ifdef CONFIG_NUMA | 35 | #ifdef CONFIG_NUMA |
39 | parent = &sysfs_nodes[cpu_to_node(num)]; | 36 | parent = &node_devices[cpu_to_node(num)]; |
40 | #endif /* CONFIG_NUMA */ | 37 | #endif /* CONFIG_NUMA */ |
41 | 38 | ||
42 | #if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU) | 39 | #if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU) |
@@ -59,7 +56,7 @@ void arch_unregister_cpu(int num) | |||
59 | 56 | ||
60 | #ifdef CONFIG_NUMA | 57 | #ifdef CONFIG_NUMA |
61 | int node = cpu_to_node(num); | 58 | int node = cpu_to_node(num); |
62 | parent = &sysfs_nodes[node]; | 59 | parent = &node_devices[node]; |
63 | #endif /* CONFIG_NUMA */ | 60 | #endif /* CONFIG_NUMA */ |
64 | 61 | ||
65 | return unregister_cpu(&sysfs_cpus[num].cpu, parent); | 62 | return unregister_cpu(&sysfs_cpus[num].cpu, parent); |
@@ -74,17 +71,11 @@ static int __init topology_init(void) | |||
74 | int i, err = 0; | 71 | int i, err = 0; |
75 | 72 | ||
76 | #ifdef CONFIG_NUMA | 73 | #ifdef CONFIG_NUMA |
77 | sysfs_nodes = kzalloc(sizeof(struct node) * MAX_NUMNODES, GFP_KERNEL); | ||
78 | if (!sysfs_nodes) { | ||
79 | err = -ENOMEM; | ||
80 | goto out; | ||
81 | } | ||
82 | |||
83 | /* | 74 | /* |
84 | * MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes? | 75 | * MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes? |
85 | */ | 76 | */ |
86 | for_each_online_node(i) { | 77 | for_each_online_node(i) { |
87 | if ((err = register_node(&sysfs_nodes[i], i, 0))) | 78 | if ((err = register_one_node(i))) |
88 | goto out; | 79 | goto out; |
89 | } | 80 | } |
90 | #endif | 81 | #endif |
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index 5bc2585c8036..338491d1604a 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c | |||
@@ -304,23 +304,12 @@ static struct notifier_block sysfs_cpu_nb = { | |||
304 | /* NUMA stuff */ | 304 | /* NUMA stuff */ |
305 | 305 | ||
306 | #ifdef CONFIG_NUMA | 306 | #ifdef CONFIG_NUMA |
307 | static struct node node_devices[MAX_NUMNODES]; | ||
308 | |||
309 | static void register_nodes(void) | 307 | static void register_nodes(void) |
310 | { | 308 | { |
311 | int i; | 309 | int i; |
312 | 310 | ||
313 | for (i = 0; i < MAX_NUMNODES; i++) { | 311 | for (i = 0; i < MAX_NUMNODES; i++) |
314 | if (node_online(i)) { | 312 | register_one_node(i); |
315 | int p_node = parent_node(i); | ||
316 | struct node *parent = NULL; | ||
317 | |||
318 | if (p_node != i) | ||
319 | parent = &node_devices[p_node]; | ||
320 | |||
321 | register_node(&node_devices[i], i, parent); | ||
322 | } | ||
323 | } | ||
324 | } | 313 | } |
325 | 314 | ||
326 | int sysfs_add_device_to_node(struct sys_device *dev, int nid) | 315 | int sysfs_add_device_to_node(struct sys_device *dev, int nid) |
diff --git a/drivers/base/node.c b/drivers/base/node.c index c80c3aeed004..cbd0f62b4870 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -190,6 +190,31 @@ void unregister_node(struct node *node) | |||
190 | sysdev_unregister(&node->sysdev); | 190 | sysdev_unregister(&node->sysdev); |
191 | } | 191 | } |
192 | 192 | ||
193 | struct node node_devices[MAX_NUMNODES]; | ||
194 | |||
195 | int register_one_node(int nid) | ||
196 | { | ||
197 | int error = 0; | ||
198 | |||
199 | if (node_online(nid)) { | ||
200 | int p_node = parent_node(nid); | ||
201 | struct node *parent = NULL; | ||
202 | |||
203 | if (p_node != nid) | ||
204 | parent = &node_devices[p_node]; | ||
205 | |||
206 | error = register_node(&node_devices[nid], nid, parent); | ||
207 | } | ||
208 | |||
209 | return error; | ||
210 | |||
211 | } | ||
212 | |||
213 | void unregister_one_node(int nid) | ||
214 | { | ||
215 | unregister_node(&node_devices[nid]); | ||
216 | } | ||
217 | |||
193 | static int __init register_node_type(void) | 218 | static int __init register_node_type(void) |
194 | { | 219 | { |
195 | return sysdev_class_register(&node_class); | 220 | return sysdev_class_register(&node_class); |
diff --git a/include/asm-i386/cpu.h b/include/asm-i386/cpu.h index e7252c216ca8..b1bc7b1b64b0 100644 --- a/include/asm-i386/cpu.h +++ b/include/asm-i386/cpu.h | |||
@@ -7,8 +7,6 @@ | |||
7 | #include <linux/nodemask.h> | 7 | #include <linux/nodemask.h> |
8 | #include <linux/percpu.h> | 8 | #include <linux/percpu.h> |
9 | 9 | ||
10 | #include <asm/node.h> | ||
11 | |||
12 | struct i386_cpu { | 10 | struct i386_cpu { |
13 | struct cpu cpu; | 11 | struct cpu cpu; |
14 | }; | 12 | }; |
diff --git a/include/asm-i386/node.h b/include/asm-i386/node.h deleted file mode 100644 index e13c6ffa72ae..000000000000 --- a/include/asm-i386/node.h +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | #ifndef _ASM_I386_NODE_H_ | ||
2 | #define _ASM_I386_NODE_H_ | ||
3 | |||
4 | #include <linux/device.h> | ||
5 | #include <linux/mmzone.h> | ||
6 | #include <linux/node.h> | ||
7 | #include <linux/topology.h> | ||
8 | #include <linux/nodemask.h> | ||
9 | |||
10 | struct i386_node { | ||
11 | struct node node; | ||
12 | }; | ||
13 | extern struct i386_node node_devices[MAX_NUMNODES]; | ||
14 | |||
15 | static inline int arch_register_node(int num){ | ||
16 | int p_node; | ||
17 | struct node *parent = NULL; | ||
18 | |||
19 | if (!node_online(num)) | ||
20 | return 0; | ||
21 | p_node = parent_node(num); | ||
22 | |||
23 | if (p_node != num) | ||
24 | parent = &node_devices[p_node].node; | ||
25 | |||
26 | return register_node(&node_devices[num].node, num, parent); | ||
27 | } | ||
28 | |||
29 | #endif /* _ASM_I386_NODE_H_ */ | ||
diff --git a/include/linux/node.h b/include/linux/node.h index 254dc3de650b..1e5347527fa8 100644 --- a/include/linux/node.h +++ b/include/linux/node.h | |||
@@ -26,8 +26,12 @@ struct node { | |||
26 | struct sys_device sysdev; | 26 | struct sys_device sysdev; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | extern struct node node_devices[]; | ||
30 | |||
29 | extern int register_node(struct node *, int, struct node *); | 31 | extern int register_node(struct node *, int, struct node *); |
30 | extern void unregister_node(struct node *node); | 32 | extern void unregister_node(struct node *node); |
33 | extern int register_one_node(int nid); | ||
34 | extern void unregister_one_node(int nid); | ||
31 | 35 | ||
32 | #define to_node(sys_device) container_of(sys_device, struct node, sysdev) | 36 | #define to_node(sys_device) container_of(sys_device, struct node, sysdev) |
33 | 37 | ||
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index f13783e81eb6..ea4038838b0a 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -256,9 +256,19 @@ int add_memory(int nid, u64 start, u64 size) | |||
256 | if (ret < 0) | 256 | if (ret < 0) |
257 | goto error; | 257 | goto error; |
258 | 258 | ||
259 | /* we online node here. we have no error path from here. */ | 259 | /* we online node here. we can't roll back from here. */ |
260 | node_set_online(nid); | 260 | node_set_online(nid); |
261 | 261 | ||
262 | if (new_pgdat) { | ||
263 | ret = register_one_node(nid); | ||
264 | /* | ||
265 | * If sysfs file of new node can't create, cpu on the node | ||
266 | * can't be hot-added. There is no rollback way now. | ||
267 | * So, check by BUG_ON() to catch it reluctantly.. | ||
268 | */ | ||
269 | BUG_ON(ret); | ||
270 | } | ||
271 | |||
262 | /* register this memory as resource */ | 272 | /* register this memory as resource */ |
263 | register_memory_resource(start, size); | 273 | register_memory_resource(start, size); |
264 | 274 | ||