Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-11 Thread Long, Wai Man
On 6/11/2014 5:48 PM, Jason Low wrote: On Wed, 2014-06-11 at 17:00 -0400, Long, Wai Man wrote: On 6/9/2014 1:38 PM, Jason Low wrote: On Wed, 2014-06-04 at 13:58 -0700, Davidlohr Bueso wrote: On Wed, 2014-06-04 at 13:57 -0700, Davidlohr Bueso wrote: In addition, how about the following helper

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-11 Thread Jason Low
On Wed, 2014-06-11 at 17:00 -0400, Long, Wai Man wrote: > On 6/9/2014 1:38 PM, Jason Low wrote: > > On Wed, 2014-06-04 at 13:58 -0700, Davidlohr Bueso wrote: > >> On Wed, 2014-06-04 at 13:57 -0700, Davidlohr Bueso wrote: > >>> In addition, how about the following helpers instead: > >>> - mutex_is_u

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-11 Thread Long, Wai Man
On 6/9/2014 1:38 PM, Jason Low wrote: On Wed, 2014-06-04 at 13:58 -0700, Davidlohr Bueso wrote: On Wed, 2014-06-04 at 13:57 -0700, Davidlohr Bueso wrote: In addition, how about the following helpers instead: - mutex_is_unlocked() : count > 0 - mutex_has_waiters() : count < 0, or list_empty(->w

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-09 Thread Jason Low
On Wed, 2014-06-04 at 13:58 -0700, Davidlohr Bueso wrote: > On Wed, 2014-06-04 at 13:57 -0700, Davidlohr Bueso wrote: > > In addition, how about the following helpers instead: > > - mutex_is_unlocked() : count > 0 > > - mutex_has_waiters() : count < 0, or list_empty(->wait_list) >

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-05 Thread Jason Low
On Wed, 2014-06-04 at 23:24 -0400, Waiman Long wrote: > On 06/04/2014 05:26 PM, Jason Low wrote: > > On Wed, 2014-06-04 at 21:43 +0200, Peter Zijlstra wrote: > >> Please make them inline functions, also can we rename the SHOW_NO_WAITER > >> thing, because its not at all clear to me wtf it does; sho

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-04 Thread Waiman Long
On 06/04/2014 05:26 PM, Jason Low wrote: On Wed, 2014-06-04 at 21:43 +0200, Peter Zijlstra wrote: On Wed, Jun 04, 2014 at 12:08:29PM -0700, Jason Low wrote: Upon entering the slowpath in __mutex_lock_common(), we try once more to acquire the mutex. We only try to acquire it if MUTEX_SHOW_NO_WAI

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-04 Thread Jason Low
On Wed, 2014-06-04 at 23:54 +0200, Thomas Gleixner wrote: > On Wed, 4 Jun 2014, Jason Low wrote: > > On Wed, 2014-06-04 at 21:43 +0200, Peter Zijlstra wrote: > > > > /* > > > > * A negative mutex count indicates that waiters are sleeping waiting > > > > for the > > > > - * mutex. > > > > + * mu

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-04 Thread Thomas Gleixner
On Wed, 4 Jun 2014, Jason Low wrote: > On Wed, 2014-06-04 at 21:43 +0200, Peter Zijlstra wrote: > > > /* > > > * A negative mutex count indicates that waiters are sleeping waiting > > > for the > > > - * mutex. > > > + * mutex, and a count of one indicates the mutex is unlocked. > > > */ > >

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-04 Thread Jason Low
On Wed, 2014-06-04 at 13:57 -0700, Davidlohr Bueso wrote: > On Wed, 2014-06-04 at 21:43 +0200, Peter Zijlstra wrote: > > On Wed, Jun 04, 2014 at 12:08:29PM -0700, Jason Low wrote: > > > Upon entering the slowpath in __mutex_lock_common(), we try once more > > > to acquire the mutex. We only try to

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-04 Thread Jason Low
On Wed, 2014-06-04 at 21:43 +0200, Peter Zijlstra wrote: > On Wed, Jun 04, 2014 at 12:08:29PM -0700, Jason Low wrote: > > Upon entering the slowpath in __mutex_lock_common(), we try once more > > to acquire the mutex. We only try to acquire it if MUTEX_SHOW_NO_WAITER > > (lock->count >= 0) is true

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-04 Thread Davidlohr Bueso
On Wed, 2014-06-04 at 13:57 -0700, Davidlohr Bueso wrote: > On Wed, 2014-06-04 at 21:43 +0200, Peter Zijlstra wrote: > > On Wed, Jun 04, 2014 at 12:08:29PM -0700, Jason Low wrote: > > > Upon entering the slowpath in __mutex_lock_common(), we try once more > > > to acquire the mutex. We only try to

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-04 Thread Davidlohr Bueso
On Wed, 2014-06-04 at 21:43 +0200, Peter Zijlstra wrote: > On Wed, Jun 04, 2014 at 12:08:29PM -0700, Jason Low wrote: > > Upon entering the slowpath in __mutex_lock_common(), we try once more > > to acquire the mutex. We only try to acquire it if MUTEX_SHOW_NO_WAITER > > (lock->count >= 0) is true

Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-04 Thread Peter Zijlstra
On Wed, Jun 04, 2014 at 12:08:29PM -0700, Jason Low wrote: > Upon entering the slowpath in __mutex_lock_common(), we try once more > to acquire the mutex. We only try to acquire it if MUTEX_SHOW_NO_WAITER > (lock->count >= 0) is true in order to avoid using the atomic xchg() > operation whenever it

[RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it is unlocked

2014-06-04 Thread Jason Low
Upon entering the slowpath in __mutex_lock_common(), we try once more to acquire the mutex. We only try to acquire it if MUTEX_SHOW_NO_WAITER (lock->count >= 0) is true in order to avoid using the atomic xchg() operation whenever it is not necessary. However, we really only need to try to acquire i