Re: [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code

2014-07-30 Thread Jason Low
On Sun, 2014-07-27 at 22:18 -0700, Davidlohr Bueso wrote: > +static bool mutex_optimistic_spin(struct mutex *lock, > + struct ww_acquire_ctx *ww_ctx, const bool > use_ww_ctx) > +{ > + struct task_struct *task = current; > + > + if

Re: [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code

2014-07-30 Thread Jason Low
On Sun, 2014-07-27 at 22:18 -0700, Davidlohr Bueso wrote: +static bool mutex_optimistic_spin(struct mutex *lock, + struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx) +{ + struct task_struct *task = current; + + if (!mutex_can_spin_on_owner(lock))

Re: [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code

2014-07-28 Thread Davidlohr Bueso
On Mon, 2014-07-28 at 09:39 -0700, Jason Low wrote: > On Mon, 2014-07-28 at 11:08 +0200, Peter Zijlstra wrote: > > On Sun, Jul 27, 2014 at 10:18:41PM -0700, Davidlohr Bueso wrote: > > > +static bool mutex_optimistic_spin(struct mutex *lock, > > > + struct ww_acquire_ctx

Re: [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code

2014-07-28 Thread Jason Low
On Mon, 2014-07-28 at 11:08 +0200, Peter Zijlstra wrote: > On Sun, Jul 27, 2014 at 10:18:41PM -0700, Davidlohr Bueso wrote: > > +static bool mutex_optimistic_spin(struct mutex *lock, > > + struct ww_acquire_ctx *ww_ctx, const bool > > use_ww_ctx) > > +{ > > > > +

Re: [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code

2014-07-28 Thread Peter Zijlstra
On Sun, Jul 27, 2014 at 10:18:41PM -0700, Davidlohr Bueso wrote: > @@ -180,6 +266,126 @@ static inline int mutex_can_spin_on_owner(struct mutex > *lock) >*/ > return retval; > } > + > +/* > + * Atomically try to take the lock when it is available */ comment fail. > +static inline

Re: [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code

2014-07-28 Thread Peter Zijlstra
On Sun, Jul 27, 2014 at 10:18:41PM -0700, Davidlohr Bueso wrote: @@ -180,6 +266,126 @@ static inline int mutex_can_spin_on_owner(struct mutex *lock) */ return retval; } + +/* + * Atomically try to take the lock when it is available */ comment fail. +static inline bool

Re: [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code

2014-07-28 Thread Jason Low
On Mon, 2014-07-28 at 11:08 +0200, Peter Zijlstra wrote: On Sun, Jul 27, 2014 at 10:18:41PM -0700, Davidlohr Bueso wrote: +static bool mutex_optimistic_spin(struct mutex *lock, + struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx) +{ + /* +* If

Re: [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code

2014-07-28 Thread Davidlohr Bueso
On Mon, 2014-07-28 at 09:39 -0700, Jason Low wrote: On Mon, 2014-07-28 at 11:08 +0200, Peter Zijlstra wrote: On Sun, Jul 27, 2014 at 10:18:41PM -0700, Davidlohr Bueso wrote: +static bool mutex_optimistic_spin(struct mutex *lock, + struct ww_acquire_ctx *ww_ctx,

[PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code

2014-07-27 Thread Davidlohr Bueso
When we fail to acquire the mutex in the fastpath, we end up calling __mutex_lock_common(). A lot goes on in this function. Move out the optimistic spinning code into mutex_optimistic_spin() and simplify the former a bit. Furthermore, this is similar to what we have in rwsems. No logical changes.

[PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code

2014-07-27 Thread Davidlohr Bueso
When we fail to acquire the mutex in the fastpath, we end up calling __mutex_lock_common(). A lot goes on in this function. Move out the optimistic spinning code into mutex_optimistic_spin() and simplify the former a bit. Furthermore, this is similar to what we have in rwsems. No logical changes.