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.
This commit is contained in:
Willy Tarreau 2025-09-09 07:52:53 +02:00
parent c3f94fbd9b
commit 12bc4f9c44

View 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));