From: Willy Tarreau Date: Thu, 23 Jan 2025 08:02:41 +0000 (+0100) Subject: MINOR: global: add a command-line option to enable CPU binding debugging X-Git-Tag: v3.2-dev8~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0661e79fe4dac543a210476802fd4be4fc91a78;p=thirdparty%2Fhaproxy.git MINOR: global: add a command-line option to enable CPU binding debugging 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. --- diff --git a/doc/management.txt b/doc/management.txt index 7b02b5bb5..798a627ee 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -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 diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h index e3a078b28..40b5a65b7 100644 --- a/include/haproxy/global-t.h +++ b/include/haproxy/global-t.h @@ -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 */ diff --git a/src/haproxy.c b/src/haproxy.c index f7a389ccd..b6a72e3a2 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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;