MINOR: threads: turn the full lock debugging to DEBUG_THREAD=2

At level 1 it now does nothing. This is reserved for some subsequent
patches which will implement lighter debugging.
This commit is contained in:
Willy Tarreau 2025-04-28 09:05:02 +02:00
parent 903a6b14ef
commit 23371b3e7c
3 changed files with 13 additions and 11 deletions

View 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

View 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 */

View 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)