Skip to content

Commit 76b67ed

Browse files
hkamezawaLinus Torvalds
authored andcommitted
[PATCH] node hotplug: register cpu: remove node struct
With Goto-san's patch, we can add new pgdat/node at runtime. I'm now considering node-hot-add with cpu + memory on ACPI. I found acpi container, which describes node, could evaluate cpu before memory. This means cpu-hot-add occurs before memory hot add. In most part, cpu-hot-add doesn't depend on node hot add. But register_cpu(), which creates symbolic link from node to cpu, requires that node should be onlined before register_cpu(). When a node is onlined, its pgdat should be there. This patch-set holds off creating symbolic link from node to cpu until node is onlined. This removes node arguments from register_cpu(). Now, register_cpu() requires 'struct node' as its argument. But the array of struct node is now unified in driver/base/node.c now (By Goto's node hotplug patch). We can get struct node in generic way. So, this argument is not necessary now. This patch also guarantees add cpu under node only when node is onlined. It is necessary for node-hot-add vs. cpu-hot-add patch following this. Moreover, register_cpu calculates cpu->node_id by cpu_to_node() without regard to its 'struct node *root' argument. This patch removes it. Also modify callers of register_cpu()/unregister_cpu, whose args are changed by register-cpu-remove-node-struct patch. [[email protected]: fix it] Signed-off-by: KAMEZAWA Hiroyuki <[email protected]> Cc: Yasunori Goto <[email protected]> Cc: Ashok Raj <[email protected]> Cc: Dave Hansen <[email protected]> Signed-off-by: Brice Goglin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent dd0932d commit 76b67ed

File tree

18 files changed

+77
-69
lines changed

18 files changed

+77
-69
lines changed

arch/alpha/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ register_cpus(void)
481481
struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
482482
if (!p)
483483
return -ENOMEM;
484-
register_cpu(p, i, NULL);
484+
register_cpu(p, i);
485485
}
486486
return 0;
487487
}

arch/arm/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ static int __init topology_init(void)
808808
int cpu;
809809

810810
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);
812812

813813
return 0;
814814
}

arch/i386/kernel/topology.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,8 @@
3232

3333
static struct i386_cpu cpu_devices[NR_CPUS];
3434

35-
int arch_register_cpu(int num){
36-
struct node *parent = NULL;
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-
35+
int arch_register_cpu(int num)
36+
{
4437
/*
4538
* CPU0 cannot be offlined due to several
4639
* restrictions and assumptions in kernel. This basically
@@ -50,21 +43,13 @@ int arch_register_cpu(int num){
5043
if (!num)
5144
cpu_devices[num].cpu.no_control = 1;
5245

53-
return register_cpu(&cpu_devices[num].cpu, num, parent);
46+
return register_cpu(&cpu_devices[num].cpu, num);
5447
}
5548

5649
#ifdef CONFIG_HOTPLUG_CPU
5750

5851
void arch_unregister_cpu(int num) {
59-
struct node *parent = NULL;
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);
52+
return unregister_cpu(&cpu_devices[num].cpu);
6853
}
6954
EXPORT_SYMBOL(arch_register_cpu);
7055
EXPORT_SYMBOL(arch_unregister_cpu);

arch/ia64/kernel/topology.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ static struct ia64_cpu *sysfs_cpus;
3030

3131
int arch_register_cpu(int num)
3232
{
33-
struct node *parent = NULL;
34-
35-
#ifdef CONFIG_NUMA
36-
parent = &node_devices[cpu_to_node(num)];
37-
#endif /* CONFIG_NUMA */
38-
3933
#if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU)
4034
/*
4135
* If CPEI cannot be re-targetted, and this is
@@ -45,21 +39,14 @@ int arch_register_cpu(int num)
4539
sysfs_cpus[num].cpu.no_control = 1;
4640
#endif
4741

48-
return register_cpu(&sysfs_cpus[num].cpu, num, parent);
42+
return register_cpu(&sysfs_cpus[num].cpu, num);
4943
}
5044

5145
#ifdef CONFIG_HOTPLUG_CPU
5246

5347
void arch_unregister_cpu(int num)
5448
{
55-
struct node *parent = NULL;
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);
49+
return unregister_cpu(&sysfs_cpus[num].cpu);
6350
}
6451
EXPORT_SYMBOL(arch_register_cpu);
6552
EXPORT_SYMBOL(arch_unregister_cpu);

arch/m32r/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static int __init topology_init(void)
275275
int i;
276276

277277
for_each_present_cpu(i)
278-
register_cpu(&cpu_devices[i], i, NULL);
278+
register_cpu(&cpu_devices[i], i);
279279

280280
return 0;
281281
}

arch/mips/kernel/smp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ static int __init topology_init(void)
446446
int ret;
447447

448448
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);
450450
if (ret)
451451
printk(KERN_WARNING "topology_init: register_cpu %d "
452452
"failed (%d)\n", cpu, ret);

arch/parisc/kernel/topology.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ static struct cpu cpu_devices[NR_CPUS] __read_mostly;
2626

2727
static int __init topology_init(void)
2828
{
29-
struct node *parent = NULL;
3029
int num;
3130

3231
for_each_present_cpu(num) {
33-
register_cpu(&cpu_devices[num], num, parent);
32+
register_cpu(&cpu_devices[num], num);
3433
}
3534
return 0;
3635
}

arch/powerpc/kernel/setup_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ int __init ppc_init(void)
215215

216216
/* register CPU devices */
217217
for_each_possible_cpu(i)
218-
register_cpu(&cpu_devices[i], i, NULL);
218+
register_cpu(&cpu_devices[i], i);
219219

220220
/* call platform init */
221221
if (ppc_md.init != NULL) {

arch/powerpc/kernel/sysfs.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,23 +348,13 @@ static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL);
348348
static int __init topology_init(void)
349349
{
350350
int cpu;
351-
struct node *parent = NULL;
352351

353352
register_nodes();
354-
355353
register_cpu_notifier(&sysfs_cpu_nb);
356354

357355
for_each_possible_cpu(cpu) {
358356
struct cpu *c = &per_cpu(cpu_devices, cpu);
359357

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
368358
/*
369359
* For now, we just see if the system supports making
370360
* the RTAS calls for CPU hotplug. But, there may be a
@@ -376,7 +366,7 @@ static int __init topology_init(void)
376366
c->no_control = 1;
377367

378368
if (cpu_online(cpu) || (c->no_control == 0)) {
379-
register_cpu(c, cpu, parent);
369+
register_cpu(c, cpu);
380370

381371
sysdev_create_file(&c->sysdev, &attr_physical_id);
382372
}

arch/ppc/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ int __init ppc_init(void)
475475

476476
/* register CPU devices */
477477
for_each_possible_cpu(i)
478-
register_cpu(&cpu_devices[i], i, NULL);
478+
register_cpu(&cpu_devices[i], i);
479479

480480
/* call platform init */
481481
if (ppc_md.init != NULL) {

0 commit comments

Comments
 (0)