All of lore.kernel.org
 help / color / mirror / Atom feed
From: paulmck@linux.vnet.ibm.com (Paul E. McKenney)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: Implement 1-,2- byte smp_load_acquire and smp_store_release
Date: Mon, 20 Apr 2015 09:08:41 -0700	[thread overview]
Message-ID: <20150420160841.GS5561@linux.vnet.ibm.com> (raw)
In-Reply-To: <1429544753-4120-1-git-send-email-a.ryabinin@samsung.com>

On Mon, Apr 20, 2015 at 06:45:53PM +0300, Andrey Ryabinin wrote:
> commit 47933ad41a86 ("arch: Introduce smp_load_acquire(), smp_store_release()")
> allowed only 4- and 8-byte smp_load_acquire, smp_store_release.
> So 1- and 2-byte cases weren't implemented in arm64.
> Later commit 536fa402221f ("compiler: Allow 1- and 2-byte smp_load_acquire()
> 				and smp_store_release()")
> allowed to use 1 and 2 byte smp_load_acquire and smp_store_release
> by adjusting the definition of __native_word().
> However, 1-,2- byte cases in arm64 version left unimplemented.
> 
> Commit 8053871d0f7f ("smp: Fix smp_call_function_single_async() locking")
> started to use smp_load_acquire() to load 2-bytes csd->flags.
> That crashes arm64 kernel during the boot.
> 
> Implement 1,2 byte cases in arm64's  smp_load_acquire()
> and smp_store_release() to fix this.
> 
> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>

I am introducing a similar smp_load_acquire() case in rcutorture to
replace use of explicit memory barriers, so thank you!  ;-)

Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> ---
>  arch/arm64/include/asm/barrier.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
> index a5abb00..71f19c4 100644
> --- a/arch/arm64/include/asm/barrier.h
> +++ b/arch/arm64/include/asm/barrier.h
> @@ -65,6 +65,14 @@ do {									\
>  do {									\
>  	compiletime_assert_atomic_type(*p);				\
>  	switch (sizeof(*p)) {						\
> +	case 1:								\
> +		asm volatile ("stlrb %w1, %0"				\
> +				: "=Q" (*p) : "r" (v) : "memory");	\
> +		break;							\
> +	case 2:								\
> +		asm volatile ("stlrh %w1, %0"				\
> +				: "=Q" (*p) : "r" (v) : "memory");	\
> +		break;							\
>  	case 4:								\
>  		asm volatile ("stlr %w1, %0"				\
>  				: "=Q" (*p) : "r" (v) : "memory");	\
> @@ -81,6 +89,14 @@ do {									\
>  	typeof(*p) ___p1;						\
>  	compiletime_assert_atomic_type(*p);				\
>  	switch (sizeof(*p)) {						\
> +	case 1:								\
> +		asm volatile ("ldarb %w0, %1"				\
> +			: "=r" (___p1) : "Q" (*p) : "memory");		\
> +		break;							\
> +	case 2:								\
> +		asm volatile ("ldarh %w0, %1"				\
> +			: "=r" (___p1) : "Q" (*p) : "memory");		\
> +		break;							\
>  	case 4:								\
>  		asm volatile ("ldar %w0, %1"				\
>  			: "=r" (___p1) : "Q" (*p) : "memory");		\
> -- 
> 2.3.5
> 

WARNING: multiple messages have this Message-ID (diff)
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Andrey Ryabinin <a.ryabinin@samsung.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64: Implement 1-,2- byte smp_load_acquire and smp_store_release
Date: Mon, 20 Apr 2015 09:08:41 -0700	[thread overview]
Message-ID: <20150420160841.GS5561@linux.vnet.ibm.com> (raw)
In-Reply-To: <1429544753-4120-1-git-send-email-a.ryabinin@samsung.com>

On Mon, Apr 20, 2015 at 06:45:53PM +0300, Andrey Ryabinin wrote:
> commit 47933ad41a86 ("arch: Introduce smp_load_acquire(), smp_store_release()")
> allowed only 4- and 8-byte smp_load_acquire, smp_store_release.
> So 1- and 2-byte cases weren't implemented in arm64.
> Later commit 536fa402221f ("compiler: Allow 1- and 2-byte smp_load_acquire()
> 				and smp_store_release()")
> allowed to use 1 and 2 byte smp_load_acquire and smp_store_release
> by adjusting the definition of __native_word().
> However, 1-,2- byte cases in arm64 version left unimplemented.
> 
> Commit 8053871d0f7f ("smp: Fix smp_call_function_single_async() locking")
> started to use smp_load_acquire() to load 2-bytes csd->flags.
> That crashes arm64 kernel during the boot.
> 
> Implement 1,2 byte cases in arm64's  smp_load_acquire()
> and smp_store_release() to fix this.
> 
> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>

I am introducing a similar smp_load_acquire() case in rcutorture to
replace use of explicit memory barriers, so thank you!  ;-)

Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> ---
>  arch/arm64/include/asm/barrier.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
> index a5abb00..71f19c4 100644
> --- a/arch/arm64/include/asm/barrier.h
> +++ b/arch/arm64/include/asm/barrier.h
> @@ -65,6 +65,14 @@ do {									\
>  do {									\
>  	compiletime_assert_atomic_type(*p);				\
>  	switch (sizeof(*p)) {						\
> +	case 1:								\
> +		asm volatile ("stlrb %w1, %0"				\
> +				: "=Q" (*p) : "r" (v) : "memory");	\
> +		break;							\
> +	case 2:								\
> +		asm volatile ("stlrh %w1, %0"				\
> +				: "=Q" (*p) : "r" (v) : "memory");	\
> +		break;							\
>  	case 4:								\
>  		asm volatile ("stlr %w1, %0"				\
>  				: "=Q" (*p) : "r" (v) : "memory");	\
> @@ -81,6 +89,14 @@ do {									\
>  	typeof(*p) ___p1;						\
>  	compiletime_assert_atomic_type(*p);				\
>  	switch (sizeof(*p)) {						\
> +	case 1:								\
> +		asm volatile ("ldarb %w0, %1"				\
> +			: "=r" (___p1) : "Q" (*p) : "memory");		\
> +		break;							\
> +	case 2:								\
> +		asm volatile ("ldarh %w0, %1"				\
> +			: "=r" (___p1) : "Q" (*p) : "memory");		\
> +		break;							\
>  	case 4:								\
>  		asm volatile ("ldar %w0, %1"				\
>  			: "=r" (___p1) : "Q" (*p) : "memory");		\
> -- 
> 2.3.5
> 


  parent reply	other threads:[~2015-04-20 16:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-20 15:45 [PATCH] arm64: Implement 1-,2- byte smp_load_acquire and smp_store_release Andrey Ryabinin
2015-04-20 15:45 ` Andrey Ryabinin
2015-04-20 15:48 ` Will Deacon
2015-04-20 15:48   ` Will Deacon
2015-04-20 16:09   ` Paul E. McKenney
2015-04-20 16:09     ` Paul E. McKenney
2015-04-20 16:08 ` [PATCH] arm64: Implement 1-, 2- " Linus Torvalds
2015-04-20 16:08   ` [PATCH] arm64: Implement 1-,2- " Linus Torvalds
2015-04-20 16:13   ` Will Deacon
2015-04-20 16:13     ` Will Deacon
2015-04-20 16:08 ` Paul E. McKenney [this message]
2015-04-20 16:08   ` Paul E. McKenney

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=20150420160841.GS5561@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.