aboutsummaryrefslogtreecommitdiff
path: root/include/qemu
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2018-02-16 10:05:23 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2018-03-12 16:12:47 +0100
commita40161cbe9ccbcbab798c3e4d257c4bba99d153a (patch)
treefe6cc9bb0a5a3253a59d0187a5266573a2b81e16 /include/qemu
parentc8d3877e48c4f57381d72eaf8d016bff12ce2d7c (diff)
downloadqemu-a40161cbe9ccbcbab798c3e4d257c4bba99d153a.zip
qemu-a40161cbe9ccbcbab798c3e4d257c4bba99d153a.tar.gz
qemu-a40161cbe9ccbcbab798c3e4d257c4bba99d153a.tar.bz2
membarrier: add --enable-membarrier
Actually enable the global memory barriers if supported by the OS. Because only recent versions of Linux include the support, they are disabled by default. Note that it also has to be disabled for QEMU to run under Wine. Before this patch, rcutorture reports 85 ns/read for my machine, after the patch it reports 12.5 ns/read. On the other hand updates go from 50 *micro*seconds to 20 *milli*seconds. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qemu')
-rw-r--r--include/qemu/sys_membarrier.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/qemu/sys_membarrier.h b/include/qemu/sys_membarrier.h
index 9ce7f52..316e3dc 100644
--- a/include/qemu/sys_membarrier.h
+++ b/include/qemu/sys_membarrier.h
@@ -9,9 +9,19 @@
#ifndef QEMU_SYS_MEMBARRIER_H
#define QEMU_SYS_MEMBARRIER_H 1
+#ifdef CONFIG_MEMBARRIER
+/* Only block reordering at the compiler level in the performance-critical
+ * side. The slow side forces processor-level ordering on all other cores
+ * through a system call.
+ */
+extern void smp_mb_global_init(void);
+extern void smp_mb_global(void);
+#define smp_mb_placeholder() barrier()
+#else
/* Keep it simple, execute a real memory barrier on both sides. */
static inline void smp_mb_global_init(void) {}
#define smp_mb_global() smp_mb()
#define smp_mb_placeholder() smp_mb()
+#endif
#endif