]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: report the number of loops and ctxsw for each thread
authorWilly Tarreau <w@1wt.eu>
Tue, 9 Sep 2025 05:52:53 +0000 (07:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 9 Sep 2025 15:56:14 +0000 (17:56 +0200)
When multiple similar warnings are emitted, it can be difficult to know
whether only one task is looping slowly or if many are sharing the CPU.
Let's report the number of context switches and polling loop turns in
thread dumps so that warnings are easier to understand.

This should be backported to 3.2.

src/debug.c

index 0c3ecb1dc207d93d71d88b0b4f1a67982fca78dd..19acb0ed1069e86ac71902d702bb6322a5896356 100644 (file)
@@ -324,7 +324,7 @@ void ha_thread_dump_one(struct buffer *buf, int is_caller)
 
        chunk_appendf(buf,
                      "%c%cThread %-2u: id=0x%llx act=%d glob=%d wq=%d rq=%d tl=%d tlsz=%d rqsz=%d\n"
-                     "     %2u/%-2u   stuck=%d prof=%d",
+                     "     %2u/%-2u   loops=%u ctxsw=%u stuck=%d prof=%d",
                      (is_caller) ? '*' : ' ', stuck ? '>' : ' ', tid + 1,
                      ha_get_pthread_id(tid),
                      thread_has_tasks(),
@@ -338,6 +338,7 @@ void ha_thread_dump_one(struct buffer *buf, int is_caller)
                      th_ctx->tasks_in_list,
                      th_ctx->rq_total,
                      ti->tgid, ti->ltid + 1,
+                     activity[tid].loops, activity[tid].ctxsw,
                      stuck,
                      !!(th_ctx->flags & TH_FL_TASK_PROFILING));