[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 06/11] test-rcu-list: access counters with atomic
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [PATCH v2 06/11] test-rcu-list: access counters with atomics |
Date: |
Sun, 19 Aug 2018 05:13:30 -0400 |
Signed-off-by: Emilio G. Cota <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 b4ed130081..dc58091996 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);
}
}
--
2.17.1
- [Qemu-devel] [PATCH v2 00/11] convert CPU list to RCU, Emilio G. Cota, 2018/08/19
- [Qemu-devel] [PATCH v2 02/11] rcu_queue: remove barrier from QLIST_EMPTY_RCU, Emilio G. Cota, 2018/08/19
- [Qemu-devel] [PATCH v2 07/11] test-rcu-list: abstract the list implementation, Emilio G. Cota, 2018/08/19
- [Qemu-devel] [PATCH v2 01/11] rcu_queue: use atomic_set in QLIST_REMOVE_RCU, Emilio G. Cota, 2018/08/19
- [Qemu-devel] [PATCH v2 10/11] spapr: do not use CPU_FOREACH_REVERSE, Emilio G. Cota, 2018/08/19
- [Qemu-devel] [PATCH v2 03/11] rcu_queue: add RCU QSIMPLEQ, Emilio G. Cota, 2018/08/19
- [Qemu-devel] [PATCH v2 11/11] qom: convert the CPU list to RCU, Emilio G. Cota, 2018/08/19
- [Qemu-devel] [PATCH v2 06/11] test-rcu-list: access counters with atomics,
Emilio G. Cota <=
- [Qemu-devel] [PATCH v2 04/11] rcu_queue: add RCU QTAILQ, Emilio G. Cota, 2018/08/19
- [Qemu-devel] [PATCH v2 09/11] tests: add test-rcu-tailq, Emilio G. Cota, 2018/08/19
- [Qemu-devel] [PATCH v2 08/11] tests: add test-list-simpleq, Emilio G. Cota, 2018/08/19
- [Qemu-devel] [PATCH v2 05/11] test-rcu-list: access goflag with atomics, Emilio G. Cota, 2018/08/19
- Re: [Qemu-devel] [PATCH v2 00/11] convert CPU list to RCU, Paolo Bonzini, 2018/08/20