[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 02/15] atomic.h: comment on use of atomic_read/se
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PATCH v3 02/15] atomic.h: comment on use of atomic_read/set |
Date: |
Fri, 30 Sep 2016 22:30:53 +0100 |
Add some notes on the use of the relaxed atomic access helpers and their
importance for defined behaviour in C11's multi-threaded memory model.
Signed-off-by: Alex Bennée <address@hidden>
---
include/qemu/atomic.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index c493f89..c4f6950 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -92,6 +92,12 @@
/* Weak atomic operations prevent the compiler moving other
* loads/stores past the atomic operation load/store. However there is
* no explicit memory barrier for the processor.
+ *
+ * The C11 memory model says that variables that are accessed from
+ * different threads should at least be done with __ATOMIC_RELAXED
+ * primitives or the result is undefined. Generally this has little to
+ * no effect on the generated code but not using the atomic primitives
+ * will get flagged by sanitizers as a violation.
*/
#define atomic_read(ptr) \
({ \
--
2.9.3
- [Qemu-devel] [PATCH v3 00/15] A number of fixes for ThreadSanitizer, Alex Bennée, 2016/09/30
- [Qemu-devel] [PATCH v3 01/15] atomic.h: fix __SANITIZE_THREAD__ build, Alex Bennée, 2016/09/30
- [Qemu-devel] [PATCH v3 03/15] exec-all.h: revert tb_page_addr_t to target_ulong, Alex Bennée, 2016/09/30
- [Qemu-devel] [PATCH v3 06/15] qom/object: update class cache atomically, Alex Bennée, 2016/09/30
- [Qemu-devel] [PATCH v3 02/15] atomic.h: comment on use of atomic_read/set,
Alex Bennée <=
- [Qemu-devel] [PATCH v3 04/15] tcg/optimize: move default return out of if statement, Alex Bennée, 2016/09/30
- [Qemu-devel] [PATCH v3 10/15] linux-user/syscall: extend lock around cpu-list, Alex Bennée, 2016/09/30
- [Qemu-devel] [PATCH v3 05/15] seqlock: use atomic writes for the sequence, Alex Bennée, 2016/09/30
- [Qemu-devel] [PATCH v3 08/15] cpu: atomically modify cpu->exit_request, Alex Bennée, 2016/09/30
- [Qemu-devel] [PATCH v3 07/15] qom/cpu: atomically clear the tb_jmp_cache, Alex Bennée, 2016/09/30
- [Qemu-devel] [PATCH v3 11/15] qga/command: use QEMU atomic primitives, Alex Bennée, 2016/09/30
- [Qemu-devel] [PATCH v3 12/15] .travis.yml: add gcc sanitizer build, Alex Bennée, 2016/09/30