From 12bc4f9c44beaa1a73b16171f63182f2b8140e3b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 9 Sep 2025 07:52:53 +0200 Subject: [PATCH] MINOR: debug: report the number of loops and ctxsw for each thread 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/debug.c b/src/debug.c index 0c3ecb1dc..19acb0ed1 100644 --- a/src/debug.c +++ b/src/debug.c @@ -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));