Skip to content

Commit c29d854

Browse files
committed
Merge branch 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull CPU hotplug fixes from Thomas Gleixner: "Two SMT/hotplug related fixes: - Prevent crash when HOTPLUG_CPU is disabled and the CPU bringup aborts. This is triggered with the 'nosmt' command line option, but can happen by any abort condition. As the real unplug code is not compiled in, prevent the fail by keeping the CPU in zombie state. - Enforce HOTPLUG_CPU for SMP on x86 to avoid the above situation completely. With 'nosmt' being a popular option it's required to unplug the half brought up sibling CPUs (due to the MCE wreckage) completely" * 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/smp: Enforce CONFIG_HOTPLUG_CPU when SMP=y cpu/hotplug: Prevent crash when CPU bringup fails on CONFIG_HOTPLUG_CPU=n
2 parents 573efdc + bebd024 commit c29d854

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,14 +2217,8 @@ config RANDOMIZE_MEMORY_PHYSICAL_PADDING
22172217
If unsure, leave at the default value.
22182218

22192219
config HOTPLUG_CPU
2220-
bool "Support for hot-pluggable CPUs"
2220+
def_bool y
22212221
depends on SMP
2222-
---help---
2223-
Say Y here to allow turning CPUs off and on. CPUs can be
2224-
controlled through /sys/devices/system/cpu.
2225-
( Note: power management support will enable this option
2226-
automatically on SMP systems. )
2227-
Say N if you want to disable CPU hotplug.
22282222

22292223
config BOOTPARAM_HOTPLUG_CPU0
22302224
bool "Set default setting of cpu0_hotpluggable"

kernel/cpu.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,20 @@ static void undo_cpu_up(unsigned int cpu, struct cpuhp_cpu_state *st)
564564
cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL);
565565
}
566566

567+
static inline bool can_rollback_cpu(struct cpuhp_cpu_state *st)
568+
{
569+
if (IS_ENABLED(CONFIG_HOTPLUG_CPU))
570+
return true;
571+
/*
572+
* When CPU hotplug is disabled, then taking the CPU down is not
573+
* possible because takedown_cpu() and the architecture and
574+
* subsystem specific mechanisms are not available. So the CPU
575+
* which would be completely unplugged again needs to stay around
576+
* in the current state.
577+
*/
578+
return st->state <= CPUHP_BRINGUP_CPU;
579+
}
580+
567581
static int cpuhp_up_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st,
568582
enum cpuhp_state target)
569583
{
@@ -574,8 +588,10 @@ static int cpuhp_up_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st,
574588
st->state++;
575589
ret = cpuhp_invoke_callback(cpu, st->state, true, NULL, NULL);
576590
if (ret) {
577-
st->target = prev_state;
578-
undo_cpu_up(cpu, st);
591+
if (can_rollback_cpu(st)) {
592+
st->target = prev_state;
593+
undo_cpu_up(cpu, st);
594+
}
579595
break;
580596
}
581597
}

0 commit comments

Comments
 (0)