Re: [PATCH 01/11] qspinlock: A simple generic 4-byte queue spinlock

2014-06-27 Thread Konrad Rzeszutek Wilk
On Mon, Jun 23, 2014 at 06:26:22PM +0200, Peter Zijlstra wrote: > On Tue, Jun 17, 2014 at 04:05:31PM -0400, Konrad Rzeszutek Wilk wrote: > > > + * The basic principle of a queue-based spinlock can best be understood > > > + * by studying a classic queue-based spinlock implementation called the > >

Re: [PATCH 01/11] qspinlock: A simple generic 4-byte queue spinlock

2014-06-27 Thread Konrad Rzeszutek Wilk
On Mon, Jun 23, 2014 at 06:12:00PM +0200, Peter Zijlstra wrote: > On Tue, Jun 17, 2014 at 04:03:29PM -0400, Konrad Rzeszutek Wilk wrote: > > > > + new = tail | (val & _Q_LOCKED_MASK); > > > > + > > > > + old = atomic_cmpxchg(&lock->val, val, new); > > > > +

Re: [PATCH 01/11] qspinlock: A simple generic 4-byte queue spinlock

2014-06-27 Thread Konrad Rzeszutek Wilk
On Mon, Jun 23, 2014 at 05:56:50PM +0200, Peter Zijlstra wrote: > On Mon, Jun 16, 2014 at 04:49:18PM -0400, Konrad Rzeszutek Wilk wrote: > > > Index: linux-2.6/kernel/locking/mcs_spinlock.h > > > === > > > --- linux-2.6.orig/kernel/loc

Re: [PATCH 01/11] qspinlock: A simple generic 4-byte queue spinlock

2014-06-23 Thread Peter Zijlstra
On Tue, Jun 17, 2014 at 04:05:31PM -0400, Konrad Rzeszutek Wilk wrote: > > + * The basic principle of a queue-based spinlock can best be understood > > + * by studying a classic queue-based spinlock implementation called the > > + * MCS lock. The paper below provides a good description for this kin

Re: [PATCH 01/11] qspinlock: A simple generic 4-byte queue spinlock

2014-06-23 Thread Peter Zijlstra
On Tue, Jun 17, 2014 at 04:03:29PM -0400, Konrad Rzeszutek Wilk wrote: > > > + new = tail | (val & _Q_LOCKED_MASK); > > > + > > > + old = atomic_cmpxchg(&lock->val, val, new); > > > + if (old == val) > > > + break; > > > + > > > + val = old; >

Re: [PATCH 01/11] qspinlock: A simple generic 4-byte queue spinlock

2014-06-23 Thread Peter Zijlstra
On Mon, Jun 16, 2014 at 04:49:18PM -0400, Konrad Rzeszutek Wilk wrote: > > Index: linux-2.6/kernel/locking/mcs_spinlock.h > > === > > --- linux-2.6.orig/kernel/locking/mcs_spinlock.h > > +++ linux-2.6/kernel/locking/mcs_spinlock.h > >

Re: [PATCH 01/11] qspinlock: A simple generic 4-byte queue spinlock

2014-06-17 Thread Konrad Rzeszutek Wilk
> + * The basic principle of a queue-based spinlock can best be understood > + * by studying a classic queue-based spinlock implementation called the > + * MCS lock. The paper below provides a good description for this kind > + * of lock. > + * > + * http://www.cise.ufl.edu/tr/DOC/REP-1992-71.pdf >

Re: [PATCH 01/11] qspinlock: A simple generic 4-byte queue spinlock

2014-06-17 Thread Konrad Rzeszutek Wilk
> > + new = tail | (val & _Q_LOCKED_MASK); > > + > > + old = atomic_cmpxchg(&lock->val, val, new); > > + if (old == val) > > + break; > > + > > + val = old; > > + } > > + > > + /* > > +* we won the trylock; forget about queue

Re: [PATCH 01/11] qspinlock: A simple generic 4-byte queue spinlock

2014-06-16 Thread Konrad Rzeszutek Wilk
On Sun, Jun 15, 2014 at 02:46:58PM +0200, Peter Zijlstra wrote: > From: Waiman Long > > This patch introduces a new generic queue spinlock implementation that > can serve as an alternative to the default ticket spinlock. Compared > with the ticket spinlock, this queue spinlock should be almost as

[PATCH 01/11] qspinlock: A simple generic 4-byte queue spinlock

2014-06-15 Thread Peter Zijlstra
From: Waiman Long This patch introduces a new generic queue spinlock implementation that can serve as an alternative to the default ticket spinlock. Compared with the ticket spinlock, this queue spinlock should be almost as fair as the ticket spinlock. It has about the same speed in single-thread