summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYasunori Goto <y-goto@jp.fujitsu.com>2006-06-27 02:53:38 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-27 17:32:36 -0700
commit0fc44159bfcb5b0afa178f9c3f50db23aebc76ff (patch)
treed87e47c0f5e6b2eff1d9113d3495d185924734d9
parent1f04bbd2d396a701c5af2e5b92bad896c2550c16 (diff)
downloadlwn-0fc44159bfcb5b0afa178f9c3f50db23aebc76ff.tar.gz
lwn-0fc44159bfcb5b0afa178f9c3f50db23aebc76ff.zip
[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.c9
-rw-r--r--arch/ia64/kernel/topology.c15
-rw-r--r--arch/powerpc/kernel/sysfs.c15
-rw-r--r--drivers/base/node.c25
-rw-r--r--include/asm-i386/cpu.h2
-rw-r--r--include/asm-i386/node.h29
-rw-r--r--include/linux/node.h4
-rw-r--r--mm/memory_hotplug.c12
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){
#ifdef CONFIG_NUMA
int node = cpu_to_node(num);
if (node_online(node))
- parent = &node_devices[node].node;
+ parent = &node_devices[parent_node(node)];
#endif /* CONFIG_NUMA */
/*
@@ -61,7 +61,7 @@ void arch_unregister_cpu(int num) {
#ifdef CONFIG_NUMA
int node = cpu_to_node(num);
if (node_online(node))
- parent = &node_devices[node].node;
+ parent = &node_devices[parent_node(node)];
#endif /* CONFIG_NUMA */
return unregister_cpu(&cpu_devices[num].cpu, parent);
@@ -74,16 +74,13 @@ EXPORT_SYMBOL(arch_unregister_cpu);
#ifdef CONFIG_NUMA
#include <linux/mmzone.h>
-#include <asm/node.h>
-
-struct i386_node node_devices[MAX_NUMNODES];
static int __init topology_init(void)
{
int i;
for_each_online_node(i)
- arch_register_node(i);
+ register_one_node(i);
for_each_present_cpu(i)
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 @@
#include <asm/numa.h>
#include <asm/cpu.h>
-#ifdef CONFIG_NUMA
-static struct node *sysfs_nodes;
-#endif
static struct ia64_cpu *sysfs_cpus;
int arch_register_cpu(int num)
@@ -36,7 +33,7 @@ int arch_register_cpu(int num)
struct node *parent = NULL;
#ifdef CONFIG_NUMA
- parent = &sysfs_nodes[cpu_to_node(num)];
+ parent = &node_devices[cpu_to_node(num)];
#endif /* CONFIG_NUMA */
#if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU)
@@ -59,7 +56,7 @@ void arch_unregister_cpu(int num)
#ifdef CONFIG_NUMA
int node = cpu_to_node(num);
- parent = &sysfs_nodes[node];
+ parent = &node_devices[node];
#endif /* CONFIG_NUMA */
return unregister_cpu(&sysfs_cpus[num].cpu, parent);
@@ -74,17 +71,11 @@ static int __init topology_init(void)
int i, err = 0;
#ifdef CONFIG_NUMA
- sysfs_nodes = kzalloc(sizeof(struct node) * MAX_NUMNODES, GFP_KERNEL);
- if (!sysfs_nodes) {
- err = -ENOMEM;
- goto out;
- }
-
/*
* MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes?
*/
for_each_online_node(i) {
- if ((err = register_node(&sysfs_nodes[i], i, 0)))
+ if ((err = register_one_node(i)))
goto out;
}
#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 = {
/* NUMA stuff */
#ifdef CONFIG_NUMA
-static struct node node_devices[MAX_NUMNODES];
-
static void register_nodes(void)
{
int i;
- 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];
-
- register_node(&node_devices[i], i, parent);
- }
- }
+ for (i = 0; i < MAX_NUMNODES; i++)
+ register_one_node(i);
}
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)
sysdev_unregister(&node->sysdev);
}
+struct node node_devices[MAX_NUMNODES];
+
+int register_one_node(int nid)
+{
+ int error = 0;
+
+ if (node_online(nid)) {
+ int p_node = parent_node(nid);
+ struct node *parent = NULL;
+
+ if (p_node != nid)
+ parent = &node_devices[p_node];
+
+ error = register_node(&node_devices[nid], nid, parent);
+ }
+
+ return error;
+
+}
+
+void unregister_one_node(int nid)
+{
+ unregister_node(&node_devices[nid]);
+}
+
static int __init register_node_type(void)
{
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 @@
#include <linux/nodemask.h>
#include <linux/percpu.h>
-#include <asm/node.h>
-
struct i386_cpu {
struct cpu cpu;
};
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 @@
-#ifndef _ASM_I386_NODE_H_
-#define _ASM_I386_NODE_H_
-
-#include <linux/device.h>
-#include <linux/mmzone.h>
-#include <linux/node.h>
-#include <linux/topology.h>
-#include <linux/nodemask.h>
-
-struct i386_node {
- struct node node;
-};
-extern struct i386_node node_devices[MAX_NUMNODES];
-
-static inline int arch_register_node(int num){
- int p_node;
- struct node *parent = NULL;
-
- if (!node_online(num))
- return 0;
- p_node = parent_node(num);
-
- if (p_node != num)
- parent = &node_devices[p_node].node;
-
- return register_node(&node_devices[num].node, num, parent);
-}
-
-#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 {
struct sys_device sysdev;
};
+extern struct node node_devices[];
+
extern int register_node(struct node *, int, struct node *);
extern void unregister_node(struct node *node);
+extern int register_one_node(int nid);
+extern void unregister_one_node(int nid);
#define to_node(sys_device) container_of(sys_device, struct node, sysdev)
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)
if (ret < 0)
goto error;
- /* we online node here. we have no error path from here. */
+ /* we online node here. we can't roll back from here. */
node_set_online(nid);
+ if (new_pgdat) {
+ ret = register_one_node(nid);
+ /*
+ * If sysfs file of new node can't create, cpu on the node
+ * can't be hot-added. There is no rollback way now.
+ * So, check by BUG_ON() to catch it reluctantly..
+ */
+ BUG_ON(ret);
+ }
+
/* register this memory as resource */
register_memory_resource(start, size);