Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper acquire/release barrier

2016-06-15 Thread Boqun Feng
On Wed, Jun 15, 2016 at 03:01:19PM -0400, Waiman Long wrote: > On 06/15/2016 04:04 AM, Boqun Feng wrote: > > Hi Waiman, > > > > On Tue, Jun 14, 2016 at 06:48:04PM -0400, Waiman Long wrote: > > > The osq_lock() and osq_unlock() function may not provide the necessary > > > acquire and release

Re: [RFC PATCH-tip v2 5/6] locking/rwsem: Change RWSEM_WAITING_BIAS for better disambiguation

2016-06-15 Thread Waiman Long
On 06/15/2016 01:45 PM, Peter Zijlstra wrote: On Tue, Jun 14, 2016 at 06:48:08PM -0400, Waiman Long wrote: +++ b/arch/alpha/include/asm/rwsem.h @@ -17,9 +17,9 @@ #define RWSEM_UNLOCKED_VALUE 0xL #define RWSEM_ACTIVE_BIAS 0x0001L #define

Re: [RFC PATCH-tip v2 5/6] locking/rwsem: Change RWSEM_WAITING_BIAS for better disambiguation

2016-06-15 Thread Waiman Long
On 06/15/2016 01:43 PM, Peter Zijlstra wrote: On Tue, Jun 14, 2016 at 06:48:08PM -0400, Waiman Long wrote: even the reduced maximum of about 16k (32-bit) or 1G (64-bit) should be more than enough for the foreseeable future. So what happens if I manage to create 16k+ threads on my 32bit kernel

Re: [RFC PATCH-tip v2 4/6] locking/rwsem: move down rwsem_down_read_failed function

2016-06-15 Thread Waiman Long
On 06/15/2016 01:40 PM, Peter Zijlstra wrote: On Tue, Jun 14, 2016 at 06:48:07PM -0400, Waiman Long wrote: Move the rwsem_down_read_failed() function down to below the optimistic spinning section before enabling optimistic spinning for the readers. newline There is no change in code.

Re: [RFC PATCH-tip v2 2/6] locking/rwsem: Stop active read lock ASAP

2016-06-15 Thread Waiman Long
On 06/15/2016 01:22 PM, Peter Zijlstra wrote: On Tue, Jun 14, 2016 at 06:48:05PM -0400, Waiman Long wrote: Currently, when down_read() fails, the active read locking isn't undone until the rwsem_down_read_failed() function grabs the wait_lock. If the wait_lock is contended, it may takes a while

Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper acquire/release barrier

2016-06-15 Thread Waiman Long
On 06/15/2016 01:12 PM, Peter Zijlstra wrote: On Wed, Jun 15, 2016 at 09:56:59AM -0700, Davidlohr Bueso wrote: On Tue, 14 Jun 2016, Waiman Long wrote: +++ b/kernel/locking/osq_lock.c @@ -115,7 +115,7 @@ bool osq_lock(struct optimistic_spin_queue *lock) * cmpxchg in an attempt to undo

Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper acquire/release barrier

2016-06-15 Thread Davidlohr Bueso
On Wed, 15 Jun 2016, Peter Zijlstra wrote: On Wed, Jun 15, 2016 at 11:27:24AM -0700, Davidlohr Bueso wrote: On Wed, 15 Jun 2016, Peter Zijlstra wrote: >In any case, its fairly simple to cure, just add >smp_acquire__after_ctrl_dep() at the end. If we bail because >need_resched() we don't need

Re: [RFC PATCH-tip v2 4/6] locking/rwsem: move down rwsem_down_read_failed function

2016-06-15 Thread Peter Zijlstra
On Tue, Jun 14, 2016 at 06:48:07PM -0400, Waiman Long wrote: > Move the rwsem_down_read_failed() function down to below the optimistic > spinning section before enabling optimistic spinning for the readers. newline > There is no change in code. Changelog fails to explain the why part. -- To

Re: [RFC PATCH-tip v2 3/6] locking/rwsem: Enable count-based spinning on reader

2016-06-15 Thread Peter Zijlstra
On Tue, Jun 14, 2016 at 06:48:06PM -0400, Waiman Long wrote: > static bool rwsem_optimistic_spin(struct rw_semaphore *sem) > { > - bool taken = false; > + bool taken = false, can_spin; I would place the variables without assignment first. > + int loopcnt; > >

Re: [RFC PATCH-tip v2 2/6] locking/rwsem: Stop active read lock ASAP

2016-06-15 Thread Peter Zijlstra
On Tue, Jun 14, 2016 at 06:48:05PM -0400, Waiman Long wrote: > Currently, when down_read() fails, the active read locking isn't undone > until the rwsem_down_read_failed() function grabs the wait_lock. If the > wait_lock is contended, it may takes a while to get the lock. During > that period,

Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper acquire/release barrier

2016-06-15 Thread Peter Zijlstra
On Wed, Jun 15, 2016 at 04:04:46PM +0800, Boqun Feng wrote: > On Tue, Jun 14, 2016 at 06:48:04PM -0400, Waiman Long wrote: > > @@ -198,7 +198,7 @@ void osq_unlock(struct optimistic_spin_queue *lock) > > * Second most likely case. > > */ > > node = this_cpu_ptr(_node); > > - next =