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:
parent
903a6b14ef
commit
23371b3e7c
@ -98,7 +98,7 @@
|
|||||||
/* When thread debugging is enabled, we remap HA_SPINLOCK_T and HA_RWLOCK_T to
|
/* When thread debugging is enabled, we remap HA_SPINLOCK_T and HA_RWLOCK_T to
|
||||||
* complex structures which embed debugging info.
|
* 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_SPINLOCK_T __HA_SPINLOCK_T
|
||||||
#define HA_RWLOCK_T __HA_RWLOCK_T
|
#define HA_RWLOCK_T __HA_RWLOCK_T
|
||||||
|
@ -305,7 +305,7 @@ static inline unsigned long thread_isolated()
|
|||||||
return _HA_ATOMIC_LOAD(&isolated_thread) == tid;
|
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 */
|
/* 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_TRYRDTOSK(lbl,l) (!pl_try_rtos(l)) /* R -?> S */
|
||||||
#define HA_RWLOCK_TRYRDTOWR(lbl, l) (!pl_try_rtow(l)) /* R -?> W */
|
#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 */
|
/* Thread debugging is ENABLED, these are the instrumented functions */
|
||||||
|
|
||||||
|
18
src/thread.c
18
src/thread.c
@ -260,7 +260,7 @@ void wait_for_threads_completion()
|
|||||||
for (i = 1; i < global.nbthread; i++)
|
for (i = 1; i < global.nbthread; i++)
|
||||||
pthread_join(ha_pthread[i], NULL);
|
pthread_join(ha_pthread[i], NULL);
|
||||||
|
|
||||||
#if (DEBUG_THREAD > 0) || defined(DEBUG_FULL)
|
#if (DEBUG_THREAD > 1) || defined(DEBUG_FULL)
|
||||||
show_lock_stats();
|
show_lock_stats();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -394,12 +394,7 @@ static int thread_cpus_enabled()
|
|||||||
|
|
||||||
#if (DEBUG_THREAD > 0) || defined(DEBUG_FULL)
|
#if (DEBUG_THREAD > 0) || defined(DEBUG_FULL)
|
||||||
|
|
||||||
struct lock_stat lock_stats_rd[LOCK_LABELS] = { };
|
const char *lock_label(enum lock_label label)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
switch (label) {
|
switch (label) {
|
||||||
case TASK_RQ_LOCK: return "TASK_RQ";
|
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 */
|
/* only way to come here is consecutive to an internal bug */
|
||||||
abort();
|
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 */
|
/* returns the num read/seek/write for a given label by summing buckets */
|
||||||
static uint64_t get_lock_stat_num_read(int lbl)
|
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);
|
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)
|
#if defined(USE_PTHREAD_EMULATION)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user