Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1529225

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

From Daniel Vetter <daniel@ffwll.ch>
Newsgroups linux.kernel
Subject Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes
Date 2016-11-24 13:00 +0100
Message-ID <sH0R3-27o-5@gated-at.bofh.it> (permalink)
References <sGDUt-4co-3@gated-at.bofh.it> <sGGSm-65N-35@gated-at.bofh.it> <sGGSm-65N-37@gated-at.bofh.it> <sH0o2-1XY-9@gated-at.bofh.it> <sH0Hn-24n-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Nov 24, 2016 at 12:40 PM, Peter Zijlstra <peterz@infradead.org> 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 struct mutex_waiter with ww_mutex-specific
>> fields to facilitate this (i.e. ctx pointer, perhaps stamp as well to reduce
>> pointer-chasing). That should be fine since it lives on the stack.
>
> Right, shouldn't be a problem I think.
>
> The only 'problem' I can see with using that is that its possible to mix
> ww and !ww waiters through ww_mutex_lock(.ctx = NULL). This makes the
> list order somewhat tricky.
>
> Ideally we'd remove that feature, although I see its actually used quite
> a bit :/

I guess we could create a small fake acquire_ctx for single-lock
paths. That way callers still don't need to deal with having an
explicit ctx, but we can assume the timestamp (for ensuring fairness)
is available for all cases. Otherwise there's indeed a problem with
correctly (well fairly) interleaving ctx and non-ctx lockers I think.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Nicolai Hähnle <nhaehnle@gmail.com> - 2016-11-23 12:30 +0100
  Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Daniel Vetter <daniel@ffwll.ch> - 2016-11-23 14:00 +0100
  Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Daniel Vetter <daniel@ffwll.ch> - 2016-11-23 14:10 +0100
    Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Daniel Vetter <daniel@ffwll.ch> - 2016-11-23 14:20 +0100
      Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Maarten Lankhorst <dev@mblankhorst.nl> - 2016-11-23 14:50 +0100
  Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Peter Zijlstra <peterz@infradead.org> - 2016-11-23 14:10 +0100
  Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Peter Zijlstra <peterz@infradead.org> - 2016-11-23 15:40 +0100
  Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Daniel Vetter <daniel@ffwll.ch> - 2016-11-23 16:10 +0100
    Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Nicolai Hähnle <nhaehnle@gmail.com> - 2016-11-24 12:30 +0100
      Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Peter Zijlstra <peterz@infradead.org> - 2016-11-24 12:50 +0100
        Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Daniel Vetter <daniel@ffwll.ch> - 2016-11-24 13:00 +0100
          Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Peter Zijlstra <peterz@infradead.org> - 2016-11-24 13:20 +0100
  Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Peter Zijlstra <peterz@infradead.org> - 2016-11-23 16:20 +0100

csiph-web