Commit 3609d819 authored by Shreyas B. Prabhu's avatar Shreyas B. Prabhu Committed by Michael Ellerman

powerpc: Make doorbell check preemption safe

Doorbell can be used to cause ipi on cpus which are sibling threads on
the same core. So icp_native_cause_ipi checks if the destination cpu
is a sibling thread of the current cpu and uses doorbell in such cases.

But while running with CONFIG_PREEMPT=y, since this section is
preemtible, we can run into issues if after we check if the destination
cpu is a sibling cpu, the task gets migrated from a sibling cpu to a
cpu on another core.

Fix this by using get_cpu()/ put_cpu()
Signed-off-by: default avatarShreyas B. Prabhu <shreyas@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Neuling <mikey@neuling.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 4bece972
...@@ -147,10 +147,14 @@ static void icp_native_cause_ipi(int cpu, unsigned long data) ...@@ -147,10 +147,14 @@ static void icp_native_cause_ipi(int cpu, unsigned long data)
{ {
kvmppc_set_host_ipi(cpu, 1); kvmppc_set_host_ipi(cpu, 1);
#ifdef CONFIG_PPC_DOORBELL #ifdef CONFIG_PPC_DOORBELL
if (cpu_has_feature(CPU_FTR_DBELL) && if (cpu_has_feature(CPU_FTR_DBELL)) {
(cpumask_test_cpu(cpu, cpu_sibling_mask(smp_processor_id())))) if (cpumask_test_cpu(cpu, cpu_sibling_mask(get_cpu()))) {
doorbell_cause_ipi(cpu, data); doorbell_cause_ipi(cpu, data);
else put_cpu();
return;
}
put_cpu();
}
#endif #endif
icp_native_set_qirr(cpu, IPI_PRIORITY); icp_native_set_qirr(cpu, IPI_PRIORITY);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment