From: "Emilio G. Cota" <cota@braap.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
"Richard Henderson" <rth@twiddle.net>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [PATCH 1/6] qsp: drop atomics when using the seqlock
Date: Mon, 3 Sep 2018 13:18:26 -0400 [thread overview]
Message-ID: <20180903171831.15446-2-cota@braap.org> (raw)
In-Reply-To: <20180903171831.15446-1-cota@braap.org>
Using atomics here is a mistake since they're not guaranteed
to compile.
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
util/qsp.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/util/qsp.c b/util/qsp.c
index b0c2575d10..a1ee03b84b 100644
--- a/util/qsp.c
+++ b/util/qsp.c
@@ -351,6 +351,7 @@ static QSPEntry *qsp_entry_get(const void *obj, const char *file, int line,
static void qsp_entry_aggregate(QSPEntry *to, const QSPEntry *from)
{
#ifdef CONFIG_ATOMIC64
+ /* use __nocheck because sizeof(void *) might be < sizeof(u64) */
to->ns += atomic_read__nocheck(&from->ns);
to->n_acqs += atomic_read__nocheck(&from->n_acqs);
#else
@@ -359,8 +360,8 @@ static void qsp_entry_aggregate(QSPEntry *to, const QSPEntry *from)
do {
version = seqlock_read_begin(&from->sequence);
- ns = atomic_read__nocheck(&from->ns);
- n_acqs = atomic_read__nocheck(&from->n_acqs);
+ ns = from->ns;
+ n_acqs = from->n_acqs;
} while (seqlock_read_retry(&from->sequence, version));
to->ns += ns;
@@ -375,14 +376,17 @@ static void qsp_entry_aggregate(QSPEntry *to, const QSPEntry *from)
*/
static inline void do_qsp_entry_record(QSPEntry *e, int64_t delta, bool acq)
{
-#ifndef CONFIG_ATOMIC64
- seqlock_write_begin(&e->sequence);
-#endif
+#ifdef CONFIG_ATOMIC64
atomic_set__nocheck(&e->ns, e->ns + delta);
if (acq) {
atomic_set__nocheck(&e->n_acqs, e->n_acqs + 1);
}
-#ifndef CONFIG_ATOMIC64
+#else
+ seqlock_write_begin(&e->sequence);
+ e->ns += delta;
+ if (acq) {
+ e->n_acqs++;
+ }
seqlock_write_end(&e->sequence);
#endif
}
--
2.17.1
next prev parent reply other threads:[~2018-09-03 17:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-03 17:18 [Qemu-devel] [PATCH 0/6] i386 + x86_64 mttcg Emilio G. Cota
2018-09-03 17:18 ` Emilio G. Cota [this message]
2018-09-09 23:32 ` [Qemu-devel] [PATCH 1/6] qsp: drop atomics when using the seqlock Paolo Bonzini
2018-09-10 15:44 ` Emilio G. Cota
2018-09-11 11:11 ` Paolo Bonzini
2018-09-03 17:18 ` [Qemu-devel] [PATCH 2/6] test-rcu-list: avoid torn accesses to n_reclaims and n_nodes_removed Emilio G. Cota
2018-09-04 17:37 ` Murilo Opsfelder Araujo
2018-09-04 19:35 ` Emilio G. Cota
2018-09-04 20:56 ` Murilo Opsfelder Araujo
2018-09-04 21:32 ` Emilio G. Cota
2018-09-11 11:25 ` Paolo Bonzini
2018-09-03 17:18 ` [Qemu-devel] [PATCH 3/6] atomic: fix comment s/x64_64/x86_64/ Emilio G. Cota
2018-09-10 9:12 ` Alex Bennée
2018-09-03 17:18 ` [Qemu-devel] [PATCH 4/6] cpus: initialize timers_state.vm_clock_lock Emilio G. Cota
2018-09-10 9:13 ` Alex Bennée
2018-09-03 17:18 ` [Qemu-devel] [PATCH 5/6] target/i386/translate: use thread-local storage in !user-mode Emilio G. Cota
2018-09-10 9:17 ` Alex Bennée
2018-09-10 12:30 ` Emilio G. Cota
2018-09-10 13:43 ` Alex Bennée
2018-09-11 11:24 ` Paolo Bonzini
2018-09-11 17:21 ` Emilio G. Cota
2018-09-03 17:18 ` [Qemu-devel] [PATCH 6/6] configure: enable mttcg for i386 and x86_64 Emilio G. Cota
2018-09-11 11:25 ` [Qemu-devel] [PATCH 0/6] i386 + x86_64 mttcg Paolo Bonzini
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=20180903171831.15446-2-cota@braap.org \
--to=cota@braap.org \
--cc=alex.bennee@linaro.org \
--cc=crosthwaite.peter@gmail.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--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 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.