Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-18 Thread Waiman Long
On 04/18/2019 05:11 AM, Peter Zijlstra wrote: > On Wed, Apr 17, 2019 at 01:51:24PM -0400, Waiman Long wrote: >> On 04/17/2019 10:05 AM, Peter Zijlstra wrote: >>> On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: @@ -650,6 +686,33 @@ __rwsem_down_read_failed_common(struct rw_semaphor

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-18 Thread Waiman Long
On 04/18/2019 04:57 AM, Peter Zijlstra wrote: > On Wed, Apr 17, 2019 at 01:34:01PM -0400, Waiman Long wrote: >> On 04/17/2019 09:56 AM, Peter Zijlstra wrote: >>> On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: @@ -549,7 +582,7 @@ static noinline enum owner_state rwsem_spin_o

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-18 Thread Waiman Long
On 04/18/2019 05:00 AM, Peter Zijlstra wrote: > On Wed, Apr 17, 2019 at 01:45:10PM -0400, Waiman Long wrote: >> On 04/17/2019 09:58 AM, Peter Zijlstra wrote: >>> On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: +/* + * Try to acquire read lock before the reader is put on wait

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-18 Thread Peter Zijlstra
On Wed, Apr 17, 2019 at 01:51:24PM -0400, Waiman Long wrote: > On 04/17/2019 10:05 AM, Peter Zijlstra wrote: > > On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: > >> @@ -650,6 +686,33 @@ __rwsem_down_read_failed_common(struct rw_semaphore > >> *sem, int state) > >>struct rwsem_wai

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-18 Thread Peter Zijlstra
On Wed, Apr 17, 2019 at 01:45:10PM -0400, Waiman Long wrote: > On 04/17/2019 09:58 AM, Peter Zijlstra wrote: > > On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: > >> +/* > >> + * Try to acquire read lock before the reader is put on wait queue. > >> + * Lock acquisition isn't allowed if

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-18 Thread Peter Zijlstra
On Wed, Apr 17, 2019 at 01:34:01PM -0400, Waiman Long wrote: > On 04/17/2019 09:56 AM, Peter Zijlstra wrote: > > On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: > >> @@ -549,7 +582,7 @@ static noinline enum owner_state > >> rwsem_spin_on_owner(struct rw_semaphore *sem) > >>return

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-17 Thread Waiman Long
On 04/17/2019 10:05 AM, Peter Zijlstra wrote: > On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: >> @@ -650,6 +686,33 @@ __rwsem_down_read_failed_common(struct rw_semaphore >> *sem, int state) >> struct rwsem_waiter waiter; >> DEFINE_WAKE_Q(wake_q); >> >> +if (!rwsem_ca

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-17 Thread Waiman Long
On 04/17/2019 09:58 AM, Peter Zijlstra wrote: > On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: >> +/* >> + * Try to acquire read lock before the reader is put on wait queue. >> + * Lock acquisition isn't allowed if the rwsem is locked or a writer handoff >> + * is ongoing. >> + */ >>

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-17 Thread Waiman Long
On 04/17/2019 09:56 AM, Peter Zijlstra wrote: > On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: >> @@ -549,7 +582,7 @@ static noinline enum owner_state >> rwsem_spin_on_owner(struct rw_semaphore *sem) >> return !owner ? OWNER_NULL : OWNER_READER; >> } >> >> -static bool rwsem_

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-17 Thread Peter Zijlstra
On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: > @@ -650,6 +686,33 @@ __rwsem_down_read_failed_common(struct rw_semaphore > *sem, int state) > struct rwsem_waiter waiter; > DEFINE_WAKE_Q(wake_q); > > + if (!rwsem_can_spin_on_owner(sem)) > + goto queue; >

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-17 Thread Peter Zijlstra
On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: > +/* > + * Try to acquire read lock before the reader is put on wait queue. > + * Lock acquisition isn't allowed if the rwsem is locked or a writer handoff > + * is ongoing. > + */ > +static inline bool rwsem_try_read_lock_unqueued(struc

Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-17 Thread Peter Zijlstra
On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote: > @@ -549,7 +582,7 @@ static noinline enum owner_state > rwsem_spin_on_owner(struct rw_semaphore *sem) > return !owner ? OWNER_NULL : OWNER_READER; > } > > -static bool rwsem_optimistic_spin(struct rw_semaphore *sem) > +static b

[PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

2019-04-13 Thread Waiman Long
This patch enables readers to optimistically spin on a rwsem when it is owned by a writer instead of going to sleep directly. The rwsem_can_spin_on_owner() function is extracted out of rwsem_optimistic_spin() and is called directly by __rwsem_down_read_failed_common() and __rwsem_down_write_failed