All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Waiman Long <Waiman.Long@hp.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-arch@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Richard Weinberger <richard@nod.at>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Matt Fleming <matt.fleming@intel.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Akinobu Mita <akinobu.mita@gmail.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Michel Lespinasse <walken@google.com>,
	Andi Kleen <andi@firstfloor.org>, Rik van Riel <riel@redhat.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	George Spelvin <linux@horizon.com>, Harvey Harrison <harvey.ha>
Subject: Re: [PATCH RFC 1/2] qspinlock: Introducing a 4-byte queue spinlock implementation
Date: Thu, 01 Aug 2013 15:41:33 +0530	[thread overview]
Message-ID: <51FA3455.1000607@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130801094029.GK3008@twins.programming.kicks-ass.net>

On 08/01/2013 03:10 PM, Peter Zijlstra wrote:
> On Wed, Jul 31, 2013 at 10:37:10PM -0400, Waiman Long wrote:
>
> OK, so over-all I rather like the thing. It might be good to include a
> link to some MCS lock description, sadly wikipedia doesn't have an
> article on the concept :/
>
> http://www.cise.ufl.edu/tr/DOC/REP-1992-71.pdf
>
> That seems like nice (short-ish) write-up of the general algorithm.
>
>> +typedef struct qspinlock {
>> +	union {
>> +		struct {
>> +			u8	locked;		/* Bit lock */
>> +			u8	reserved;
>> +			u16	qcode;		/* Wait queue code */
>> +		};
>> +		u32		qlock;
>> +	};
>> +} arch_spinlock_t;
>
>> +static __always_inline void queue_spin_unlock(struct qspinlock *lock)
>> +{
>> +	barrier();
>> +	ACCESS_ONCE(lock->locked) = 0;
>
> Its always good to add comments with barriers..
>
>> +	smp_wmb();
>> +}
>
>> +/*
>> + * The queue node structure
>> + */
>> +struct qnode {
>> +	struct qnode	*next;
>> +	u8		 wait;		/* Waiting flag	*/
>> +	u8		 used;		/* Used flag	*/
>> +#ifdef	CONFIG_DEBUG_SPINLOCK
>> +	u16		 cpu_nr;	/* CPU number	*/
>> +	void		*lock;		/* Lock address */
>> +#endif
>> +};
>> +
>> +/*
>> + * The 16-bit wait queue code is divided into the following 2 fields:
>> + * Bits 0-1 : queue node index
>> + * Bits 2-15: cpu number + 1
>> + *
>> + * The current implementation will allow a maximum of (1<<14)-1 = 16383 CPUs.
>
> I haven't yet read far enough to figure out why you need the -1 thing,
> but effectively you're restricted to 15k due to this.
>

It is exactly 16k-1 not 15k
That is because CPU_CODE of 1 to 16k represents cpu 0..16k-1

WARNING: multiple messages have this Message-ID (diff)
From: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Waiman Long <Waiman.Long@hp.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-arch@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Richard Weinberger <richard@nod.at>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Matt Fleming <matt.fleming@intel.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Akinobu Mita <akinobu.mita@gmail.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Michel Lespinasse <walken@google.com>,
	Andi Kleen <andi@firstfloor.org>, Rik van Riel <riel@redhat.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	George Spelvin <linux@horizon.com>,
	Harvey Harrison <harvey.harrison@gmail.com>,
	"Chandramouleeswaran, Aswin" <aswin@hp.com>,
	"Norton, Scott J" <scott.norton@hp.com>
Subject: Re: [PATCH RFC 1/2] qspinlock: Introducing a 4-byte queue spinlock implementation
Date: Thu, 01 Aug 2013 15:41:33 +0530	[thread overview]
Message-ID: <51FA3455.1000607@linux.vnet.ibm.com> (raw)
Message-ID: <20130801101133.c1DXoiBw8r3do_Zbd0S9-eya6AjKTRWA_NXZh42xbOE@z> (raw)
In-Reply-To: <20130801094029.GK3008@twins.programming.kicks-ass.net>

On 08/01/2013 03:10 PM, Peter Zijlstra wrote:
> On Wed, Jul 31, 2013 at 10:37:10PM -0400, Waiman Long wrote:
>
> OK, so over-all I rather like the thing. It might be good to include a
> link to some MCS lock description, sadly wikipedia doesn't have an
> article on the concept :/
>
> http://www.cise.ufl.edu/tr/DOC/REP-1992-71.pdf
>
> That seems like nice (short-ish) write-up of the general algorithm.
>
>> +typedef struct qspinlock {
>> +	union {
>> +		struct {
>> +			u8	locked;		/* Bit lock */
>> +			u8	reserved;
>> +			u16	qcode;		/* Wait queue code */
>> +		};
>> +		u32		qlock;
>> +	};
>> +} arch_spinlock_t;
>
>> +static __always_inline void queue_spin_unlock(struct qspinlock *lock)
>> +{
>> +	barrier();
>> +	ACCESS_ONCE(lock->locked) = 0;
>
> Its always good to add comments with barriers..
>
>> +	smp_wmb();
>> +}
>
>> +/*
>> + * The queue node structure
>> + */
>> +struct qnode {
>> +	struct qnode	*next;
>> +	u8		 wait;		/* Waiting flag	*/
>> +	u8		 used;		/* Used flag	*/
>> +#ifdef	CONFIG_DEBUG_SPINLOCK
>> +	u16		 cpu_nr;	/* CPU number	*/
>> +	void		*lock;		/* Lock address */
>> +#endif
>> +};
>> +
>> +/*
>> + * The 16-bit wait queue code is divided into the following 2 fields:
>> + * Bits 0-1 : queue node index
>> + * Bits 2-15: cpu number + 1
>> + *
>> + * The current implementation will allow a maximum of (1<<14)-1 = 16383 CPUs.
>
> I haven't yet read far enough to figure out why you need the -1 thing,
> but effectively you're restricted to 15k due to this.
>

It is exactly 16k-1 not 15k
That is because CPU_CODE of 1 to 16k represents cpu 0..16k-1




WARNING: multiple messages have this Message-ID (diff)
From: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Waiman Long <Waiman.Long@hp.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-arch@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Richard Weinberger <richard@nod.at>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Matt Fleming <matt.fleming@intel.com>,
	Herbert Xu <herbert@gondor.hengli.com.au>,
	Akinobu Mita <akinobu.mita@gmail.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Michel Lespinasse <walken@google.com>,
	Andi Kleen <andi@firstfloor.org>, Rik van Riel <riel@redhat.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	George Spelvin <linux@horizon.com>,
	Harvey Harrison <harvey.harrison@gmail.com>,
	"Chandramouleeswaran, Aswin" <aswin@hp.com>,
	"Norton, Scott J" <scott.norton@hp.com>
Subject: Re: [PATCH RFC 1/2] qspinlock: Introducing a 4-byte queue spinlock implementation
Date: Thu, 01 Aug 2013 15:41:33 +0530	[thread overview]
Message-ID: <51FA3455.1000607@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130801094029.GK3008@twins.programming.kicks-ass.net>

On 08/01/2013 03:10 PM, Peter Zijlstra wrote:
> On Wed, Jul 31, 2013 at 10:37:10PM -0400, Waiman Long wrote:
>
> OK, so over-all I rather like the thing. It might be good to include a
> link to some MCS lock description, sadly wikipedia doesn't have an
> article on the concept :/
>
> http://www.cise.ufl.edu/tr/DOC/REP-1992-71.pdf
>
> That seems like nice (short-ish) write-up of the general algorithm.
>
>> +typedef struct qspinlock {
>> +	union {
>> +		struct {
>> +			u8	locked;		/* Bit lock */
>> +			u8	reserved;
>> +			u16	qcode;		/* Wait queue code */
>> +		};
>> +		u32		qlock;
>> +	};
>> +} arch_spinlock_t;
>
>> +static __always_inline void queue_spin_unlock(struct qspinlock *lock)
>> +{
>> +	barrier();
>> +	ACCESS_ONCE(lock->locked) = 0;
>
> Its always good to add comments with barriers..
>
>> +	smp_wmb();
>> +}
>
>> +/*
>> + * The queue node structure
>> + */
>> +struct qnode {
>> +	struct qnode	*next;
>> +	u8		 wait;		/* Waiting flag	*/
>> +	u8		 used;		/* Used flag	*/
>> +#ifdef	CONFIG_DEBUG_SPINLOCK
>> +	u16		 cpu_nr;	/* CPU number	*/
>> +	void		*lock;		/* Lock address */
>> +#endif
>> +};
>> +
>> +/*
>> + * The 16-bit wait queue code is divided into the following 2 fields:
>> + * Bits 0-1 : queue node index
>> + * Bits 2-15: cpu number + 1
>> + *
>> + * The current implementation will allow a maximum of (1<<14)-1 = 16383 CPUs.
>
> I haven't yet read far enough to figure out why you need the -1 thing,
> but effectively you're restricted to 15k due to this.
>

It is exactly 16k-1 not 15k
That is because CPU_CODE of 1 to 16k represents cpu 0..16k-1




  parent reply	other threads:[~2013-08-01 10:05 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1375324631-32868-1-git-send-email-Waiman.Long@hp.com>
2013-08-01  2:37 ` [PATCH RFC 1/2] qspinlock: Introducing a 4-byte queue spinlock implementation Waiman Long
2013-08-01  2:37   ` Waiman Long
2013-08-01  2:37   ` Waiman Long
     [not found]   ` <20130801094029.GK3008@twins.programming.kicks-ass.net>
2013-08-01 10:11     ` Raghavendra K T [this message]
2013-08-01 10:11       ` Raghavendra K T
2013-08-01 10:11       ` Raghavendra K T
2013-08-01 10:12       ` Peter Zijlstra
2013-08-01 10:12         ` Peter Zijlstra
2013-08-01 10:12         ` Peter Zijlstra
2013-08-01 10:14       ` Peter Zijlstra
2013-08-01 10:14         ` Peter Zijlstra
2013-08-01 10:14         ` Peter Zijlstra
     [not found]     ` <51FAA1C3.2050507@hp.com>
2013-08-01 18:16       ` Raghavendra K T
2013-08-01 18:16         ` Raghavendra K T
2013-08-01 18:16         ` Raghavendra K T
2013-08-01 20:10         ` Peter Zijlstra
2013-08-01 20:10           ` Peter Zijlstra
2013-08-01 20:10           ` Peter Zijlstra
2013-08-01 20:36           ` Raghavendra K T
2013-08-01 20:36             ` Raghavendra K T
2013-08-01 20:36             ` Raghavendra K T
2013-08-01 20:23   ` Raghavendra K T
2013-08-01 20:23     ` Raghavendra K T
2013-08-01 20:23     ` Raghavendra K T
2013-08-01 20:47     ` Peter Zijlstra
2013-08-01 20:47       ` Peter Zijlstra
2013-08-01 20:47       ` Peter Zijlstra
2013-08-02  2:54       ` Raghavendra K T
2013-08-02  2:54         ` Raghavendra K T
2013-08-02  2:54         ` Raghavendra K T
2013-08-01 21:09     ` Waiman Long
2013-08-01 21:09       ` Waiman Long
2013-08-01 21:09       ` Waiman Long
2013-08-02  3:00       ` Raghavendra K T
2013-08-02  3:00         ` Raghavendra K T
2013-08-02  3:00         ` Raghavendra K T
2013-08-01  2:37 ` [PATCH RFC 2/2] qspinlock x86: Enable x86 to use queue spinlock Waiman Long
2013-08-01  2:37   ` Waiman Long
2013-08-01  2:37   ` Waiman Long

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=51FA3455.1000607@linux.vnet.ibm.com \
    --to=raghavendra.kt@linux.vnet.ibm.com \
    --cc=Waiman.Long@hp.com \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@horizon.com \
    --cc=matt.fleming@intel.com \
    --cc=mingo@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=richard@nod.at \
    --cc=riel@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=rusty@rustcorp.com.au \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=walken@google.com \
    --cc=x86@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.