[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 29/39] test-qht: perform lookups under rcu_read_lock
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 29/39] test-qht: perform lookups under rcu_read_lock |
Date: |
Fri, 7 Oct 2016 18:57:53 +0200 |
From: "Emilio G. Cota" <address@hidden>
qht_lookup is meant to be called from an RCU read-critical
section. Make sure we're in such a section in test-qht
when performing lookups, despite the fact that no races
in qht can be triggered by test-qht since it is single-threaded.
Note that rcu_register_thread is already called by the
rcu_after_fork hook, and therefore duplicating it here would
be a bug.
Signed-off-by: Emilio G. Cota <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
tests/test-qht.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/test-qht.c b/tests/test-qht.c
index 46a64b6..9b7423a 100644
--- a/tests/test-qht.c
+++ b/tests/test-qht.c
@@ -6,6 +6,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/qht.h"
+#include "qemu/rcu.h"
#define N 5000
@@ -51,6 +52,7 @@ static void check(int a, int b, bool expected)
struct qht_stats stats;
int i;
+ rcu_read_lock();
for (i = a; i < b; i++) {
void *p;
uint32_t hash;
@@ -61,6 +63,8 @@ static void check(int a, int b, bool expected)
p = qht_lookup(&ht, is_equal, &val, hash);
g_assert_true(!!p == expected);
}
+ rcu_read_unlock();
+
qht_statistics_init(&ht, &stats);
if (stats.used_head_buckets) {
g_assert_cmpfloat(qdist_avg(&stats.chain), >=, 1.0);
--
2.7.4
- [Qemu-devel] [PULL 20/39] .travis.yml: add gcc sanitizer build, (continued)
- [Qemu-devel] [PULL 20/39] .travis.yml: add gcc sanitizer build, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 22/39] char: use a fixed idx for child muxed chr, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 21/39] i8259: give ISA device when registering ISA ioports, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 23/39] char: update read handler in all cases, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 25/39] qemu_kill_report: Report PID name too, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 24/39] util: Introduce qemu_get_pid_name, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 26/39] qemu-nbd: Shrink image size by specified offset, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 27/39] qht: simplify qht_reset_size, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 28/39] qht: fix unlock-after-free segfault upon resizing, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 30/39] qemu-tech: drop index, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 29/39] test-qht: perform lookups under rcu_read_lock,
Paolo Bonzini <=
- [Qemu-devel] [PULL 31/39] qemu-doc: replace introduction with the one from the internals manual, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 33/39] qemu-tech: move text from qemu-tech to tcg/README, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 32/39] qemu-doc: drop installation and compilation notes, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 36/39] qemu-tech: move TCG test documentation to tests/tcg/README, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 34/39] qemu-tech: document lazy condition code evaluation in cpu.h, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 37/39] qemu-tech: reorganize content, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 38/39] qemu-tech: rewrite some parts, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 39/39] qemu-doc: merge qemu-tech and qemu-doc, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 35/39] qemu-tech: move user mode emulation features from qemu-tech, Paolo Bonzini, 2016/10/07
- Re: [Qemu-devel] [PULL 00/39] Misc patches for 2016-10-07, Peter Maydell, 2016/10/10