Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-25 Thread Tim Chen
On Tue, 2013-06-25 at 09:37 +0200, Peter Zijlstra wrote: > On Mon, Jun 24, 2013 at 01:17:45PM -0700, Tim Chen wrote: > > On second thought, I agree with you. I should change this to > > something like > > > > int retval = true; > > task_struct *sem_owner; > > > > /* Spin only if acti

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-25 Thread Peter Zijlstra
On Mon, Jun 24, 2013 at 01:17:45PM -0700, Tim Chen wrote: > On second thought, I agree with you. I should change this to > something like > > int retval = true; > task_struct *sem_owner; > > /* Spin only if active writer running */ > if (!sem->owner) > retur

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Peter Hurley
On 06/24/2013 05:58 PM, Tim Chen wrote: On Sat, 2013-06-22 at 03:57 -0400, Peter Hurley wrote: Will this spin for full scheduler value on a reader-owned lock? + /* wait_lock will be acquired if write_lock is obtained */ + if (rwsem_try_write_lock(sem->count, true, s

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Tim Chen
On Sat, 2013-06-22 at 03:57 -0400, Peter Hurley wrote: > Will this spin for full scheduler value on a reader-owned lock? > > > + /* wait_lock will be acquired if write_lock is obtained */ > > + if (rwsem_try_write_lock(sem->count, true, sem)) { > > + ret = 1;

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Tim Chen
On Mon, 2013-06-24 at 16:48 -0400, Peter Hurley wrote: > > Also, I haven't given a lot of thought to if preemption must be disabled > before calling rwsem_can_spin_on_owner(). If so, wouldn't you just drop > rwsem_can_spin_on_owner() (because the conditions tested in the loop are > equivalent)? >

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Peter Hurley
On 06/24/2013 04:17 PM, Tim Chen wrote: On Mon, 2013-06-24 at 14:49 -0400, Peter Hurley wrote: On 06/24/2013 01:11 PM, Tim Chen wrote: On Sun, 2013-06-23 at 13:03 -0700, Davidlohr Bueso wrote: On Sat, 2013-06-22 at 03:57 -0400, Peter Hurley wrote: On 06/21/2013 07:51 PM, Tim Chen wrote: +st

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Peter Hurley
On 06/24/2013 03:13 PM, Tim Chen wrote: On Mon, 2013-06-24 at 14:49 -0400, Peter Hurley wrote: On 06/24/2013 01:11 PM, Tim Chen wrote: On Sun, 2013-06-23 at 13:03 -0700, Davidlohr Bueso wrote: On Sat, 2013-06-22 at 03:57 -0400, Peter Hurley wrote: On 06/21/2013 07:51 PM, Tim Chen wrote: +st

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Tim Chen
On Mon, 2013-06-24 at 14:49 -0400, Peter Hurley wrote: > On 06/24/2013 01:11 PM, Tim Chen wrote: > > On Sun, 2013-06-23 at 13:03 -0700, Davidlohr Bueso wrote: > >> On Sat, 2013-06-22 at 03:57 -0400, Peter Hurley wrote: > >>> On 06/21/2013 07:51 PM, Tim Chen wrote: > > +static inline bool

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Tim Chen
On Mon, 2013-06-24 at 14:49 -0400, Peter Hurley wrote: > On 06/24/2013 01:11 PM, Tim Chen wrote: > > On Sun, 2013-06-23 at 13:03 -0700, Davidlohr Bueso wrote: > >> On Sat, 2013-06-22 at 03:57 -0400, Peter Hurley wrote: > >>> On 06/21/2013 07:51 PM, Tim Chen wrote: > > +static inline bool

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Peter Hurley
On 06/24/2013 01:11 PM, Tim Chen wrote: On Sun, 2013-06-23 at 13:03 -0700, Davidlohr Bueso wrote: On Sat, 2013-06-22 at 03:57 -0400, Peter Hurley wrote: On 06/21/2013 07:51 PM, Tim Chen wrote: +static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem) +{ + int retval = true;

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Tim Chen
On Sun, 2013-06-23 at 13:03 -0700, Davidlohr Bueso wrote: > On Sat, 2013-06-22 at 03:57 -0400, Peter Hurley wrote: > > On 06/21/2013 07:51 PM, Tim Chen wrote: > > > Introduce in this patch optimistic spinning for writer lock > > > acquisition in read write semaphore. The logic is > > > similar to

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Tim Chen
On Mon, 2013-06-24 at 10:46 +0200, Peter Zijlstra wrote: > On Fri, Jun 21, 2013 at 04:51:40PM -0700, Tim Chen wrote: > > Introduce in this patch optimistic spinning for writer lock > > acquisition in read write semaphore. The logic is > > similar to the optimistic spinning in mutex but without > >

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-24 Thread Peter Zijlstra
On Fri, Jun 21, 2013 at 04:51:40PM -0700, Tim Chen wrote: > Introduce in this patch optimistic spinning for writer lock > acquisition in read write semaphore. The logic is > similar to the optimistic spinning in mutex but without > the MCS lock queueing of the spinner. This provides a > better ch

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-23 Thread Davidlohr Bueso
On Sat, 2013-06-22 at 03:57 -0400, Peter Hurley wrote: > On 06/21/2013 07:51 PM, Tim Chen wrote: > > Introduce in this patch optimistic spinning for writer lock > > acquisition in read write semaphore. The logic is > > similar to the optimistic spinning in mutex but without > > the MCS lock queuei

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-22 Thread Peter Hurley
On 06/21/2013 07:51 PM, Tim Chen wrote: Introduce in this patch optimistic spinning for writer lock acquisition in read write semaphore. The logic is similar to the optimistic spinning in mutex but without the MCS lock queueing of the spinner. This provides a better chance for a writer to acqui

Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-21 Thread Davidlohr Bueso
On Fri, 2013-06-21 at 16:51 -0700, Tim Chen wrote: > Introduce in this patch optimistic spinning for writer lock > acquisition in read write semaphore. The logic is > similar to the optimistic spinning in mutex but without > the MCS lock queueing of the spinner. This provides a > better chance fo

[PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition

2013-06-21 Thread Tim Chen
Introduce in this patch optimistic spinning for writer lock acquisition in read write semaphore. The logic is similar to the optimistic spinning in mutex but without the MCS lock queueing of the spinner. This provides a better chance for a writer to acquire the lock before being we block it and p