]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: debug: no longer set nor use TH_FL_DUMPING_OTHERS
authorWilly Tarreau <w@1wt.eu>
Thu, 17 Apr 2025 13:35:50 +0000 (15:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Apr 2025 14:25:47 +0000 (16:25 +0200)
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.

include/haproxy/tinfo-t.h
src/debug.c
src/haproxy.c
src/wdt.c

index 229f0a4c2682c76f12f4762d599dd1eeb14ddc52..f0e32534f1fe115e278415dd6fac6579c058a959 100644 (file)
@@ -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 */
index 93372ce01915573d03c5bccfc55a9176c5419c2c..9daf2b0e17168bc83ea71d5e741d5f26fbe53e98 100644 (file)
@@ -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 <task> (which may
index 6888e886e7f820a73aa7f28515eb6b93aaa11678..a663fa638ee3a615b64fd7c62021445a3d84e912 100644 (file)
@@ -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;
index fa600d6fab0150ddb44535507460ce4881e2fef3..0a17991dd0b229282986e5c661399f609ff30018 100644 (file)
--- 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;
                }