]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: threads: turn the full lock debugging to DEBUG_THREAD=2
authorWilly Tarreau <w@1wt.eu>
Mon, 28 Apr 2025 07:05:02 +0000 (09:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 28 Apr 2025 14:50:34 +0000 (16:50 +0200)
At level 1 it now does nothing. This is reserved for some subsequent
patches which will implement lighter debugging.

include/haproxy/thread-t.h
include/haproxy/thread.h
src/thread.c

index 4539742b4831c2194d03be241a131928709bd235..8eba633d0aa0ac1d305262beda91b87c7a9cf9a4 100644 (file)
@@ -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 (DEBUG_THREAD < 1) && !defined(DEBUG_FULL)
+#if (DEBUG_THREAD < 2) && !defined(DEBUG_FULL)
 
 #define HA_SPINLOCK_T        __HA_SPINLOCK_T
 #define HA_RWLOCK_T          __HA_RWLOCK_T
index af449a6f70a5b0b53c072d32fbfd8aa73d3aaa90..f723583ab8aa26f946f4328b9ada5f8da7f530b1 100644 (file)
@@ -305,7 +305,7 @@ static inline unsigned long thread_isolated()
        return _HA_ATOMIC_LOAD(&isolated_thread) == tid;
 }
 
-#if (DEBUG_THREAD < 1) && !defined(DEBUG_FULL)
+#if (DEBUG_THREAD < 2) && !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 /* (DEBUG_THREAD < 1) && !defined(DEBUG_FULL) */
+#else /* (DEBUG_THREAD < 2) && !defined(DEBUG_FULL) */
 
 /* Thread debugging is ENABLED, these are the instrumented functions */
 
index caaf7c25c292e30d432b73311bd462f457017138..0bdb0f94d728c946e838435975a1c71c62a66906 100644 (file)
@@ -260,7 +260,7 @@ void wait_for_threads_completion()
        for (i = 1; i < global.nbthread; i++)
                pthread_join(ha_pthread[i], NULL);
 
-#if (DEBUG_THREAD > 0) || defined(DEBUG_FULL)
+#if (DEBUG_THREAD > 1) || defined(DEBUG_FULL)
        show_lock_stats();
 #endif
 }
@@ -394,12 +394,7 @@ static int thread_cpus_enabled()
 
 #if (DEBUG_THREAD > 0) || defined(DEBUG_FULL)
 
-struct lock_stat lock_stats_rd[LOCK_LABELS] = { };
-struct lock_stat lock_stats_sk[LOCK_LABELS] = { };
-struct lock_stat lock_stats_wr[LOCK_LABELS] = { };
-
-/* this is only used below */
-static const char *lock_label(enum lock_label label)
+const char *lock_label(enum lock_label label)
 {
        switch (label) {
        case TASK_RQ_LOCK:         return "TASK_RQ";
@@ -454,6 +449,13 @@ static const char *lock_label(enum lock_label label)
        /* only way to come here is consecutive to an internal bug */
        abort();
 }
+#endif
+
+#if (DEBUG_THREAD > 1) || defined(DEBUG_FULL)
+
+struct lock_stat lock_stats_rd[LOCK_LABELS] = { };
+struct lock_stat lock_stats_sk[LOCK_LABELS] = { };
+struct lock_stat lock_stats_wr[LOCK_LABELS] = { };
 
 /* returns the num read/seek/write for a given label by summing buckets */
 static uint64_t get_lock_stat_num_read(int lbl)
@@ -1140,7 +1142,7 @@ void __spin_unlock(enum lock_label lbl, struct ha_spinlock *l,
        HA_ATOMIC_INC(&lock_stats_sk[lbl].num_unlocked);
 }
 
-#endif // (DEBUG_THREAD > 0) || defined(DEBUG_FULL)
+#endif // (DEBUG_THREAD > 1) || defined(DEBUG_FULL)
 
 
 #if defined(USE_PTHREAD_EMULATION)