All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Neuling <mikey@neuling.org>
To: "Shreyas B. Prabhu" <shreyas@linux.vnet.ibm.com>
Cc: paulus@samba.org, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc: Make doorbell check preemption safe
Date: Wed, 20 May 2015 11:00:08 +1000	[thread overview]
Message-ID: <1432083608.20823.19.camel@neuling.org> (raw)
In-Reply-To: <1432062014-9115-1-git-send-email-shreyas@linux.vnet.ibm.com>

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.
>=20
> But while running with CONFIG_PREEMPT=3Dy, 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.
>=20
> 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(-)
>=20
> 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);
>  }
> =20
>  /*

WARNING: multiple messages have this Message-ID (diff)
From: Michael Neuling <mikey@neuling.org>
To: "Shreyas B. Prabhu" <shreyas@linux.vnet.ibm.com>
Cc: mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc: Make doorbell check preemption safe
Date: Wed, 20 May 2015 11:00:08 +1000	[thread overview]
Message-ID: <1432083608.20823.19.camel@neuling.org> (raw)
In-Reply-To: <1432062014-9115-1-git-send-email-shreyas@linux.vnet.ibm.com>

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);
>  }
>  
>  /*


  reply	other threads:[~2015-05-20  1:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 19:00 [PATCH] powerpc: Make doorbell check preemption safe Shreyas B. Prabhu
2015-05-19 19:00 ` Shreyas B. Prabhu
2015-05-20  1:00 ` Michael Neuling [this message]
2015-05-20  1:00   ` Michael Neuling
2015-06-04  6:45   ` Shreyas B Prabhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432083608.20823.19.camel@neuling.org \
    --to=mikey@neuling.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=shreyas@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.