summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-04-14 22:10:27 +0200
committerRichard Braun <rbraun@sceen.net>2018-04-14 22:33:52 +0200
commit32a436158554923171d5c2bf7e160290e008436a (patch)
treeb17e0d4d871bcb6b91c47c217de8ee0f1d056672
parentd4a39d61e853f570ec8d599e9500a80b035fb61f (diff)
kern/atomic: fix consume memory order
The consume memory order is known to be problematic in the C11 specification, and as a result, most compilers alias it to acquire. Based on the assumption that the kernel doesn't run on architectures with an Alpha-like memory model, the consume memory order was aliased to relaxed, letting the CPU identify data dependencies. But there may also be issues at compile time, making this hack is dangerous. As a result, the actual consume memory order as implemented by the compiler is now used to define the kernel consume memory order. See https://lwn.net/Articles/588300/.
-rw-r--r--kern/atomic.h13
1 files changed, 1 insertions, 12 deletions
diff --git a/kern/atomic.h b/kern/atomic.h
index 6b4ebf3..5d99da9 100644
--- a/kern/atomic.h
+++ b/kern/atomic.h
@@ -31,20 +31,9 @@
/*
* Supported memory orders.
- *
- * Note that the consume order is aliased to relaxed. This assumes that
- * all supported processors respect data dependencies. The rationale is
- * that the definition for the consume order is confusing enough that
- * most compilers alias it to acquire, which forces the generation of
- * memory barrier instructions even when they're not really needed.
- * Since there is currently no processor where using consume or relaxed
- * would produce different code, it is safe to establish that alias.
- * It serves as explicit documentation for code review, and will easily
- * be replaced with the true consume order once compiler support becomes
- * efficient and reliable.
*/
#define ATOMIC_RELAXED __ATOMIC_RELAXED
-#define ATOMIC_CONSUME __ATOMIC_RELAXED
+#define ATOMIC_CONSUME __ATOMIC_CONSUME
#define ATOMIC_ACQUIRE __ATOMIC_ACQUIRE
#define ATOMIC_RELEASE __ATOMIC_RELEASE
#define ATOMIC_ACQ_REL __ATOMIC_ACQ_REL