[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 41/74] test-rcu-list: access counters with atomics
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 41/74] test-rcu-list: access counters with atomics |
Date: |
Tue, 21 Aug 2018 19:02:13 +0200 |
From: "Emilio G. Cota" <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
tests/test-rcu-list.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tests/test-rcu-list.c b/tests/test-rcu-list.c
index b4ed130..dc58091 100644
--- a/tests/test-rcu-list.c
+++ b/tests/test-rcu-list.c
@@ -93,7 +93,7 @@ static void reclaim_list_el(struct rcu_head *prcu)
struct list_element *el = container_of(prcu, struct list_element, rcu);
g_free(el);
/* Accessed only from call_rcu thread. */
- n_reclaims++;
+ atomic_set(&n_reclaims, n_reclaims + 1);
}
static QLIST_HEAD(q_list_head, list_element) Q_list_head;
@@ -182,7 +182,7 @@ static void *rcu_q_updater(void *arg)
qemu_mutex_lock(&counts_mutex);
n_nodes += n_nodes_local;
n_updates += n_updates_local;
- n_nodes_removed += n_removed_local;
+ atomic_set(&n_nodes_removed, n_nodes_removed + n_removed_local);
qemu_mutex_unlock(&counts_mutex);
return NULL;
}
@@ -239,16 +239,18 @@ static void rcu_qtest(const char *test, int duration, int
nreaders)
n_nodes_removed += n_removed_local;
qemu_mutex_unlock(&counts_mutex);
synchronize_rcu();
- while (n_nodes_removed > n_reclaims) {
+ while (atomic_read(&n_nodes_removed) > atomic_read(&n_reclaims)) {
g_usleep(100);
synchronize_rcu();
}
if (g_test_in_charge) {
- g_assert_cmpint(n_nodes_removed, ==, n_reclaims);
+ g_assert_cmpint(atomic_read(&n_nodes_removed), ==,
+ atomic_read(&n_reclaims));
} else {
printf("%s: %d readers; 1 updater; nodes read: " \
"%lld, nodes removed: %lld; nodes reclaimed: %lld\n",
- test, nthreadsrunning - 1, n_reads, n_nodes_removed,
n_reclaims);
+ test, nthreadsrunning - 1, n_reads,
+ atomic_read(&n_nodes_removed), atomic_read(&n_reclaims));
exit(0);
}
}
--
1.8.3.1
- [Qemu-devel] [PULL 25/74] hmp-commands: add sync-profile, (continued)
- [Qemu-devel] [PULL 25/74] hmp-commands: add sync-profile, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 47/74] hw/intc/apic: Switch away from old_mmio, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 28/74] update-linux-headers.sh: add qemu_fw_cfg.h, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 34/74] target-i386: Fix lcall/ljmp to call gate in IA-32e mode, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 37/74] rcu_queue: remove barrier from QLIST_EMPTY_RCU, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 17/74] seqlock: constify seqlock_read_begin, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 43/74] tests: add test-list-simpleq, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 44/74] tests: add test-rcu-tailq, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 49/74] module: Use QEMU_MODULE_DIR as a search path, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 51/74] seqlock: add QemuLockable support, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 41/74] test-rcu-list: access counters with atomics,
Paolo Bonzini <=
- [Qemu-devel] [PULL 39/74] rcu_queue: add RCU QTAILQ, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 46/74] qom: convert the CPU list to RCU, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 23/74] tests/atomic_add-bench: add -p to enable sync profiler, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 52/74] cpus: protect TimerState writes with a spinlock, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 38/74] rcu_queue: add RCU QSIMPLEQ, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 45/74] spapr: do not use CPU_FOREACH_REVERSE, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 30/74] i386: Fix arch_query_cpu_model_expansion() leak, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 40/74] test-rcu-list: access goflag with atomics, Paolo Bonzini, 2018/08/21