Re: [PATCH v8 16/19] locking/rwsem: Guard against making count negative

2019-06-11 Thread Peter Zijlstra
On Tue, Jun 11, 2019 at 03:11:31PM +0200, Peter Zijlstra wrote: > On Mon, May 20, 2019 at 04:59:15PM -0400, Waiman Long wrote: > > > +static inline long rwsem_read_trylock(struct rw_semaphore *sem, long *cnt) > > +{ > > + long adjustment = -RWSEM_READER_BIAS; > > + > > + *cnt = atomic_long_fet

Re: [PATCH v8 16/19] locking/rwsem: Guard against making count negative

2019-06-11 Thread Peter Zijlstra
On Mon, May 20, 2019 at 04:59:15PM -0400, Waiman Long wrote: > static struct rw_semaphore __sched * > +rwsem_down_read_slowpath(struct rw_semaphore *sem, int state, long > adjustment) > { > + long count; > bool wake = false; > struct rwsem_waiter waiter; > DEFINE_WAKE_Q(wak

Re: [PATCH v8 16/19] locking/rwsem: Guard against making count negative

2019-06-11 Thread Peter Zijlstra
On Mon, May 20, 2019 at 04:59:15PM -0400, Waiman Long wrote: > +static inline long rwsem_read_trylock(struct rw_semaphore *sem, long *cnt) > +{ > + long adjustment = -RWSEM_READER_BIAS; > + > + *cnt = atomic_long_fetch_add_acquire(RWSEM_READER_BIAS, &sem->count); I'm thinking we'd actuall