mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Jason Low <jason.low2@hp.com>
Cc: Will Deacon <will.deacon@arm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"paulmck@linux.vnet.ibm.com" <paulmck@linux.vnet.ibm.com>,
	terry.rudd@hpe.com, "Long, Wai Man" <waiman.long@hpe.com>,
	"boqun.feng@gmail.com" <boqun.feng@gmail.com>,
	"dave@stgolabs.net" <dave@stgolabs.net>
Subject: Re: [RFC] arm64: Implement WFE based spin wait for MCS spinlocks
Date: Wed, 20 Apr 2016 12:30:59 +0200	[thread overview]
Message-ID: <20160420103059.GX3408@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1460618018.2871.25.camel@j-VirtualBox>

On Thu, Apr 14, 2016 at 12:13:38AM -0700, Jason Low wrote:
> Use WFE to avoid most spinning with MCS spinlocks. This is implemented
> with the new cmpwait() mechanism for comparing and waiting for the MCS
> locked value to change using LDXR + WFE.
> 
> Signed-off-by: Jason Low <jason.low2@hp.com>
> ---
>  arch/arm64/include/asm/mcs_spinlock.h | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>  create mode 100644 arch/arm64/include/asm/mcs_spinlock.h
> 
> diff --git a/arch/arm64/include/asm/mcs_spinlock.h b/arch/arm64/include/asm/mcs_spinlock.h
> new file mode 100644
> index 0000000..d295d9d
> --- /dev/null
> +++ b/arch/arm64/include/asm/mcs_spinlock.h
> @@ -0,0 +1,21 @@
> +#ifndef __ASM_MCS_SPINLOCK_H
> +#define __ASM_MCS_SPINLOCK_H
> +
> +#define arch_mcs_spin_lock_contended(l)					\
> +do {									\
> +	int locked_val;							\
> +	for (;;) {							\
> +		locked_val = READ_ONCE(*l);				\
> +		if (locked_val)						\
> +			break;						\
> +		cmpwait(l, locked_val);					\
> +	}								\
> +	smp_rmb();							\
> +} while (0)

If you make the generic version use smp_cond_load_acquire() this isn't
needed.

  reply	other threads:[~2016-04-20 10:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14  7:13 Jason Low
2016-04-20 10:30 ` Peter Zijlstra [this message]
2016-04-20 19:36   ` Jason Low

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=20160420103059.GX3408@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=boqun.feng@gmail.com \
    --cc=dave@stgolabs.net \
    --cc=jason.low2@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=terry.rudd@hpe.com \
    --cc=torvalds@linux-foundation.org \
    --cc=waiman.long@hpe.com \
    --cc=will.deacon@arm.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

Powered by JetHome