]> git.proxmox.com Git - mirror_qemu.git/commit
util/qht: atomically set b->hashes
authorAlex Bennée <alex.bennee@linaro.org>
Fri, 30 Sep 2016 21:31:00 +0000 (22:31 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 4 Oct 2016 08:00:26 +0000 (10:00 +0200)
commita890643958f03aaa344290700093b280cb606c28
tree3c49b66767086eb01021e88e8c4611dabdc8361b
parent027d9a7d2911e993cdcbd21c7c35d1dd058f05bb
util/qht: atomically set b->hashes

ThreadSanitizer detects a possible race between reading/writing the
hashes. The ordering semantics are already documented for QHT however
for true C11 compliance we should use relaxed atomic primitives for
accesses that are done across threads. On x86 this slightly changes to
the code to not do a load/compare in a single instruction leading to a
slight performance degradation.

Running 'taskset -c 0 tests/qht-bench -n 1 -d 10' (i.e. all lookups) 10
times, we get:

before the patch:
 $ ./mean.pl 34.04 34.24 34.38 34.25 34.18 34.51 34.46 34.44 34.29 34.08
 34.287 +- 0.160072900059109
after:
 $ ./mean.pl 33.94 34.00 33.52 33.46 33.55 33.71 34.27 34.06 34.28 34.58
 33.937 +- 0.374731014640279

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Emilio G. Cota <cota@braap.org>
Message-Id: <20160930213106.20186-10-alex.bennee@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
util/qht.c