Re: [PATCH v4 12/16] locking/rwsem: Enable time-based spinning on reader-owned rwsem

2019-04-19 Thread Peter Zijlstra
On Thu, Apr 18, 2019 at 11:15:33AM -0400, Waiman Long wrote: > On 04/18/2019 09:06 AM, Peter Zijlstra wrote: > >> + /* > >> + * Check time threshold every 16 iterations to > >> + * avoid calling sched_clock() too frequently. > >> +

Re: [PATCH v4 12/16] locking/rwsem: Enable time-based spinning on reader-owned rwsem

2019-04-19 Thread Waiman Long
On 04/19/2019 10:33 AM, Waiman Long wrote: > On 04/19/2019 03:56 AM, Peter Zijlstra wrote: >> On Thu, Apr 18, 2019 at 11:15:33AM -0400, Waiman Long wrote: >>> On 04/18/2019 09:06 AM, Peter Zijlstra wrote: > + /* > + * Check time threshold every 16

Re: [PATCH v4 12/16] locking/rwsem: Enable time-based spinning on reader-owned rwsem

2019-04-19 Thread Waiman Long
On 04/19/2019 03:56 AM, Peter Zijlstra wrote: > On Thu, Apr 18, 2019 at 11:15:33AM -0400, Waiman Long wrote: >> On 04/18/2019 09:06 AM, Peter Zijlstra wrote: + /* + * Check time threshold every 16 iterations to + * avoid calling

Re: [PATCH v4 12/16] locking/rwsem: Enable time-based spinning on reader-owned rwsem

2019-04-18 Thread Waiman Long
On 04/18/2019 09:06 AM, Peter Zijlstra wrote: > So I really dislike time based spinning, and we've always rejected it > before. > > On Sat, Apr 13, 2019 at 01:22:55PM -0400, Waiman Long wrote: > >> +static inline u64 rwsem_rspin_threshold(struct rw_semaphore *sem) >> +{ >> +long count =

Re: [PATCH v4 12/16] locking/rwsem: Enable time-based spinning on reader-owned rwsem

2019-04-18 Thread Peter Zijlstra
So I really dislike time based spinning, and we've always rejected it before. On Sat, Apr 13, 2019 at 01:22:55PM -0400, Waiman Long wrote: > +static inline u64 rwsem_rspin_threshold(struct rw_semaphore *sem) > +{ > + long count = atomic_long_read(>count); > + int reader_cnt =

[PATCH v4 12/16] locking/rwsem: Enable time-based spinning on reader-owned rwsem

2019-04-13 Thread Waiman Long
When the rwsem is owned by reader, writers stop optimistic spinning simply because there is no easy way to figure out if all the readers are actively running or not. However, there are scenarios where the readers are unlikely to sleep and optimistic spinning can help performance. This patch