Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-18 Thread Peter Zijlstra
On Thu, Jul 18, 2019 at 12:45:47PM +0100, Will Deacon wrote: > On Thu, Jul 18, 2019 at 12:58:12PM +0200, Peter Zijlstra wrote: > > On Thu, Jul 18, 2019 at 10:26:41AM +0100, Will Deacon wrote: > > > > > /* > > > * We need to ensure ACQUIRE semantics when reading sem->count so that > > > * we pair

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-18 Thread Paul E. McKenney
On Thu, Jul 18, 2019 at 06:50:52AM -0400, Jan Stancek wrote: > > - Original Message - > > Hi Jan, Waiman, [+Jade and Paul for the litmus test at the end] > > > > On Wed, Jul 17, 2019 at 09:22:00PM +0200, Jan Stancek wrote: > > > On Wed, Jul 17, 2019 at 10:19:04AM -0400, Waiman Long wrote:

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-18 Thread Will Deacon
On Thu, Jul 18, 2019 at 12:58:12PM +0200, Peter Zijlstra wrote: > On Thu, Jul 18, 2019 at 10:26:41AM +0100, Will Deacon wrote: > > > /* > > * We need to ensure ACQUIRE semantics when reading sem->count so that > > * we pair with the RELEASE store performed by an unlocking/downgrading > > * writ

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-18 Thread Jan Stancek
- Original Message - > > It's simpler like so: > > On Thu, Jul 18, 2019 at 01:04:46PM +0200, Peter Zijlstra wrote: > > X = 0; > > > > rwsem_down_read() > > for (;;) { > > set_current_state(TASK_UNINTERRUPTIBLE); > > > >

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-18 Thread Peter Zijlstra
It's simpler like so: On Thu, Jul 18, 2019 at 01:04:46PM +0200, Peter Zijlstra wrote: > X = 0; > > rwsem_down_read() > for (;;) { > set_current_state(TASK_UNINTERRUPTIBLE); > > X = 1; >

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-18 Thread Peter Zijlstra
On Thu, Jul 18, 2019 at 06:50:52AM -0400, Jan Stancek wrote: > > In writing this, I also noticed that we don't have any explicit ordering > > at the end of the reader slowpath when we wait on the queue but get woken > > immediately: > > > > if (!waiter.task) > > break; > > > > Am

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-18 Thread Peter Zijlstra
On Thu, Jul 18, 2019 at 10:26:41AM +0100, Will Deacon wrote: > /* > * We need to ensure ACQUIRE semantics when reading sem->count so that > * we pair with the RELEASE store performed by an unlocking/downgrading > * writer. > * > * P0 (writer)P1 (reader) > * > * down_

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-18 Thread Jan Stancek
- Original Message - > Hi Jan, Waiman, [+Jade and Paul for the litmus test at the end] > > On Wed, Jul 17, 2019 at 09:22:00PM +0200, Jan Stancek wrote: > > On Wed, Jul 17, 2019 at 10:19:04AM -0400, Waiman Long wrote: > > > > If you add a comment to the code outlining the issue (preferabl

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-18 Thread Will Deacon
Hi Jan, Waiman, [+Jade and Paul for the litmus test at the end] On Wed, Jul 17, 2019 at 09:22:00PM +0200, Jan Stancek wrote: > On Wed, Jul 17, 2019 at 10:19:04AM -0400, Waiman Long wrote: > > > If you add a comment to the code outlining the issue (preferably as a > > > litmus > > > test involving

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-17 Thread Waiman Long
On 7/17/19 3:22 PM, Jan Stancek wrote: > On Wed, Jul 17, 2019 at 10:19:04AM -0400, Waiman Long wrote: >>> If you add a comment to the code outlining the issue (preferably as >>> a litmus >>> test involving sem->count and some shared data which happens to be >>> vmacache_seqnum in your test)), then:

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-17 Thread Jan Stancek
On Wed, Jul 17, 2019 at 10:19:04AM -0400, Waiman Long wrote: If you add a comment to the code outlining the issue (preferably as a litmus test involving sem->count and some shared data which happens to be vmacache_seqnum in your test)), then: Reviewed-by: Will Deacon Thanks, Will Agreed. A

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-17 Thread Waiman Long
On 7/17/19 8:02 AM, Jan Stancek wrote: > LTP mtest06 has been observed to rarely hit "still mapped when deleted" > and following BUG_ON on arm64: > page:7e02fa37e480 refcount:3 mapcount:1 mapping:80be3d678ab0 > index:0x0 > xfs_address_space_operations [xfs] > flags: 0xbfffe00037(

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-17 Thread Waiman Long
On 7/17/19 9:13 AM, Will Deacon wrote: > On Wed, Jul 17, 2019 at 02:02:20PM +0200, Jan Stancek wrote: >> LTP mtest06 has been observed to rarely hit "still mapped when deleted" >> and following BUG_ON on arm64: >> page:7e02fa37e480 refcount:3 mapcount:1 mapping:80be3d678ab0 >> index:0x0

Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-17 Thread Will Deacon
On Wed, Jul 17, 2019 at 02:02:20PM +0200, Jan Stancek wrote: > LTP mtest06 has been observed to rarely hit "still mapped when deleted" > and following BUG_ON on arm64: > page:7e02fa37e480 refcount:3 mapcount:1 mapping:80be3d678ab0 > index:0x0 > xfs_address_space_operations [xfs] > fl

[PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

2019-07-17 Thread Jan Stancek
LTP mtest06 has been observed to rarely hit "still mapped when deleted" and following BUG_ON on arm64: page:7e02fa37e480 refcount:3 mapcount:1 mapping:80be3d678ab0 index:0x0 xfs_address_space_operations [xfs] flags: 0xbfffe00037(locked|referenced|uptodate|lru|active) page dumped