[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 19/31] atomics: do not emit consume barrier for atomi
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 19/31] atomics: do not emit consume barrier for atomic_rcu_read |
Date: |
Fri, 27 May 2016 12:06:32 +0200 |
From: "Emilio G. Cota" <address@hidden>
Currently we emit a consume-load in atomic_rcu_read. Because of
limitations in current compilers, this is overkill for non-Alpha hosts
and it is only useful to make Thread Sanitizer work.
This patch leaves the consume-load in atomic_rcu_read when
compiling with Thread Sanitizer enabled, and resorts to a
relaxed load + smp_read_barrier_depends otherwise.
On an RMO host architecture, such as aarch64, the performance
improvement of this change is easily measurable. For instance,
qht-bench performs an atomic_rcu_read on every lookup. Performance
before and after applying this patch:
$ tests/qht-bench -d 5 -n 1
Before: 9.78 MT/s
After: 10.96 MT/s
Signed-off-by: Emilio G. Cota <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/qemu/atomic.h | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index 96db6e9..7a59096 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -67,13 +67,23 @@
__atomic_store(ptr, &_val, __ATOMIC_RELAXED); \
} while(0)
-/* Atomic RCU operations imply weak memory barriers */
+/* See above: most compilers currently treat consume and acquire the
+ * same, but this slows down atomic_rcu_read unnecessarily.
+ */
+#ifdef __SANITIZE_THREAD__
+#define atomic_rcu_read__nocheck(ptr, valptr) \
+ __atomic_load(ptr, valptr, __ATOMIC_CONSUME);
+#else
+#define atomic_rcu_read__nocheck(ptr, valptr) \
+ __atomic_load(ptr, valptr, __ATOMIC_RELAXED); \
+ smp_read_barrier_depends();
+#endif
#define atomic_rcu_read(ptr) \
({ \
QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \
typeof(*ptr) _val; \
- __atomic_load(ptr, &_val, __ATOMIC_CONSUME); \
+ atomic_rcu_read__nocheck(ptr, &_val); \
_val; \
})
--
2.5.5
- [Qemu-devel] [PULL 14/31] scsi: megasas: check 'read_queue_head' index value, (continued)
- [Qemu-devel] [PULL 14/31] scsi: megasas: check 'read_queue_head' index value, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 10/31] scsi: pvscsi: check command descriptor ring buffer size (CVE-2016-4952), Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 09/31] kvm_stat: Remove, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 12/31] scsi: megasas: use appropriate property buffer size, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 15/31] block/iscsi: avoid potential overflow of acb->task->cdb, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 18/31] atomics: emit an smp_read_barrier_depends() barrier only for Alpha and Thread Sanitizer, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 20/31] docs/atomics: update comparison with Linux, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 17/31] docs/atomics: update atomic_read/set comparison with Linux, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 16/31] bt: rewrite csrhci_write to avoid out-of-bounds writes, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 24/31] scsi-disk: add need_fua_emulation to SCSIDiskClass, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 19/31] atomics: do not emit consume barrier for atomic_rcu_read,
Paolo Bonzini <=
- [Qemu-devel] [PULL 21/31] xen-hvm: ignore background I/O sections, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 22/31] scsi-disk: introduce a common base class, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 25/31] scsi-disk: introduce scsi_disk_req_check_error, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 26/31] scsi-block: always use SG_IO, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 23/31] scsi-disk: introduce dma_readv and dma_writev, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 27/31] scsi-generic: Merge block max xfer len in INQUIRY response, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 31/31] exec: hide mr->ram_addr from qemu_get_ram_ptr users, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 29/31] exec: remove ram_addr argument from qemu_ram_block_from_host, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 28/31] memory: remove qemu_get_ram_fd, qemu_set_ram_fd, qemu_ram_block_host_ptr, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 30/31] memory: split memory_region_from_host from qemu_ram_addr_from_host, Paolo Bonzini, 2016/05/27