diff --git a/doc/management.txt b/doc/management.txt index 99b3e5936..e71849a52 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -1788,7 +1788,9 @@ set maxconn global 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" - section of the configuration file. Please also see "show profiling". + 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. set rate-limit connections global Change the process-wide connection rate limit, which is set by the global diff --git a/src/activity.c b/src/activity.c index e0e6693b7..ffad3701d 100644 --- a/src/activity.c +++ b/src/activity.c @@ -72,8 +72,17 @@ static int cli_parse_set_profiling(char **args, char *payload, struct appctx *ap if (strcmp(args[3], "on") == 0) { unsigned int old = profiling; + int i; + while (!_HA_ATOMIC_CAS(&profiling, &old, (old & ~HA_PROF_TASKS_MASK) | HA_PROF_TASKS_ON)) ; + /* also flush current profiling stats */ + for (i = 0; i < 256; i++) { + HA_ATOMIC_STORE(&sched_activity[i].calls, 0); + HA_ATOMIC_STORE(&sched_activity[i].cpu_time, 0); + HA_ATOMIC_STORE(&sched_activity[i].lat_time, 0); + HA_ATOMIC_STORE(&sched_activity[i].func, NULL); + } } else if (strcmp(args[3], "auto") == 0) { unsigned int old = profiling;