Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-24 Thread Peter Zijlstra
On Thu, Nov 24, 2016 at 12:52:25PM +0100, Daniel Vetter wrote: > On Thu, Nov 24, 2016 at 12:40 PM, Peter Zijlstra wrote: > > > >> I do believe we can win a bit by keeping the wait list sorted, if we also > >> make sure that waiters don't add themselves in the first place if they see > >> that a de

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-24 Thread Nicolai Hähnle
On 24.11.2016 12:56, Peter Zijlstra wrote: On Thu, Nov 24, 2016 at 12:52:25PM +0100, Daniel Vetter wrote: On Thu, Nov 24, 2016 at 12:40 PM, Peter Zijlstra wrote: I do believe we can win a bit by keeping the wait list sorted, if we also make sure that waiters don't add themselves in the first

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-24 Thread Daniel Vetter
On Thu, Nov 24, 2016 at 12:40 PM, Peter Zijlstra wrote: > >> I do believe we can win a bit by keeping the wait list sorted, if we also >> make sure that waiters don't add themselves in the first place if they see >> that a deadlock situation cannot be avoided. >> >> I will probably want to extend

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-24 Thread Peter Zijlstra
On Thu, Nov 24, 2016 at 12:26:57PM +0100, Nicolai Hähnle wrote: > I do believe we can win a bit by keeping the wait list sorted, if we also > make sure that waiters don't add themselves in the first place if they see > that a deadlock situation cannot be avoided. > > I will probably want to exten

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-24 Thread Nicolai Hähnle
On 23.11.2016 15:25, Daniel Vetter wrote: On Wed, Nov 23, 2016 at 03:03:36PM +0100, Peter Zijlstra wrote: On Wed, Nov 23, 2016 at 12:25:22PM +0100, Nicolai Hähnle wrote: @@ -473,7 +476,14 @@ void __sched ww_mutex_unlock(struct ww_mutex *lock) */ mutex_clear_owner(&lock->base);

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-23 Thread Peter Zijlstra
On Wed, Nov 23, 2016 at 12:25:22PM +0100, Nicolai Hähnle wrote: > @@ -473,7 +476,14 @@ void __sched ww_mutex_unlock(struct ww_mutex *lock) >*/ > mutex_clear_owner(&lock->base); > #endif > - __mutex_fastpath_unlock(&lock->base.count, __mutex_unlock_slowpath); > + /* > + *

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-23 Thread Peter Zijlstra
On Wed, Nov 23, 2016 at 03:25:25PM +0100, Daniel Vetter wrote: > Without thinking it through in detail this is a PI issue, except that we > replace boosting with wakeup&back-off. Could we perhaps steal something > from rt mutexes to make it fair&efficient? rt_mutexes order the waiters by 'priorit

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-23 Thread Daniel Vetter
On Wed, Nov 23, 2016 at 03:03:36PM +0100, Peter Zijlstra wrote: > On Wed, Nov 23, 2016 at 12:25:22PM +0100, Nicolai Hähnle wrote: > > @@ -473,7 +476,14 @@ void __sched ww_mutex_unlock(struct ww_mutex *lock) > > */ > > mutex_clear_owner(&lock->base); > > #endif > > - __mutex_fastpath_unl

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-23 Thread Maarten Lankhorst
Op 23-11-16 om 14:11 schreef Daniel Vetter: > On Wed, Nov 23, 2016 at 02:08:48PM +0100, Daniel Vetter wrote: >> On Wed, Nov 23, 2016 at 02:00:46PM +0100, Peter Zijlstra wrote: >>> On Wed, Nov 23, 2016 at 12:25:22PM +0100, Nicolai Hähnle wrote: From: Nicolai Hähnle Fix a race conditi

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-23 Thread Daniel Vetter
On Wed, Nov 23, 2016 at 02:08:48PM +0100, Daniel Vetter wrote: > On Wed, Nov 23, 2016 at 02:00:46PM +0100, Peter Zijlstra wrote: > > On Wed, Nov 23, 2016 at 12:25:22PM +0100, Nicolai Hähnle wrote: > > > From: Nicolai Hähnle > > > > > > Fix a race condition involving 4 threads and 2 ww_mutexes as

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-23 Thread Daniel Vetter
On Wed, Nov 23, 2016 at 02:00:46PM +0100, Peter Zijlstra wrote: > On Wed, Nov 23, 2016 at 12:25:22PM +0100, Nicolai Hähnle wrote: > > From: Nicolai Hähnle > > > > Fix a race condition involving 4 threads and 2 ww_mutexes as indicated in > > the following example. Acquire context stamps are ordere

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-23 Thread Peter Zijlstra
On Wed, Nov 23, 2016 at 12:25:22PM +0100, Nicolai Hähnle wrote: > From: Nicolai Hähnle > > Fix a race condition involving 4 threads and 2 ww_mutexes as indicated in > the following example. Acquire context stamps are ordered like the thread > numbers, i.e. thread #1 should back off when it encoun

Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-23 Thread Daniel Vetter
On Wed, Nov 23, 2016 at 12:25:22PM +0100, Nicolai Hähnle wrote: > From: Nicolai Hähnle > > Fix a race condition involving 4 threads and 2 ww_mutexes as indicated in > the following example. Acquire context stamps are ordered like the thread > numbers, i.e. thread #1 should back off when it encoun

[PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes

2016-11-23 Thread Nicolai Hähnle
From: Nicolai Hähnle Fix a race condition involving 4 threads and 2 ww_mutexes as indicated in the following example. Acquire context stamps are ordered like the thread numbers, i.e. thread #1 should back off when it encounters a mutex locked by thread #0 etc. Thread #0Thread #1Thread #2