Re: [PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-11 Thread Dmitry Safonov
On Tue, 2018-09-11 at 15:50 +0200, Peter Zijlstra wrote: > On Tue, Sep 11, 2018 at 02:33:22PM +0100, Dmitry Safonov wrote: > > > > You might want to think about ditching that ldsem thing > > > > entirely, > > > > and use a regular rwsem ? > > > > > > Yeah, but AFAICS, regular rwsem will need to

Re: [PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-11 Thread Dmitry Safonov
On Tue, 2018-09-11 at 15:50 +0200, Peter Zijlstra wrote: > On Tue, Sep 11, 2018 at 02:33:22PM +0100, Dmitry Safonov wrote: > > > > You might want to think about ditching that ldsem thing > > > > entirely, > > > > and use a regular rwsem ? > > > > > > Yeah, but AFAICS, regular rwsem will need to

Re: [PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-11 Thread Peter Zijlstra
On Tue, Sep 11, 2018 at 02:33:22PM +0100, Dmitry Safonov wrote: > > > You might want to think about ditching that ldsem thing entirely, > > > and use a regular rwsem ? > > > > Yeah, but AFAICS, regular rwsem will need to have a timeout then (for > > write). So, I thought fixing this pile would be

Re: [PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-11 Thread Peter Zijlstra
On Tue, Sep 11, 2018 at 02:33:22PM +0100, Dmitry Safonov wrote: > > > You might want to think about ditching that ldsem thing entirely, > > > and use a regular rwsem ? > > > > Yeah, but AFAICS, regular rwsem will need to have a timeout then (for > > write). So, I thought fixing this pile would be

Re: [PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-11 Thread Dmitry Safonov
On Tue, 2018-09-11 at 14:01 +0100, Dmitry Safonov wrote: > On Tue, 2018-09-11 at 14:02 +0200, Peter Zijlstra wrote: > > On Tue, Sep 11, 2018 at 02:48:21AM +0100, Dmitry Safonov wrote: > > > It seems like when ldsem_down_read() fails with timeout, it > > > misses > > > update for sem->wait_readers.

Re: [PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-11 Thread Dmitry Safonov
On Tue, 2018-09-11 at 14:01 +0100, Dmitry Safonov wrote: > On Tue, 2018-09-11 at 14:02 +0200, Peter Zijlstra wrote: > > On Tue, Sep 11, 2018 at 02:48:21AM +0100, Dmitry Safonov wrote: > > > It seems like when ldsem_down_read() fails with timeout, it > > > misses > > > update for sem->wait_readers.

Re: [PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-11 Thread Dmitry Safonov
On Tue, 2018-09-11 at 14:02 +0200, Peter Zijlstra wrote: > On Tue, Sep 11, 2018 at 02:48:21AM +0100, Dmitry Safonov wrote: > > It seems like when ldsem_down_read() fails with timeout, it misses > > update for sem->wait_readers. By that reason, when writer finally > > releases write end of the

Re: [PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-11 Thread Dmitry Safonov
On Tue, 2018-09-11 at 14:02 +0200, Peter Zijlstra wrote: > On Tue, Sep 11, 2018 at 02:48:21AM +0100, Dmitry Safonov wrote: > > It seems like when ldsem_down_read() fails with timeout, it misses > > update for sem->wait_readers. By that reason, when writer finally > > releases write end of the

Re: [PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-11 Thread Peter Zijlstra
On Tue, Sep 11, 2018 at 02:48:21AM +0100, Dmitry Safonov wrote: > It seems like when ldsem_down_read() fails with timeout, it misses > update for sem->wait_readers. By that reason, when writer finally > releases write end of the semaphore __ldsem_wake_readers() does adjust > sem->count with wrong

Re: [PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-11 Thread Peter Zijlstra
On Tue, Sep 11, 2018 at 02:48:21AM +0100, Dmitry Safonov wrote: > It seems like when ldsem_down_read() fails with timeout, it misses > update for sem->wait_readers. By that reason, when writer finally > releases write end of the semaphore __ldsem_wake_readers() does adjust > sem->count with wrong

[PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-10 Thread Dmitry Safonov
It seems like when ldsem_down_read() fails with timeout, it misses update for sem->wait_readers. By that reason, when writer finally releases write end of the semaphore __ldsem_wake_readers() does adjust sem->count with wrong value: sem->wait_readers * (LDSEM_ACTIVE_BIAS - LDSEM_WAIT_BIAS) I.e,

[PATCHv3 6/6] tty/ldsem: Decrement wait_readers on timeouted down_read()

2018-09-10 Thread Dmitry Safonov
It seems like when ldsem_down_read() fails with timeout, it misses update for sem->wait_readers. By that reason, when writer finally releases write end of the semaphore __ldsem_wake_readers() does adjust sem->count with wrong value: sem->wait_readers * (LDSEM_ACTIVE_BIAS - LDSEM_WAIT_BIAS) I.e,