]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: global: add a command-line option to enable CPU binding debugging
authorWilly Tarreau <w@1wt.eu>
Thu, 23 Jan 2025 08:02:41 +0000 (09:02 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 14 Mar 2025 17:30:30 +0000 (18:30 +0100)
During development, everything related to CPU binding and the CPU topology
is debugged using state dumps at various places, but it does make sense to
have a real command line option so that this remains usable in production
to help users figure why some CPUs are not used by default. Let's add
"-dc" for this. Since the list of global.tune.options values is almost
full and does not 100% match this option, let's add a new "tune.debug"
field for this.

doc/management.txt
include/haproxy/global-t.h
src/haproxy.c

index 7b02b5bb570cfe04da474070110aaeed0eb6db23..798a627ee774a797e312b7f2db1ac7469091ca42 100644 (file)
@@ -394,6 +394,9 @@ list of options is :
     foreground. It is mainly used during development or during small tests, as
     Ctrl-C is enough to stop the process. Never use it in an init script.
 
+  -dc : enable CPU affinity debugging. The list of selected and evicted CPUs as
+    well as their topology will be reported before starting.
+
   -de : disable the use of the "epoll" poller. It is equivalent to the "global"
     section's keyword "noepoll". It is mostly useful when suspecting a bug
     related to this poller. On systems supporting epoll, the fallback will
index e3a078b28ab453816a7e56a1e318e5588dd7f448..40b5a65b798a49d5a6fdb3138da002e5900eb70c 100644 (file)
@@ -88,6 +88,9 @@
 #define GTUNE_QUIC_CC_HYSTART    (1<<29)
 #define GTUNE_QUIC_NO_UDP_GSO    (1<<30)
 
+/* subsystem-specific debugging options for tune.debug */
+#define GDBG_CPU_AFFINITY           (1U<< 0)
+
 #define NO_ZERO_COPY_FWD             0x0001 /* Globally disable zero-copy FF */
 #define NO_ZERO_COPY_FWD_PT          0x0002 /* disable zero-copy FF for PT (recv & send are disabled automatically) */
 #define NO_ZERO_COPY_FWD_H1_RCV      0x0004 /* disable zero-copy FF for H1 on received */
@@ -171,6 +174,7 @@ struct global {
                int max_rules_at_once; /* max number of rules excecuted in a single evaluation loop */
                int maxaccept;     /* max number of consecutive accept() */
                int options;       /* various tuning options */
+               uint debug;        /* various debugging options (GDBG_*) */
                int runqueue_depth;/* max number of tasks to run at once */
                uint recv_enough;  /* how many input bytes at once are "enough" */
                uint bufsize;      /* buffer size in bytes, defaults to BUFSIZE */
index f7a389ccde2773f54b99df72df63817e9be52851..b6a72e3a2c65d2e763a56cc78f0539705e387bf2 100644 (file)
@@ -688,6 +688,9 @@ static void usage(char *name)
 #endif
 #if defined(HA_HAVE_DUMP_LIBS)
                "        -dL dumps loaded object files after config checks\n"
+#endif
+#if defined(USE_CPU_AFFINITY)
+               "        -dc dumps the list of selected and evicted CPUs\n"
 #endif
                "        -dK{class[,...]} dump registered keywords (use 'help' for list)\n"
                "        -dr ignores server address resolution failures\n"
@@ -1492,6 +1495,10 @@ static void init_args(int argc, char **argv)
 #if defined(SO_REUSEPORT)
                        else if (*flag == 'd' && flag[1] == 'R')
                                protocol_clrf_all(PROTO_F_REUSEPORT_SUPPORTED);
+#endif
+#if defined(USE_CPU_AFFINITY)
+                       else if (*flag == 'd' && flag[1] == 'c')
+                               global.tune.debug |= GDBG_CPU_AFFINITY;
 #endif
                        else if (*flag == 'd' && flag[1] == 'F')
                                global.tune.options &= ~GTUNE_USE_FAST_FWD;