]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: threads: move declaration of capabilities to config.h
authorWilly Tarreau <w@1wt.eu>
Wed, 10 Oct 2018 16:29:23 +0000 (18:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 10 Oct 2018 16:29:23 +0000 (18:29 +0200)
In commit f161d0f51 ("BUG/MINOR: pools/threads: don't ignore DEBUG_UAF
on double-word CAS capable archs") I moved some defines and accidently
messed up with lockfree pools. The problem is that the HA_HAVE_CAS_DW
macro is not defined anymore where the CONFIG_HAP_LOCKLESS_POOLS macro
is set, so this fix implicitly disabled lockfree pools.

This patch fixes this by moving the capabilities definition to config.h
(probably that we'd benefit from having an "arch.h" file to declare the
capabilities offered by the architecture). In a test on a 12-core machine,
we used to measure 19s spent in the pool lock for 1M requests without
this patch, and 0 with it so that's definitely a net saving.

No backport is required, this is only for 1.9.

include/common/config.h
include/common/hathreads.h

index acd6b202b42762f28ec811a87bea4ad43ced8b7d..47ff18c03d2cb1dd5fcc286dff71547fef7db475 100644 (file)
 #define THREAD_LOCAL
 #endif
 
+/* Some architectures have a double-word CAS, sometimes even dual-8 bytes */
+#if defined(__x86_64__) || defined (__aarch64__)
+#define HA_HAVE_CAS_DW
+#define HA_CAS_IS_8B
+#elif defined(__arm__) && (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__))
+#define HA_HAVE_CAS_DW
+#endif
+
 /* On architectures supporting threads and double-word CAS, we can implement
  * lock-less memory pools. This isn't supported for debugging modes however.
  */
-#if !defined(DEBUG_NO_LOCKLESS_POOLS) && defined(USE_THREAD) && defined(HA_HAVE_CAS_DW) && !defined(DEBUG_UAF)
+#if defined(USE_THREAD) && defined(HA_HAVE_CAS_DW) && !defined(DEBUG_NO_LOCKLESS_POOLS) && !defined(DEBUG_UAF)
 #define CONFIG_HAP_LOCKLESS_POOLS
 #endif
 
index 01b218165eecaf504a3215e88cd8ab4cb4c1c88c..1f3fe8dd6081a93b3d8d9e5d96acdbf769eb5dbb 100644 (file)
@@ -816,8 +816,7 @@ static inline void __spin_unlock(enum lock_label lbl, struct ha_spinlock *l,
 #endif  /* DEBUG_THREAD */
 
 #ifdef __x86_64__
-#define HA_HAVE_CAS_DW 1
-#define HA_CAS_IS_8B
+
 static __inline int
 __ha_cas_dw(void *target, void *compare, const void *set)
 {
@@ -855,7 +854,7 @@ __ha_barrier_full(void)
 }
 
 #elif defined(__arm__) && (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__))
-#define HA_HAVE_CAS_DW 1
+
 static __inline void
 __ha_barrier_load(void)
 {
@@ -896,8 +895,6 @@ static __inline int __ha_cas_dw(void *target, void *compare, const void *set)
 }
 
 #elif defined (__aarch64__)
-#define HA_HAVE_CAS_DW 1
-#define HA_CAS_IS_8B
 
 static __inline void
 __ha_barrier_load(void)