MINOR: threads/cli: display the lock history on "show threads"

This will display the lock labels and modes for each non-empty step
at the end of "show threads" when these are defined. This allows to
emit up to the last 8 locking operation for each thread on 64 bit
machines.
This commit is contained in:
Willy Tarreau 2025-04-28 15:19:35 +02:00
parent b8a1c2380b
commit d9a659ed96
2 changed files with 18 additions and 0 deletions

View File

@ -49,6 +49,7 @@ int thread_map_to_groups();
int thread_resolve_group_mask(struct thread_set *ts, int defgrp, char **err);
void thread_detect_count(void);
int parse_thread_set(const char *arg, struct thread_set *ts, char **err);
const char *lock_label(enum lock_label label);
extern int thread_cpus_enabled_at_boot;

View File

@ -352,6 +352,23 @@ void ha_thread_dump_one(struct buffer *buf, int is_caller)
chunk_appendf(buf, " curr_task=");
ha_task_dump(buf, th_ctx->current, " ");
#if defined(USE_THREAD) && ((DEBUG_THREAD > 0) || defined(DEBUG_FULL))
/* List the lock history */
if (th_ctx->lock_history) {
int lkh, lkl;
chunk_appendf(buf, " lock_hist:");
for (lkl = 7; lkl >= 0; lkl--) {
lkh = (th_ctx->lock_history >> (lkl * 8)) & 0xff;
if (!lkh)
continue;
chunk_appendf(buf, " %c:%s",
"URSW"[lkh & 3], lock_label((lkh >> 2) - 1));
}
chunk_appendf(buf, "\n");
}
#endif
if (!(HA_ATOMIC_LOAD(&tg_ctx->threads_idle) & ti->ltid_bit)) {
/* only dump the stack of active threads */
#ifdef USE_LUA