From: Peter Zijlstra <peterz@infradead.org>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: mingo@kernel.org, tglx@linutronix.de, Waiman.Long@hpe.com,
jason.low2@hp.com, linux-kernel@vger.kernel.org,
Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH 4/4] locking/rwsem: Rework zeroing reader waiter->task
Date: Mon, 9 May 2016 09:50:51 +0200 [thread overview]
Message-ID: <20160509075051.GE3430@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1462769770-29363-5-git-send-email-dave@stgolabs.net>
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.
next prev parent reply other threads:[~2016-05-09 7:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-09 4:56 [PATCH -tip 0/4] locking/rwsem (xadd): Reader waiter optimizations Davidlohr Bueso
2016-05-09 4:56 ` [PATCH 1/4] locking/rwsem: Avoid stale ->count for rwsem_down_write_failed() Davidlohr Bueso
2016-05-09 5:36 ` Peter Hurley
2016-05-09 7:12 ` Peter Zijlstra
2016-05-09 14:29 ` Davidlohr Bueso
2016-05-09 4:56 ` [PATCH 2/4] locking/rwsem: Drop superfluous waiter refcount Davidlohr Bueso
2016-05-09 7:39 ` Peter Zijlstra
2016-05-09 15:56 ` Davidlohr Bueso
2016-05-09 16:11 ` Peter Zijlstra
2016-05-09 18:51 ` Davidlohr Bueso
2016-05-09 18:59 ` Peter Zijlstra
2016-05-09 4:56 ` [PATCH 3/4] locking/rwsem: Enable lockless waiter wakeup(s) Davidlohr Bueso
2016-05-09 7:48 ` Peter Zijlstra
2016-05-09 4:56 ` [PATCH 4/4] locking/rwsem: Rework zeroing reader waiter->task Davidlohr Bueso
2016-05-09 7:50 ` Peter Zijlstra [this message]
2016-05-10 1:31 ` [PATCH -tip 0/4] locking/rwsem (xadd): Reader waiter optimizations Waiman Long
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160509075051.GE3430@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Waiman.Long@hpe.com \
--cc=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=jason.low2@hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.