[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/6] qsp: drop atomics when using the seqlock
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [PATCH 1/6] qsp: drop atomics when using the seqlock |
Date: |
Mon, 3 Sep 2018 13:18:26 -0400 |
Using atomics here is a mistake since they're not guaranteed
to compile.
Signed-off-by: Emilio G. Cota <address@hidden>
---
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
- Re: [Qemu-devel] [PATCH 5/6] target/i386/translate: use thread-local storage in !user-mode, (continued)
[Qemu-devel] [PATCH 2/6] test-rcu-list: avoid torn accesses to n_reclaims and n_nodes_removed, Emilio G. Cota, 2018/09/03
[Qemu-devel] [PATCH 1/6] qsp: drop atomics when using the seqlock,
Emilio G. Cota <=
Re: [Qemu-devel] [PATCH 0/6] i386 + x86_64 mttcg, Paolo Bonzini, 2018/09/11