[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 18/31] atomics: emit an smp_read_barrier_depends() ba
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 18/31] atomics: emit an smp_read_barrier_depends() barrier only for Alpha and Thread Sanitizer |
Date: |
Fri, 27 May 2016 12:06:31 +0200 |
From: "Emilio G. Cota" <address@hidden>
For correctness, smp_read_barrier_depends() is only required to
emit a barrier on Alpha hosts. However, we are currently emitting
a consume fence unconditionally, and most compilers currently treat
consume and acquire fences as equivalent.
Fix it by keeping the consume fence if we're compiling with Thread
Sanitizer, since this might help prevent false warnings. Otherwise,
only emit the barrier for Alpha hosts. Note that we still guarantee
that smp_read_barrier_depends() is a compiler barrier.
Signed-off-by: Emilio G. Cota <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/qemu/atomic.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index 5bc4d6c..96db6e9 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -36,7 +36,18 @@
#define smp_wmb() ({ barrier(); __atomic_thread_fence(__ATOMIC_RELEASE);
barrier(); })
#define smp_rmb() ({ barrier(); __atomic_thread_fence(__ATOMIC_ACQUIRE);
barrier(); })
+/* Most compilers currently treat consume and acquire the same, but really
+ * no processors except Alpha need a barrier here. Leave it in if
+ * using Thread Sanitizer to avoid warnings, otherwise optimize it away.
+ */
+#if defined(__SANITIZE_THREAD__)
#define smp_read_barrier_depends() ({ barrier();
__atomic_thread_fence(__ATOMIC_CONSUME); barrier(); })
+#elsif defined(__alpha__)
+#define smp_read_barrier_depends() asm volatile("mb":::"memory")
+#else
+#define smp_read_barrier_depends() barrier()
+#endif
+
/* Weak atomic operations prevent the compiler moving other
* loads/stores past the atomic operation load/store. However there is
--
2.5.5
- [Qemu-devel] [PULL 06/31] hw/char: QOM'ify lm32_uart.c, (continued)
- [Qemu-devel] [PULL 06/31] hw/char: QOM'ify lm32_uart.c, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 02/31] Revert "memory: Drop FlatRange.romd_mode", Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 07/31] hw/char: QOM'ify milkymist-uart.c, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 11/31] scsi: mptsas: infinite loop while fetching requests, Paolo Bonzini, 2016/05/27
- [Qemu-devel] [PULL 13/31] scsi: megasas: initialise local configuration data buffer, Paolo Bonzini, 2016/05/27
- [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 <=
- [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, 2016/05/27
- [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