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.
This commit is contained in:
Willy Tarreau 2025-01-23 09:02:41 +01:00
parent 94543d7b65
commit f0661e79fe
3 changed files with 14 additions and 0 deletions

View 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

View 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 */

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