All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Alexander A Sverdlin <alexander.sverdlin@nokia.com>
Cc: Paul Burton <paul.burton@imgtec.com>,
	linux-mips@vger.kernel.org,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Will Deacon <will@kernel.org>, Boqun Feng <boqun.feng@gmail.com>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] MIPS: cmpxchg: Use cmpxchg_local() for {cmp_}xchg_small()
Date: Wed, 27 Jan 2021 23:37:19 +0100	[thread overview]
Message-ID: <YBHrH1Rw/nQqgDK4@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210127203627.47510-7-alexander.sverdlin@nokia.com>

On Wed, Jan 27, 2021 at 09:36:27PM +0100, Alexander A Sverdlin wrote:
> From: Alexander Sverdlin <alexander.sverdlin@nokia.com>
> 
> It makes no sense to fold smp_mb__before_llsc()/smp_llsc_mb() again and
> again, leave only one barrier pair in the outer function.
> 
> This removes one SYNCW from __xchg_small() and brings around 10%
> performance improvement in a tight spinlock loop with 6 threads on a 6 core
> Octeon.
> 
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
> ---
>  arch/mips/kernel/cmpxchg.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/mips/kernel/cmpxchg.c b/arch/mips/kernel/cmpxchg.c
> index 89107de..122e85f 100644
> --- a/arch/mips/kernel/cmpxchg.c
> +++ b/arch/mips/kernel/cmpxchg.c
> @@ -41,7 +41,7 @@ unsigned long __xchg_small(volatile void *ptr, unsigned long val, unsigned int s
>  	do {
>  		old32 = load32;
>  		new32 = (load32 & ~mask) | (val << shift);
> -		load32 = cmpxchg(ptr32, old32, new32);
> +		load32 = cmpxchg_local(ptr32, old32, new32);
>  	} while (load32 != old32);
>  
>  	return (load32 & mask) >> shift;
> @@ -97,7 +97,7 @@ unsigned long __cmpxchg_small(volatile void *ptr, unsigned long old,
>  		 */
>  		old32 = (load32 & ~mask) | (old << shift);
>  		new32 = (load32 & ~mask) | (new << shift);
> -		load32 = cmpxchg(ptr32, old32, new32);
> +		load32 = cmpxchg_local(ptr32, old32, new32);
>  		if (load32 == old32)
>  			return old;
>  	}

This is wrong, please use cmpxchg_relaxed() which you've just
introduced. cmpxchg_local() need not be cross-cpu atomic at all (it is
on mips by accident of implementation).

      reply	other threads:[~2021-01-27 23:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 20:36 [PATCH 0/6] MIPS: qspinlock: Try to reduce reduce the spinlock regression Alexander A Sverdlin
2021-01-27 20:36 ` [PATCH 1/6] MIPS: Octeon: Implement __smp_store_release() Alexander A Sverdlin
2021-01-27 22:32   ` Peter Zijlstra
2021-01-28  7:27     ` Alexander Sverdlin
2021-01-28 11:33       ` Peter Zijlstra
2021-01-28 11:52         ` Alexander Sverdlin
2021-01-28 14:57           ` Peter Zijlstra
2021-01-28 15:15             ` Peter Zijlstra
2021-01-28 12:09         ` Alexander Sverdlin
2021-01-28 15:04           ` Peter Zijlstra
2021-01-27 20:36 ` [PATCH 2/6] MIPS: Implement atomic_cmpxchg_relaxed() Alexander A Sverdlin
2021-01-27 20:36 ` [PATCH 3/6] MIPS: Octeon: qspinlock: Flush write buffer Alexander A Sverdlin
2021-01-27 22:34   ` Peter Zijlstra
2021-01-28  7:29     ` Alexander Sverdlin
2021-01-28 11:35       ` Peter Zijlstra
2021-01-28 12:13         ` Alexander Sverdlin
2021-01-28 15:26           ` Peter Zijlstra
2021-01-27 20:36 ` [PATCH 4/6] MIPS: Octeon: qspinlock: Exclude mmiowb() Alexander A Sverdlin
2021-01-27 22:35   ` Peter Zijlstra
2021-01-27 20:36 ` [PATCH 5/6] MIPS: Provide {atomic_}xchg_relaxed() Alexander A Sverdlin
2021-01-27 20:36 ` [PATCH 6/6] MIPS: cmpxchg: Use cmpxchg_local() for {cmp_}xchg_small() Alexander A Sverdlin
2021-01-27 22:37   ` Peter Zijlstra [this message]

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=YBHrH1Rw/nQqgDK4@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=alexander.sverdlin@nokia.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paul.burton@imgtec.com \
    --cc=tsbogend@alpha.franken.de \
    --cc=will@kernel.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.