Skip to content

Commit 7c5c92e

Browse files
antonblanchardmpe
authored andcommitted
powerpc: Secondary CPUs must set cpu_callin_map after setting active and online
I have a busy ppc64le KVM box where guests sometimes hit the infamous "kernel BUG at kernel/smpboot.c:134!" issue during boot: BUG_ON(td->cpu != smp_processor_id()); Basically a per CPU hotplug thread scheduled on the wrong CPU. The oops output confirms it: CPU: 0 Comm: watchdog/130 The problem is that we aren't ensuring the CPU active and online bits are set before allowing the master to continue on. The master unparks the secondary CPUs kthreads and the scheduler looks for a CPU to run on. It calls select_task_rq and realises the suggested CPU is not in the cpus_allowed mask. It then ends up in select_fallback_rq, and since the active and online bits aren't set we choose some other CPU to run on. Cc: stable@vger.kernel.org Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 56548fc commit 7c5c92e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎arch/powerpc/kernel/smp.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ void start_secondary(void *unused)
700700
smp_store_cpu_info(cpu);
701701
set_dec(tb_ticks_per_jiffy);
702702
preempt_disable();
703-
cpu_callin_map[cpu] = 1;
704703

705704
if (smp_ops->setup_cpu)
706705
smp_ops->setup_cpu(cpu);
@@ -739,6 +738,14 @@ void start_secondary(void *unused)
739738
notify_cpu_starting(cpu);
740739
set_cpu_online(cpu, true);
741740

741+
/*
742+
* CPU must be marked active and online before we signal back to the
743+
* master, because the scheduler needs to see the cpu_online and
744+
* cpu_active bits set.
745+
*/
746+
smp_wmb();
747+
cpu_callin_map[cpu] = 1;
748+
742749
local_irq_enable();
743750

744751
cpu_startup_entry(CPUHP_ONLINE);

0 commit comments

Comments
 (0)