Skip to content

Commit 06c6796

Browse files
committed
cpu/hotplug: Fix off by one in cpuhp_bringup_mask()
cpuhp_bringup_mask() iterates over a cpumask and starts all present CPUs up to a caller provided upper limit. The limit variable is decremented and checked for 0 before invoking cpu_up(), which is obviously off by one and prevents the bringup of the last CPU when the limit is equal to the number of present CPUs. Move the decrement and check after the cpu_up() invocation. Fixes: 18415f3 ("cpu/hotplug: Allow "parallel" bringup up to CPUHP_BP_KICK_AP_STATE") Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/87wn10ufj9.ffs@tglx
1 parent 6a4be69 commit 06c6796

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

kernel/cpu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,9 +1770,6 @@ static void __init cpuhp_bringup_mask(const struct cpumask *mask, unsigned int n
17701770
for_each_cpu(cpu, mask) {
17711771
struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
17721772

1773-
if (!--ncpus)
1774-
break;
1775-
17761773
if (cpu_up(cpu, target) && can_rollback_cpu(st)) {
17771774
/*
17781775
* If this failed then cpu_up() might have only
@@ -1781,6 +1778,9 @@ static void __init cpuhp_bringup_mask(const struct cpumask *mask, unsigned int n
17811778
*/
17821779
WARN_ON(cpuhp_invoke_callback_range(false, cpu, st, CPUHP_OFFLINE));
17831780
}
1781+
1782+
if (!--ncpus)
1783+
break;
17841784
}
17851785
}
17861786

0 commit comments

Comments
 (0)