Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-02-04 Thread Tim Chen
On Wed, 2015-02-04 at 13:06 +0100, Peter Zijlstra wrote: > On Tue, Feb 03, 2015 at 11:43:36AM -0800, Tim Chen wrote: > > That's true. We cannot have the lock grabbed by a new write > > contender as any new writer contender of the lock will be > > queued by the OSQ logic. Only the > > thread doin

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-02-04 Thread Peter Zijlstra
On Tue, Feb 03, 2015 at 11:43:36AM -0800, Tim Chen wrote: > That's true. We cannot have the lock grabbed by a new write > contender as any new writer contender of the lock will be > queued by the OSQ logic. Only the > thread doing the optimistic spin is attempting write lock. > In other word,

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-02-03 Thread Tim Chen
On Tue, 2015-02-03 at 13:04 -0800, Jason Low wrote: > On Tue, 2015-02-03 at 11:43 -0800, Tim Chen wrote: > > On Tue, 2015-02-03 at 09:54 -0800, Jason Low wrote: > > > On Tue, 2015-02-03 at 09:16 -0800, Tim Chen wrote: > > > > > > > > > > > > > > + if (READ_ONCE(sem->owner)) > > > > > > > +

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-02-03 Thread Jason Low
On Tue, 2015-02-03 at 11:43 -0800, Tim Chen wrote: > On Tue, 2015-02-03 at 09:54 -0800, Jason Low wrote: > > On Tue, 2015-02-03 at 09:16 -0800, Tim Chen wrote: > > > > > > > > > > > > + if (READ_ONCE(sem->owner)) > > > > > > + return true; /* new owner, continue spinning */ > > > > >

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-02-03 Thread Tim Chen
On Tue, 2015-02-03 at 09:54 -0800, Jason Low wrote: > On Tue, 2015-02-03 at 09:16 -0800, Tim Chen wrote: > > > > > > > > > > + if (READ_ONCE(sem->owner)) > > > > > + return true; /* new owner, continue spinning */ > > > > > + > > > > > > > > Do you have some comparison data of wh

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-02-03 Thread Jason Low
On Tue, 2015-02-03 at 09:16 -0800, Tim Chen wrote: > > > > > > > > + if (READ_ONCE(sem->owner)) > > > > + return true; /* new owner, continue spinning */ > > > > + > > > > > > Do you have some comparison data of whether it is more advantageous > > > to continue spinning when

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-02-03 Thread Tim Chen
> > > > > > + if (READ_ONCE(sem->owner)) > > > + return true; /* new owner, continue spinning */ > > > + > > > > Do you have some comparison data of whether it is more advantageous > > to continue spinning when owner changes? After the above change, > > rwsem will behave more like a s

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-01-31 Thread Davidlohr Bueso
On Sat, 2015-01-31 at 13:14 -0800, Davidlohr Bueso wrote: > - owner changes from nil: implies that a writer now holds the mutex. Why Err... that should say rwsem. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-01-31 Thread Davidlohr Bueso
On Sat, 2015-01-31 at 10:29 +0100, Peter Zijlstra wrote: > On Fri, Jan 30, 2015 at 01:14:26AM -0800, Davidlohr Bueso wrote: > > +++ b/kernel/locking/rwsem-xadd.c > > @@ -337,21 +337,30 @@ static inline bool owner_running(struct rw_semaphore > > *sem, > > static noinline > > bool rwsem_spin_on_ow

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-01-31 Thread Peter Zijlstra
On Fri, Jan 30, 2015 at 01:14:26AM -0800, Davidlohr Bueso wrote: > +++ b/kernel/locking/rwsem-xadd.c > @@ -337,21 +337,30 @@ static inline bool owner_running(struct rw_semaphore > *sem, > static noinline > bool rwsem_spin_on_owner(struct rw_semaphore *sem, struct task_struct *owner) > { > +

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-01-30 Thread Davidlohr Bueso
On Fri, 2015-01-30 at 17:51 -0800, Tim Chen wrote: > On Fri, 2015-01-30 at 01:14 -0800, Davidlohr Bueso wrote: > > When readers hold the semaphore, the ->owner is nil. As such, > > and unlike mutexes, '!owner' does not necessarily imply that > > the lock is free. This will cause writers to potentia

Re: [PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-01-30 Thread Tim Chen
On Fri, 2015-01-30 at 01:14 -0800, Davidlohr Bueso wrote: > When readers hold the semaphore, the ->owner is nil. As such, > and unlike mutexes, '!owner' does not necessarily imply that > the lock is free. This will cause writers to potentially spin > excessively as they've been mislead to thinking

[PATCH 4/5] locking/rwsem: Avoid deceiving lock spinners

2015-01-30 Thread Davidlohr Bueso
When readers hold the semaphore, the ->owner is nil. As such, and unlike mutexes, '!owner' does not necessarily imply that the lock is free. This will cause writers to potentially spin excessively as they've been mislead to thinking they have a chance of acquiring the lock, instead of blocking. Th