* [PATCH] powerpc: Make doorbell check preemption safe
@ 2015-05-19 19:00 Shreyas B. Prabhu
2015-05-20 1:00 ` Michael Neuling
0 siblings, 1 reply; 3+ messages in thread
From: Shreyas B. Prabhu @ 2015-05-19 19:00 UTC (permalink / raw)
To: mpe; +Cc: mikey, benh, paulus, linuxppc-dev, linux-kernel, Shreyas B. Prabhu
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: Shreyas B. Prabhu <shreyas@linux.vnet.ibm.com>
---
arch/powerpc/sysdev/xics/icp-native.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/sysdev/xics/icp-native.c b/arch/powerpc/sysdev/xics/icp-native.c
index 2fc4cf1..62fd478 100644
--- a/arch/powerpc/sysdev/xics/icp-native.c
+++ b/arch/powerpc/sysdev/xics/icp-native.c
@@ -147,12 +147,16 @@ static void icp_native_cause_ipi(int cpu, unsigned long data)
{
kvmppc_set_host_ipi(cpu, 1);
#ifdef CONFIG_PPC_DOORBELL
- if (cpu_has_feature(CPU_FTR_DBELL) &&
- (cpumask_test_cpu(cpu, cpu_sibling_mask(smp_processor_id()))))
- doorbell_cause_ipi(cpu, data);
- else
+ if (cpu_has_feature(CPU_FTR_DBELL)) {
+ if (cpumask_test_cpu(cpu, cpu_sibling_mask(get_cpu()))) {
+ doorbell_cause_ipi(cpu, data);
+ put_cpu();
+ return;
+ }
+ put_cpu();
+ }
#endif
- icp_native_set_qirr(cpu, IPI_PRIORITY);
+ icp_native_set_qirr(cpu, IPI_PRIORITY);
}
/*
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc: Make doorbell check preemption safe
2015-05-19 19:00 [PATCH] powerpc: Make doorbell check preemption safe Shreyas B. Prabhu
@ 2015-05-20 1:00 ` Michael Neuling
2015-06-04 6:45 ` Shreyas B Prabhu
0 siblings, 1 reply; 3+ messages in thread
From: Michael Neuling @ 2015-05-20 1:00 UTC (permalink / raw)
To: Shreyas B. Prabhu; +Cc: mpe, benh, paulus, linuxppc-dev, linux-kernel
On Wed, 2015-05-20 at 00:30 +0530, Shreyas B. Prabhu wrote:
> 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()
Thanks. Looks good and it's boots for me.
Signed-off-by: Michael Neuling <mikey@neuling.org>
> Signed-off-by: Shreyas B. Prabhu <shreyas@linux.vnet.ibm.com>
> ---
> arch/powerpc/sysdev/xics/icp-native.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/xics/icp-native.c b/arch/powerpc/sysdev/xics/icp-native.c
> index 2fc4cf1..62fd478 100644
> --- a/arch/powerpc/sysdev/xics/icp-native.c
> +++ b/arch/powerpc/sysdev/xics/icp-native.c
> @@ -147,12 +147,16 @@ static void icp_native_cause_ipi(int cpu, unsigned long data)
> {
> kvmppc_set_host_ipi(cpu, 1);
> #ifdef CONFIG_PPC_DOORBELL
> - if (cpu_has_feature(CPU_FTR_DBELL) &&
> - (cpumask_test_cpu(cpu, cpu_sibling_mask(smp_processor_id()))))
> - doorbell_cause_ipi(cpu, data);
> - else
> + if (cpu_has_feature(CPU_FTR_DBELL)) {
> + if (cpumask_test_cpu(cpu, cpu_sibling_mask(get_cpu()))) {
> + doorbell_cause_ipi(cpu, data);
> + put_cpu();
> + return;
> + }
> + put_cpu();
> + }
> #endif
> - icp_native_set_qirr(cpu, IPI_PRIORITY);
> + icp_native_set_qirr(cpu, IPI_PRIORITY);
> }
>
> /*
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc: Make doorbell check preemption safe
2015-05-20 1:00 ` Michael Neuling
@ 2015-06-04 6:45 ` Shreyas B Prabhu
0 siblings, 0 replies; 3+ messages in thread
From: Shreyas B Prabhu @ 2015-06-04 6:45 UTC (permalink / raw)
To: Michael Neuling; +Cc: mpe, benh, paulus, linuxppc-dev, linux-kernel
On Wednesday 20 May 2015 06:30 AM, Michael Neuling wrote:
> On Wed, 2015-05-20 at 00:30 +0530, Shreyas B. Prabhu wrote:
>> 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()
>
> Thanks. Looks good and it's boots for me.
>
> Signed-off-by: Michael Neuling <mikey@neuling.org>
>
mikey, Thanks!
mpe, if this looks ok, can you please pick it up?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-04 6:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19 19:00 [PATCH] powerpc: Make doorbell check preemption safe Shreyas B. Prabhu
2015-05-20 1:00 ` Michael Neuling
2015-06-04 6:45 ` Shreyas B Prabhu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).