Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1396801
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 4/4] locking/rwsem: Rework zeroing reader waiter->task |
| Date | 2016-05-09 10:00 +0200 |
| Message-ID | <rwOgH-II-23@gated-at.bofh.it> (permalink) |
| References | <rwLsu-5sI-3@gated-at.bofh.it> <rwLCa-5YS-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sun, May 08, 2016 at 09:56:10PM -0700, Davidlohr Bueso wrote:
> Readers that are awoken will expect a nil ->task indicating
> that a wakeup has occurred. There is a mismatch between the
> smp_mb() and its documentation, in that the serialization is
> done between reading the task and the nil store. Furthermore,
> in addition to having the overlapping of loads and stores to
> waiter->task guaranteed to be ordered within that CPU, both
> wake_up_process() originally and now wake_q_add() already
> imply barriers upon successful calls, which serves the comment.
>
> Just atomically do a xchg() and simplify the whole thing. We can
> use relaxed semantics as before mentioned in addition to the
> barrier provided by wake_q_add(), delaying there is no risk in
> reordering with the actual wakeup.
> @@ -190,24 +189,18 @@ __rwsem_mark_wake(struct rw_semaphore *sem,
> next = sem->wait_list.next;
> loop = woken;
> do {
> + struct task_struct *tsk;
> +
> waiter = list_entry(next, struct rwsem_waiter, list);
> next = waiter->list.next;
> - tsk = waiter->task;
> - /*
> - * Make sure we do not wakeup the next reader before
> - * setting the nil condition to grant the next reader;
> - * otherwise we could miss the wakeup on the other
> - * side and end up sleeping again. See the pairing
> - * in rwsem_down_read_failed().
> - */
> - smp_mb();
> - waiter->task = NULL;
> +
> + tsk = xchg_relaxed(&waiter->task, NULL);
> wake_q_add(wake_q, tsk);
Not a great fan of this patch; it again doesn't fix the race, and
smp_store_release() is a cheaper option on x86.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH -tip 0/4] locking/rwsem (xadd): Reader waiter optimizations Davidlohr Bueso <dave@stgolabs.net> - 2016-05-09 07:00 +0200
[PATCH 4/4] locking/rwsem: Rework zeroing reader waiter->task Davidlohr Bueso <dave@stgolabs.net> - 2016-05-09 07:10 +0200
Re: [PATCH 4/4] locking/rwsem: Rework zeroing reader waiter->task Peter Zijlstra <peterz@infradead.org> - 2016-05-09 10:00 +0200
[PATCH 3/4] locking/rwsem: Enable lockless waiter wakeup(s) Davidlohr Bueso <dave@stgolabs.net> - 2016-05-09 07:10 +0200
Re: [PATCH 3/4] locking/rwsem: Enable lockless waiter wakeup(s) Peter Zijlstra <peterz@infradead.org> - 2016-05-09 09:50 +0200
[PATCH 2/4] locking/rwsem: Drop superfluous waiter refcount Davidlohr Bueso <dave@stgolabs.net> - 2016-05-09 07:10 +0200
Re: [PATCH 2/4] locking/rwsem: Drop superfluous waiter refcount Peter Zijlstra <peterz@infradead.org> - 2016-05-09 09:40 +0200
Re: [PATCH 2/4] locking/rwsem: Drop superfluous waiter refcount Davidlohr Bueso <dave@stgolabs.net> - 2016-05-09 18:00 +0200
Re: [PATCH 2/4] locking/rwsem: Drop superfluous waiter refcount Peter Zijlstra <peterz@infradead.org> - 2016-05-09 18:20 +0200
Re: [PATCH 2/4] locking/rwsem: Drop superfluous waiter refcount Davidlohr Bueso <dave@stgolabs.net> - 2016-05-09 21:00 +0200
Re: [PATCH 2/4] locking/rwsem: Drop superfluous waiter refcount Peter Zijlstra <peterz@infradead.org> - 2016-05-09 21:10 +0200
[PATCH 1/4] locking/rwsem: Avoid stale ->count for rwsem_down_write_failed() Davidlohr Bueso <dave@stgolabs.net> - 2016-05-09 07:10 +0200
Re: [PATCH 1/4] locking/rwsem: Avoid stale ->count for rwsem_down_write_failed() Peter Hurley <peter@hurleysoftware.com> - 2016-05-09 07:40 +0200
Re: [PATCH 1/4] locking/rwsem: Avoid stale ->count for rwsem_down_write_failed() Peter Zijlstra <peterz@infradead.org> - 2016-05-09 09:20 +0200
Re: [PATCH 1/4] locking/rwsem: Avoid stale ->count for rwsem_down_write_failed() Davidlohr Bueso <dave@stgolabs.net> - 2016-05-09 16:40 +0200
Re: [PATCH -tip 0/4] locking/rwsem (xadd): Reader waiter optimizations Waiman Long <waiman.long@hpe.com> - 2016-05-10 03:40 +0200
csiph-web