Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1534121
| From | Nicolai Hähnle <nhaehnle@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 00/11] locking/ww_mutex: Keep sorted wait list to avoid stampedes |
| Date | 2016-12-01 15:10 +0100 |
| Message-ID | <sJAdI-4Rh-7@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
Changes to patches 1 & 5 based on feedback. I've also updated the branch at https://cgit.freedesktop.org/~nh/linux/log/?h=mutex. There's been the question of using a balanced tree rather than a list. Frankly, I'd say the 99% use case doesn't need it. Also, dealing with waiters without a context is easy in the list, but becomes trickier with a tree. I think one can do it with an additional counter on the lock itself to establish the FIFO order of context-less waiters, but it'd make the code harder to follow. I doubt that it's worth it. (original cover letter below) The basic idea is to make sure that: 1. All waiters that have a ww_ctx appear in stamp order in the wait list. Waiters without a ww_ctx are still supported and appear in FIFO order as before. 2. At most one of the waiters can be in a state where it has to check for back off (i.e., ww_ctx->acquire > 0). Technically, there are short time windows in which more than one such waiter can be on the list, but all but the first one are running. This happens when a new waiter with ww_ctx->acquire > 0 adds itself at the front of the list and wakes up the previous head of the list, and of course multiple such chained cases can be in-flight simultaneously. Then we only ever have to wake up one task at a time. This is _not_ always the head of the wait list, since there may be waiters without a context. But among waiters with a context, we only ever have to wake the first one. To achieve all this, the series adds a new field to mutex_waiter which is only used for the w/w lock case. As a consequence, calling mutex_lock directly on w/w locks is now definitely incorrect. That was likely the intention previously anyway, but grepping through the source I did find one place that had slipped through. I've included timings taken from a contention-heavy stress test to some of the patches. The stress test performs actual GPU operations which take a good chunk of the wall time, but even so, the series still manages to improve the wall time quite a bit. Cheers, Nicolai
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH v2 00/11] locking/ww_mutex: Keep sorted wait list to avoid stampedes Nicolai Hähnle <nhaehnle@gmail.com> - 2016-12-01 15:10 +0100
[PATCH v2 05/11] locking/ww_mutex: Add waiters in stamp order Nicolai Hähnle <nhaehnle@gmail.com> - 2016-12-01 15:10 +0100
Re: [PATCH v2 05/11] locking/ww_mutex: Add waiters in stamp order Chris Wilson <chris@chris-wilson.co.uk> - 2016-12-01 17:10 +0100
Re: [PATCH v2 05/11] locking/ww_mutex: Add waiters in stamp order Peter Zijlstra <peterz@infradead.org> - 2016-12-06 16:40 +0100
Re: [PATCH v2 05/11] locking/ww_mutex: Add waiters in stamp order Peter Zijlstra <peterz@infradead.org> - 2016-12-06 18:00 +0100
[PATCH v2 07/11] locking/ww_mutex: Wake at most one waiter for back off when acquiring the lock Nicolai Hähnle <nhaehnle@gmail.com> - 2016-12-01 15:10 +0100
[PATCH v2 10/11] Documentation/locking/ww_mutex: Update the design document Nicolai Hähnle <nhaehnle@gmail.com> - 2016-12-01 15:10 +0100
[PATCH v2 09/11] locking/mutex: Initialize mutex_waiter::ww_ctx with poison when debugging Nicolai Hähnle <nhaehnle@gmail.com> - 2016-12-01 15:10 +0100
[PATCH v2 02/11] locking/ww_mutex: Re-check ww->ctx in the inner optimistic spin loop Nicolai Hähnle <nhaehnle@gmail.com> - 2016-12-01 15:10 +0100
Re: [PATCH v2 02/11] locking/ww_mutex: Re-check ww->ctx in the inner optimistic spin loop Chris Wilson <chris@chris-wilson.co.uk> - 2016-12-01 15:40 +0100
Re: [PATCH v2 02/11] locking/ww_mutex: Re-check ww->ctx in the inner optimistic spin loop Peter Zijlstra <peterz@infradead.org> - 2016-12-06 16:10 +0100
Re: [PATCH v2 02/11] locking/ww_mutex: Re-check ww->ctx in the inner optimistic spin loop Waiman Long <longman@redhat.com> - 2016-12-06 17:10 +0100
Re: [PATCH v2 02/11] locking/ww_mutex: Re-check ww->ctx in the inner optimistic spin loop Waiman Long <longman@redhat.com> - 2016-12-06 19:50 +0100
Re: [PATCH v2 02/11] locking/ww_mutex: Re-check ww->ctx in the inner optimistic spin loop Peter Zijlstra <peterz@infradead.org> - 2016-12-06 20:10 +0100
[PATCH v2 01/11] drm/vgem: Use ww_mutex_(un)lock even with a NULL context Nicolai Hähnle <nhaehnle@gmail.com> - 2016-12-01 15:10 +0100
Re: [PATCH v2 01/11] drm/vgem: Use ww_mutex_(un)lock even with a NULL context Chris Wilson <chris@chris-wilson.co.uk> - 2016-12-01 15:20 +0100
Re: [PATCH v2 01/11] drm/vgem: Use ww_mutex_(un)lock even with a NULL context Daniel Vetter <daniel@ffwll.ch> - 2016-12-01 16:20 +0100
Re: [PATCH v2 01/11] drm/vgem: Use ww_mutex_(un)lock even with a NULL context Peter Zijlstra <peterz@infradead.org> - 2016-12-01 17:30 +0100
[PATCH v2 11/11] [rfc] locking/ww_mutex: Always spin optimistically for the first waiter Nicolai Hähnle <nhaehnle@gmail.com> - 2016-12-01 15:10 +0100
[PATCH v2 06/11] locking/ww_mutex: Notify waiters that have to back off while adding tasks to wait list Nicolai Hähnle <nhaehnle@gmail.com> - 2016-12-01 15:10 +0100
csiph-web