Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752359AbbETBAM (ORCPT ); Tue, 19 May 2015 21:00:12 -0400 Received: from ozlabs.org ([103.22.144.67]:34455 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751612AbbETBAJ convert rfc822-to-8bit (ORCPT ); Tue, 19 May 2015 21:00:09 -0400 Message-ID: <1432083608.20823.19.camel@neuling.org> Subject: Re: [PATCH] powerpc: Make doorbell check preemption safe From: Michael Neuling To: "Shreyas B. Prabhu" Cc: mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Date: Wed, 20 May 2015 11:00:08 +1000 In-Reply-To: <1432062014-9115-1-git-send-email-shreyas@linux.vnet.ibm.com> References: <1432062014-9115-1-git-send-email-shreyas@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1931 Lines: 53 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 > Signed-off-by: Shreyas B. Prabhu > --- > 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); > } > > /* -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/