提交 7c5c92ed 编写于 作者: A Anton Blanchard 提交者: Michael Ellerman

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: NAnton Blanchard <anton@samba.org>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
上级 56548fc0
...@@ -700,7 +700,6 @@ void start_secondary(void *unused) ...@@ -700,7 +700,6 @@ void start_secondary(void *unused)
smp_store_cpu_info(cpu); smp_store_cpu_info(cpu);
set_dec(tb_ticks_per_jiffy); set_dec(tb_ticks_per_jiffy);
preempt_disable(); preempt_disable();
cpu_callin_map[cpu] = 1;
if (smp_ops->setup_cpu) if (smp_ops->setup_cpu)
smp_ops->setup_cpu(cpu); smp_ops->setup_cpu(cpu);
...@@ -739,6 +738,14 @@ void start_secondary(void *unused) ...@@ -739,6 +738,14 @@ void start_secondary(void *unused)
notify_cpu_starting(cpu); notify_cpu_starting(cpu);
set_cpu_online(cpu, true); set_cpu_online(cpu, true);
/*
* CPU must be marked active and online before we signal back to the
* master, because the scheduler needs to see the cpu_online and
* cpu_active bits set.
*/
smp_wmb();
cpu_callin_map[cpu] = 1;
local_irq_enable(); local_irq_enable();
cpu_startup_entry(CPUHP_ONLINE); cpu_startup_entry(CPUHP_ONLINE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册