From: Paolo Bonzini <pbonzini@redhat.com>
To: "Emilio G. Cota" <cota@braap.org>, qemu-devel@nongnu.org
Cc: Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Richard Henderson <rth@twiddle.net>,
David Gibson <david@gibson.dropbear.id.au>,
Alexander Graf <agraf@suse.de>, Riku Voipio <riku.voipio@iki.fi>,
Laurent Vivier <laurent@vivier.eu>,
qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 00/11] convert CPU list to RCU
Date: Mon, 20 Aug 2018 11:30:07 +0200 [thread overview]
Message-ID: <374f82bc-1680-a59d-aa71-31e88e4936a2@redhat.com> (raw)
In-Reply-To: <20180819091335.22863-1-cota@braap.org>
On 19/08/2018 11:13, Emilio G. Cota wrote:
> - Add some fixes for test-rcu-list. I wanted to be able to get no
> races with ThreadSanitizer, but it still warns about two races.
> I'm appending the report just in case, but I think tsan is getting
> confused.
I cannot understand the first. The second might be fixed by this untested
patch (the second hunk; the first is an optimization and clarification):
diff --git a/util/rcu.c b/util/rcu.c
index 5676c22bd1..314b7db1a6 100644
--- a/util/rcu.c
+++ b/util/rcu.c
@@ -192,7 +192,9 @@ static void enqueue(struct rcu_head *node)
node->next = NULL;
old_tail = atomic_xchg(&tail, &node->next);
- atomic_mb_set(old_tail, node);
+
+ /* Pairs with smb_mb_acquire() in try_dequeue. */
+ atomic_store_release(old_tail, node);
}
static struct rcu_head *try_dequeue(void)
@@ -213,7 +215,10 @@ retry:
* wrong and we need to wait until its enqueuer finishes the update.
*/
node = head;
- next = atomic_mb_read(&head->next);
+ smp_mb_acquire();
+
+ /* atomic_read is enough because the pointer is never dereferenced. */
+ next = atomic_read(&head->next);
if (!next) {
return NULL;
}
The idea being that enqueue() writes so to speak node->prev->next in
the atomic_store_release when it enqueues node; try_dequeue() instead reads
node->next, so there is no synchronizes-with edge. However, I'm not that
convinced that it's necessary...
Paolo
next prev parent reply other threads:[~2018-08-20 9:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-19 9:13 [Qemu-devel] [PATCH v2 00/11] convert CPU list to RCU Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 01/11] rcu_queue: use atomic_set in QLIST_REMOVE_RCU Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 02/11] rcu_queue: remove barrier from QLIST_EMPTY_RCU Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 03/11] rcu_queue: add RCU QSIMPLEQ Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 04/11] rcu_queue: add RCU QTAILQ Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 05/11] test-rcu-list: access goflag with atomics Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 06/11] test-rcu-list: access counters " Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 07/11] test-rcu-list: abstract the list implementation Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 08/11] tests: add test-list-simpleq Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 09/11] tests: add test-rcu-tailq Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 10/11] spapr: do not use CPU_FOREACH_REVERSE Emilio G. Cota
2018-08-19 9:13 ` [Qemu-devel] [PATCH v2 11/11] qom: convert the CPU list to RCU Emilio G. Cota
2018-08-20 9:30 ` Paolo Bonzini [this message]
2018-08-31 20:29 ` [Qemu-devel] [PATCH v2 00/11] convert " Emilio G. Cota
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=374f82bc-1680-a59d-aa71-31e88e4936a2@redhat.com \
--to=pbonzini@redhat.com \
--cc=agraf@suse.de \
--cc=cota@braap.org \
--cc=crosthwaite.peter@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=rth@twiddle.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).