diff --git a/Makefile b/Makefile index 768d840f3..311d01098 100644 --- a/Makefile +++ b/Makefile @@ -261,7 +261,7 @@ endif # without appearing here. Currently defined DEBUG macros include DEBUG_FULL, # DEBUG_MEM_STATS, DEBUG_DONT_SHARE_POOLS, DEBUG_FD, DEBUG_POOL_INTEGRITY, # DEBUG_NO_POOLS, DEBUG_FAIL_ALLOC, DEBUG_STRICT_ACTION=[0-3], DEBUG_HPACK, -# DEBUG_AUTH, DEBUG_SPOE, DEBUG_UAF, DEBUG_THREAD, DEBUG_STRICT, DEBUG_DEV, +# DEBUG_AUTH, DEBUG_SPOE, DEBUG_UAF, DEBUG_THREAD=0-2, DEBUG_STRICT, DEBUG_DEV, # DEBUG_TASK, DEBUG_MEMORY_POOLS, DEBUG_POOL_TRACING, DEBUG_QPACK, DEBUG_LIST, # DEBUG_COUNTERS=[0-2], DEBUG_STRESS, DEBUG_UNIT. DEBUG = diff --git a/include/haproxy/defaults.h b/include/haproxy/defaults.h index c08b48e1d..7b6b6ec0d 100644 --- a/include/haproxy/defaults.h +++ b/include/haproxy/defaults.h @@ -594,6 +594,11 @@ # define DEBUG_STRICT 1 #endif +/* Let's make DEBUG_THREAD default to 0, and make sure it has a value */ +#ifndef DEBUG_THREAD +# define DEBUG_THREAD 0 +#endif + /* Let's make DEBUG_COUNTERS default to 1 to have glitches counters by default */ #ifndef DEBUG_COUNTERS # define DEBUG_COUNTERS 1 diff --git a/include/haproxy/thread-t.h b/include/haproxy/thread-t.h index f1e7895a5..4539742b4 100644 --- a/include/haproxy/thread-t.h +++ b/include/haproxy/thread-t.h @@ -41,7 +41,7 @@ #define __decl_rwlock(lock) #define __decl_aligned_rwlock(lock) -#elif !defined(DEBUG_THREAD) && !defined(DEBUG_FULL) +#elif (DEBUG_THREAD < 1) && !defined(DEBUG_FULL) /************** THREADS ENABLED WITHOUT DEBUGGING **************/ @@ -98,7 +98,7 @@ /* When thread debugging is enabled, we remap HA_SPINLOCK_T and HA_RWLOCK_T to * complex structures which embed debugging info. */ -#if !defined(DEBUG_THREAD) && !defined(DEBUG_FULL) +#if (DEBUG_THREAD < 1) && !defined(DEBUG_FULL) #define HA_SPINLOCK_T __HA_SPINLOCK_T #define HA_RWLOCK_T __HA_RWLOCK_T diff --git a/include/haproxy/thread.h b/include/haproxy/thread.h index 6ba6602cc..af449a6f7 100644 --- a/include/haproxy/thread.h +++ b/include/haproxy/thread.h @@ -305,7 +305,7 @@ static inline unsigned long thread_isolated() return _HA_ATOMIC_LOAD(&isolated_thread) == tid; } -#if !defined(DEBUG_THREAD) && !defined(DEBUG_FULL) +#if (DEBUG_THREAD < 1) && !defined(DEBUG_FULL) /* Thread debugging is DISABLED, these are the regular locking functions */ @@ -335,7 +335,7 @@ static inline unsigned long thread_isolated() #define HA_RWLOCK_TRYRDTOSK(lbl,l) (!pl_try_rtos(l)) /* R -?> S */ #define HA_RWLOCK_TRYRDTOWR(lbl, l) (!pl_try_rtow(l)) /* R -?> W */ -#else /* !defined(DEBUG_THREAD) && !defined(DEBUG_FULL) */ +#else /* (DEBUG_THREAD < 1) && !defined(DEBUG_FULL) */ /* Thread debugging is ENABLED, these are the instrumented functions */ diff --git a/src/thread.c b/src/thread.c index ef98648f2..caaf7c25c 100644 --- a/src/thread.c +++ b/src/thread.c @@ -260,7 +260,7 @@ void wait_for_threads_completion() for (i = 1; i < global.nbthread; i++) pthread_join(ha_pthread[i], NULL); -#if defined(DEBUG_THREAD) || defined(DEBUG_FULL) +#if (DEBUG_THREAD > 0) || defined(DEBUG_FULL) show_lock_stats(); #endif } @@ -392,7 +392,7 @@ static int thread_cpus_enabled() /* Below come the lock-debugging functions */ -#if defined(DEBUG_THREAD) || defined(DEBUG_FULL) +#if (DEBUG_THREAD > 0) || defined(DEBUG_FULL) struct lock_stat lock_stats_rd[LOCK_LABELS] = { }; struct lock_stat lock_stats_sk[LOCK_LABELS] = { }; @@ -1140,7 +1140,7 @@ void __spin_unlock(enum lock_label lbl, struct ha_spinlock *l, HA_ATOMIC_INC(&lock_stats_sk[lbl].num_unlocked); } -#endif // defined(DEBUG_THREAD) || defined(DEBUG_FULL) +#endif // (DEBUG_THREAD > 0) || defined(DEBUG_FULL) #if defined(USE_PTHREAD_EMULATION)