]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: activity: add a "memory" entry to "profiling"
authorWilly Tarreau <w@1wt.eu>
Wed, 5 May 2021 14:44:23 +0000 (16:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 May 2021 16:55:02 +0000 (18:55 +0200)
This adds the necessary flags to permit run-time enabling/disabling of
memory profiling. For now this is disabled.

A few words were added to the management doc about it and recalling that
this is limited to certain OSes.

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

index bba88c0fd60027e6611041f5621006f4daadea19..a16a86de72c77caf1039d0cd129292ebe17675f3 100644 (file)
@@ -1917,12 +1917,15 @@ set maxconn global <maxconn>
   delayed until the threshold is reached. A value of zero restores the initial
   setting.
 
-set profiling { tasks } { auto | on | off }
-  Enables or disables CPU profiling for the indicated subsystem. This is
-  equivalent to setting or clearing the "profiling" settings in the "global"
+set profiling { tasks | memory } { auto | on | off }
+  Enables or disables CPU or memory profiling for the indicated subsystem. This
+  is equivalent to setting or clearing the "profiling" settings in the "global"
   section of the configuration file. Please also see "show profiling". Note
   that manually setting the tasks profiling to "on" automatically resets the
   scheduler statistics, thus allows to check activity over a given interval.
+  The memory profiling is limited to certain operating systems (known to work
+  on the linux-glibc target), and requires USE_MEMORY_PROFILING to be set at
+  compile time.
 
 set rate-limit connections global <value>
   Change the process-wide connection rate limit, which is set by the global
index c1c16aaf8781e69a87dac1c500339c5c6ec89a40..02fd2f34e641806a6c64448bb1b1e10e4398932b 100644 (file)
@@ -32,6 +32,8 @@
 #define HA_PROF_TASKS_ON    0x00000003     /* per-task CPU profiling forced enabled */
 #define HA_PROF_TASKS_MASK  0x00000003     /* per-task CPU profiling mask */
 
+#define HA_PROF_MEMORY      0x00000004     /* memory profiling */
+
 /* per-thread activity reports. It's important that it's aligned on cache lines
  * because some elements will be updated very often. Most counters are OK on
  * 32-bit since this will be used during debugging sessions for troubleshooting
index 8ccff234bf34c6ef9a2c7bdd0b46f138de89a42c..18dd6ae5baa5294b8beb965447aa7f33b85905c2 100644 (file)
@@ -67,8 +67,12 @@ static int cli_parse_set_profiling(char **args, char *payload, struct appctx *ap
        if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
                return 1;
 
+       if (strcmp(args[2], "memory") == 0) {
+               return cli_err(appctx, "Memory profiling not compiled in.\n");
+       }
+
        if (strcmp(args[2], "tasks") != 0)
-               return cli_err(appctx, "Expects 'tasks'.\n");
+               return cli_err(appctx, "Expects etiher 'tasks' or 'memory'.\n");
 
        if (strcmp(args[3], "on") == 0) {
                unsigned int old = profiling;
@@ -146,8 +150,9 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
        qsort(tmp_activity, 256, sizeof(tmp_activity[0]), cmp_sched_activity);
 
        chunk_printf(&trash,
-                    "Per-task CPU profiling              : %s      # set profiling tasks {on|auto|off}\n",
-                    str);
+                    "Per-task CPU profiling              : %-8s      # set profiling tasks {on|auto|off}\n"
+                    "Memory usage profiling              : %-8s      # set profiling memory {on|off}\n",
+                    str, (profiling & HA_PROF_MEMORY) ? "on" : "off");
 
        chunk_appendf(&trash, "Tasks activity:\n"
                      "  function                      calls   cpu_tot   cpu_avg   lat_tot   lat_avg\n");
@@ -336,7 +341,7 @@ INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
 static struct cli_kw_list cli_kws = {{ },{
        { { "show", "profiling", NULL }, "show profiling : show CPU profiling options",   NULL, cli_io_handler_show_profiling, NULL },
        { { "show", "tasks", NULL },     "show tasks     : show running tasks",           NULL, cli_io_handler_show_tasks,     NULL },
-       { { "set",  "profiling", NULL }, "set  profiling : enable/disable CPU profiling", cli_parse_set_profiling,  NULL },
+       { { "set",  "profiling", NULL }, "set  profiling : enable/disable resource profiling", cli_parse_set_profiling,  NULL },
        {{},}
 }};