From: Willy Tarreau Date: Thu, 17 Apr 2025 13:35:50 +0000 (+0200) Subject: CLEANUP: debug: no longer set nor use TH_FL_DUMPING_OTHERS X-Git-Tag: v3.2-dev11~13 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=874ba2afed327c61345edcb1721fbe326fef67ce;p=thirdparty%2Fhaproxy.git CLEANUP: debug: no longer set nor use TH_FL_DUMPING_OTHERS TH_FL_DUMPING_OTHERS was being used to try to perform exclusion between threads running "show threads" and those producing warnings. Now that it is much more cleanly handled, we don't need that type of protection anymore, which was adding to the complexity of the solution. Let's just get rid of it. --- diff --git a/include/haproxy/tinfo-t.h b/include/haproxy/tinfo-t.h index 229f0a4c2..f0e32534f 100644 --- a/include/haproxy/tinfo-t.h +++ b/include/haproxy/tinfo-t.h @@ -64,7 +64,7 @@ enum { #define TH_FL_SLEEPING 0x00000008 /* thread won't check its task list before next wakeup */ #define TH_FL_STARTED 0x00000010 /* set once the thread starts */ #define TH_FL_IN_LOOP 0x00000020 /* set only inside the polling loop */ -#define TH_FL_DUMPING_OTHERS 0x00000040 /* thread currently dumping other threads */ +/* unused 0x00000040 */ #define TH_FL_IN_SIG_HANDLER 0x00000080 /* thread currently in the generic signal handler */ #define TH_FL_IN_DBG_HANDLER 0x00000100 /* thread currently in the debug signal handler */ #define TH_FL_IN_WDT_HANDLER 0x00000200 /* thread currently in the wdt signal handler */ diff --git a/src/debug.c b/src/debug.c index 93372ce01..9daf2b0e1 100644 --- a/src/debug.c +++ b/src/debug.c @@ -401,18 +401,6 @@ struct buffer *ha_thread_dump_fill(struct buffer *buf, int thr) /* silence bogus warning in gcc 11 without threads */ ASSUME(0 <= thr && thr < MAX_THREADS); - /* A thread that's currently dumping other threads cannot be dumped, or - * it will very likely cause a deadlock. - */ - if (HA_ATOMIC_LOAD(&ha_thread_ctx[thr].flags) & TH_FL_DUMPING_OTHERS) - return NULL; - - /* This will be undone in ha_thread_dump_done(). We're using an atomic - * OR to also block any possible re-entrance. - */ - if (HA_ATOMIC_FETCH_OR(&th_ctx->flags, TH_FL_DUMPING_OTHERS) & TH_FL_DUMPING_OTHERS) - return NULL; - if (thr != tid) { struct buffer *old = NULL; @@ -435,11 +423,8 @@ struct buffer *ha_thread_dump_fill(struct buffer *buf, int thr) buf = HA_ATOMIC_LOAD(&ha_thread_ctx[thr].thread_dump_buffer); if ((ulong)buf & 0x1) break; - if (!buf) { - /* cancelled: no longer dumping */ - HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_DUMPING_OTHERS); + if (!buf) return buf; - } ha_thread_relax(); } } @@ -486,8 +471,6 @@ void ha_thread_dump_done(int thr) continue; } } while (!HA_ATOMIC_CAS(&ha_thread_ctx[thr].thread_dump_buffer, &old, NULL)); - - HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_DUMPING_OTHERS); } /* dumps into the buffer some information related to task (which may diff --git a/src/haproxy.c b/src/haproxy.c index 6888e886e..a663fa638 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2857,9 +2857,6 @@ void run_poll_loop() /* Process a few tasks */ process_runnable_tasks(); - /* If this happens this is an accidental leak */ - BUG_ON(HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_DUMPING_OTHERS); - /* also stop if we failed to cleanly stop all tasks */ if (killed > 1) break; diff --git a/src/wdt.c b/src/wdt.c index fa600d6fa..0a17991dd 100644 --- a/src/wdt.c +++ b/src/wdt.c @@ -99,15 +99,13 @@ void wdt_handler(int sig, siginfo_t *si, void *arg) if (!p) goto update_and_leave; - if ((_HA_ATOMIC_LOAD(&ha_thread_ctx[thr].flags) & (TH_FL_SLEEPING|TH_FL_DUMPING_OTHERS)) || + if ((_HA_ATOMIC_LOAD(&ha_thread_ctx[thr].flags) & TH_FL_SLEEPING) || (_HA_ATOMIC_LOAD(&ha_tgroup_ctx[tgrp-1].threads_harmless) & thr_bit)) { /* This thread is currently doing exactly nothing * waiting in the poll loop (unlikely but possible), * waiting for all other threads to join the rendez-vous * point (common), or waiting for another thread to - * finish an isolated operation (unlikely but possible), - * or waiting for another thread to finish dumping its - * stack. + * finish an isolated operation (unlikely but possible). */ goto update_and_leave; }