Disable sys_membarrier
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 9 Sep 2015 17:16:50 +0000 (13:16 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 9 Sep 2015 17:22:03 +0000 (13:22 -0400)
sys_membarrier underwent changes between its original implementation and
its upcoming inclusion into the Linux kernel. Disable it to ensure we
do not use the ABI incorrectly.

Should the prior user-space code be built against a kernel header that
defines SYS_membarrier, and executed against that kernel, the following
scenarios may happen:

- -1 will be returned with EINVAL errno if the 2nd argument (flags) is
  non-zero (the previous ABI expected a single argument),
- (MEMBARRIER_EXPEDITED | MEMBARRIER_QUERY) defined as
  (1 << 0) | (1 << 16) will return -1 with EINVAL errno, because valid
  commands are now one-hot.

Therefore, should an incompatible user-space code try to use
sys_membarrier, it will simply think that the system does not have
membarrier support due to the negative return value upon query.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu.c

diff --git a/urcu.c b/urcu.c
index a26d38fbaca8286ffe1f6fe3bd522e5a2740a34f..624d7fcca7ff618279633f66792874649d8b2813 100644 (file)
--- a/urcu.c
+++ b/urcu.c
 #define RCU_QS_ACTIVE_ATTEMPTS 100
 
 /*
- * RCU_MEMBARRIER is only possibly available on Linux.
+ * The ABI of sys_membarrier changed after its original implementation.
+ * Disable it for now. Use RCU_MB flavor instead.
  */
-#if defined(RCU_MEMBARRIER) && defined(__linux__)
-#include <syscall.h>
-#endif
-
-/* If the headers do not support SYS_membarrier, fall back on RCU_MB */
-#ifdef SYS_membarrier
-# define membarrier(...)               syscall(SYS_membarrier, __VA_ARGS__)
-#else
-# define membarrier(...)               -ENOSYS
-#endif
+#define membarrier(...)                -ENOSYS
 
 #define MEMBARRIER_EXPEDITED           (1 << 0)
 #define MEMBARRIER_DELAYED             (1 << 1)
This page took 0.02607 seconds and 4 git commands to generate.