]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: threads/cli: display the lock history on "show threads"
authorWilly Tarreau <w@1wt.eu>
Mon, 28 Apr 2025 13:19:35 +0000 (15:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 28 Apr 2025 14:50:34 +0000 (16:50 +0200)
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.

include/haproxy/thread.h
src/debug.c

index e6c8e4b9d5cfc27360cffecdd93f570eefe913cb..4ed2dd677086a4a72e9eaa91874685a7915f9d6d 100644 (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;
 
 
index 9daf2b0e17168bc83ea71d5e741d5f26fbe53e98..1d6b30a7a27589b12e6c1becc5995f37b4756c40 100644 (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