Linux-csky Archive mirror
 help / color / mirror / Atom feed
From: Guo Ren <guoren@kernel.org>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
	elver@google.com,  akpm@linux-foundation.org, tglx@linutronix.de,
	peterz@infradead.org,  dianders@chromium.org, pmladek@suse.com,
	arnd@arndb.de,  torvalds@linux-foundation.org,
	kernel-team@meta.com,  Yujie Liu <yujie.liu@intel.com>,
	linux-csky@vger.kernel.org
Subject: Re: [PATCH v2 cmpxchg 11/13] csky: Emulate one-byte cmpxchg
Date: Sat, 11 May 2024 14:42:17 +0800	[thread overview]
Message-ID: <CAJF2gTQb1qW_GUiQBWiogBLX2geNGMFhOJK55ZKWJYyFqu-SSQ@mail.gmail.com> (raw)
In-Reply-To: <20240501230130.1111603-11-paulmck@kernel.org>

On Thu, May 2, 2024 at 7:01 AM Paul E. McKenney <paulmck@kernel.org> wrote:
>
> Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on csky.
>
> [ paulmck: Apply kernel test robot feedback. ]
> [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ]
>
> Co-developed-by: Yujie Liu <yujie.liu@intel.com>
> Signed-off-by: Yujie Liu <yujie.liu@intel.com>
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> Tested-by: Yujie Liu <yujie.liu@intel.com>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: <linux-csky@vger.kernel.org>
> ---
>  arch/csky/Kconfig               |  1 +
>  arch/csky/include/asm/cmpxchg.h | 10 ++++++++++
>  2 files changed, 11 insertions(+)
>
> diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
> index d3ac36751ad1f..5479707eb5d10 100644
> --- a/arch/csky/Kconfig
> +++ b/arch/csky/Kconfig
> @@ -37,6 +37,7 @@ config CSKY
>         select ARCH_INLINE_SPIN_UNLOCK_BH if !PREEMPTION
>         select ARCH_INLINE_SPIN_UNLOCK_IRQ if !PREEMPTION
>         select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE if !PREEMPTION
> +       select ARCH_NEED_CMPXCHG_1_EMU
>         select ARCH_WANT_FRAME_POINTERS if !CPU_CK610 && $(cc-option,-mbacktrace)
>         select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
>         select COMMON_CLK
> diff --git a/arch/csky/include/asm/cmpxchg.h b/arch/csky/include/asm/cmpxchg.h
> index 916043b845f14..db6dda47184e4 100644
> --- a/arch/csky/include/asm/cmpxchg.h
> +++ b/arch/csky/include/asm/cmpxchg.h
> @@ -6,6 +6,7 @@
>  #ifdef CONFIG_SMP
>  #include <linux/bug.h>
>  #include <asm/barrier.h>
> +#include <linux/cmpxchg-emu.h>
>
>  #define __xchg_relaxed(new, ptr, size)                         \
>  ({                                                             \
> @@ -61,6 +62,9 @@
>         __typeof__(old) __old = (old);                          \
>         __typeof__(*(ptr)) __ret;                               \
>         switch (size) {                                         \
> +       case 1:                                                 \
> +               __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \
> +               break;                                          \
>         case 4:                                                 \
>                 asm volatile (                                  \
>                 "1:     ldex.w          %0, (%3) \n"            \
> @@ -91,6 +95,9 @@
>         __typeof__(old) __old = (old);                          \
>         __typeof__(*(ptr)) __ret;                               \
>         switch (size) {                                         \
> +       case 1:                                                 \
> +               __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \
> +               break;                                          \
>         case 4:                                                 \
>                 asm volatile (                                  \
>                 "1:     ldex.w          %0, (%3) \n"            \
> @@ -122,6 +129,9 @@
>         __typeof__(old) __old = (old);                          \
>         __typeof__(*(ptr)) __ret;                               \
>         switch (size) {                                         \
> +       case 1:                                                 \
> +               __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \
> +               break;                                          \
>         case 4:                                                 \
>                 asm volatile (                                  \
>                 RELEASE_FENCE                                   \
> --
> 2.40.1
>
Reviewed-by: Guo Ren <guoren@kernel.org>

I will optimize it after ARCH_NEED_CMPXCHG_1_EMU is merged.

-- 
Best Regards
 Guo Ren

  reply	other threads:[~2024-05-11  6:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <b67e79d4-06cb-4a45-a906-b9e0fbae22c5@paulmck-laptop>
2024-05-01 23:01 ` [PATCH v2 cmpxchg 11/13] csky: Emulate one-byte cmpxchg Paul E. McKenney
2024-05-11  6:42   ` Guo Ren [this message]
2024-05-11 14:49     ` 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=CAJF2gTQb1qW_GUiQBWiogBLX2geNGMFhOJK55ZKWJYyFqu-SSQ@mail.gmail.com \
    --to=guoren@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=dianders@chromium.org \
    --cc=elver@google.com \
    --cc=kernel-team@meta.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-csky@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=yujie.liu@intel.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).