Skip to content

Commit e0a0d05

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 fixes for the hotplug state machine code: - Move the misplaces smb() in the hotplug thread function to the proper place, otherwise a half update control struct could be observed - Prevent state corruption on error rollback, which causes the state to advance by one and as a consequence skip it in the bringup sequence" * 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: cpu/hotplug: Prevent state corruption on error rollback cpu/hotplug: Adjust misplaced smb() in cpuhp_thread_fun()
2 parents 3243a89 + 69fa6eb commit e0a0d05

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

kernel/cpu.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,15 @@ static void cpuhp_thread_fun(unsigned int cpu)
607607
bool bringup = st->bringup;
608608
enum cpuhp_state state;
609609

610+
if (WARN_ON_ONCE(!st->should_run))
611+
return;
612+
610613
/*
611614
* ACQUIRE for the cpuhp_should_run() load of ->should_run. Ensures
612615
* that if we see ->should_run we also see the rest of the state.
613616
*/
614617
smp_mb();
615618

616-
if (WARN_ON_ONCE(!st->should_run))
617-
return;
618-
619619
cpuhp_lock_acquire(bringup);
620620

621621
if (st->single) {
@@ -916,7 +916,8 @@ static int cpuhp_down_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st,
916916
ret = cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL);
917917
if (ret) {
918918
st->target = prev_state;
919-
undo_cpu_down(cpu, st);
919+
if (st->state < prev_state)
920+
undo_cpu_down(cpu, st);
920921
break;
921922
}
922923
}
@@ -969,7 +970,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
969970
* to do the further cleanups.
970971
*/
971972
ret = cpuhp_down_callbacks(cpu, st, target);
972-
if (ret && st->state > CPUHP_TEARDOWN_CPU && st->state < prev_state) {
973+
if (ret && st->state == CPUHP_TEARDOWN_CPU && st->state < prev_state) {
973974
cpuhp_reset_state(st, prev_state);
974975
__cpuhp_kick_ap(st);
975976
}

0 commit comments

Comments
 (0)