Skip to content

Commit af7aa04

Browse files
Qais YousefKAGA-KOKO
authored andcommitted
x86/smp: Replace cpu_up/down() with add/remove_cpu()
The core device API performs extra housekeeping bits that are missing from directly calling cpu_up/down(). See commit a6717c0 ("powerpc/rtas: use device model APIs and serialization during LPM") for an example description of what might go wrong. This also prepares to make cpu_up/down() a private interface of the CPU subsystem. Signed-off-by: Qais Yousef <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent e646ac5 commit af7aa04

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

arch/x86/kernel/topology.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,39 +59,29 @@ __setup("cpu0_hotplug", enable_cpu0_hotplug);
5959
*/
6060
int _debug_hotplug_cpu(int cpu, int action)
6161
{
62-
struct device *dev = get_cpu_device(cpu);
6362
int ret;
6463

6564
if (!cpu_is_hotpluggable(cpu))
6665
return -EINVAL;
6766

68-
lock_device_hotplug();
69-
7067
switch (action) {
7168
case 0:
72-
ret = cpu_down(cpu);
73-
if (!ret) {
69+
ret = remove_cpu(cpu);
70+
if (!ret)
7471
pr_info("DEBUG_HOTPLUG_CPU0: CPU %u is now offline\n", cpu);
75-
dev->offline = true;
76-
kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
77-
} else
72+
else
7873
pr_debug("Can't offline CPU%d.\n", cpu);
7974
break;
8075
case 1:
81-
ret = cpu_up(cpu);
82-
if (!ret) {
83-
dev->offline = false;
84-
kobject_uevent(&dev->kobj, KOBJ_ONLINE);
85-
} else {
76+
ret = add_cpu(cpu);
77+
if (ret)
8678
pr_debug("Can't online CPU%d.\n", cpu);
87-
}
79+
8880
break;
8981
default:
9082
ret = -EINVAL;
9183
}
9284

93-
unlock_device_hotplug();
94-
9585
return ret;
9686
}
9787

arch/x86/mm/mmio-mod.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static void enter_uniprocessor(void)
386386
put_online_cpus();
387387

388388
for_each_cpu(cpu, downed_cpus) {
389-
err = cpu_down(cpu);
389+
err = remove_cpu(cpu);
390390
if (!err)
391391
pr_info("CPU%d is down.\n", cpu);
392392
else
@@ -406,7 +406,7 @@ static void leave_uniprocessor(void)
406406
return;
407407
pr_notice("Re-enabling CPUs...\n");
408408
for_each_cpu(cpu, downed_cpus) {
409-
err = cpu_up(cpu);
409+
err = add_cpu(cpu);
410410
if (!err)
411411
pr_info("enabled CPU%d.\n", cpu);
412412
else

arch/x86/xen/smp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void __init xen_smp_cpus_done(unsigned int max_cpus)
132132
if (xen_vcpu_nr(cpu) < MAX_VIRT_CPUS)
133133
continue;
134134

135-
rc = cpu_down(cpu);
135+
rc = remove_cpu(cpu);
136136

137137
if (rc == 0) {
138138
/*

0 commit comments

Comments
 (0)