Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 1 | /* |
Willy Tarreau | a04ded5 | 2020-06-02 10:29:48 +0200 | [diff] [blame] | 2 | * include/haproxy/activity-t.h |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 3 | * This file contains structure declarations for activity measurements. |
| 4 | * |
Willy Tarreau | a04ded5 | 2020-06-02 10:29:48 +0200 | [diff] [blame] | 5 | * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation, version 2.1 |
| 10 | * exclusively. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
Willy Tarreau | a04ded5 | 2020-06-02 10:29:48 +0200 | [diff] [blame] | 22 | #ifndef _HAPROXY_ACTIVITY_T_H |
| 23 | #define _HAPROXY_ACTIVITY_T_H |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 24 | |
Willy Tarreau | 4c7e4b7 | 2020-05-27 12:58:42 +0200 | [diff] [blame] | 25 | #include <haproxy/api-t.h> |
Willy Tarreau | 6634794 | 2020-06-01 12:18:08 +0200 | [diff] [blame] | 26 | #include <haproxy/freq_ctr-t.h> |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 27 | |
Willy Tarreau | a04ded5 | 2020-06-02 10:29:48 +0200 | [diff] [blame] | 28 | /* bit fields for the "profiling" global variable */ |
| 29 | #define HA_PROF_TASKS_OFF 0x00000000 /* per-task CPU profiling forced disabled */ |
Willy Tarreau | aa622b8 | 2021-01-28 21:44:22 +0100 | [diff] [blame] | 30 | #define HA_PROF_TASKS_AOFF 0x00000001 /* per-task CPU profiling off (automatic) */ |
| 31 | #define HA_PROF_TASKS_AON 0x00000002 /* per-task CPU profiling on (automatic) */ |
| 32 | #define HA_PROF_TASKS_ON 0x00000003 /* per-task CPU profiling forced enabled */ |
Willy Tarreau | a04ded5 | 2020-06-02 10:29:48 +0200 | [diff] [blame] | 33 | #define HA_PROF_TASKS_MASK 0x00000003 /* per-task CPU profiling mask */ |
| 34 | |
Willy Tarreau | 00dd44f | 2021-05-05 16:44:23 +0200 | [diff] [blame] | 35 | #define HA_PROF_MEMORY 0x00000004 /* memory profiling */ |
| 36 | |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 37 | /* per-thread activity reports. It's important that it's aligned on cache lines |
| 38 | * because some elements will be updated very often. Most counters are OK on |
| 39 | * 32-bit since this will be used during debugging sessions for troubleshooting |
| 40 | * in iterative mode. |
| 41 | */ |
| 42 | struct activity { |
| 43 | unsigned int loops; // complete loops in run_poll_loop() |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 44 | unsigned int wake_tasks; // active tasks prevented poll() from sleeping |
| 45 | unsigned int wake_signal; // pending signal prevented poll() from sleeping |
Willy Tarreau | e545153 | 2020-06-17 20:25:18 +0200 | [diff] [blame] | 46 | unsigned int poll_io; // number of times poll() reported I/O events |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 47 | unsigned int poll_exp; // number of times poll() sees an expired timeout (includes wake_*) |
Willy Tarreau | e406386 | 2020-06-17 20:35:33 +0200 | [diff] [blame] | 48 | unsigned int poll_drop_fd; // poller dropped a dead FD from the update list |
| 49 | unsigned int poll_dead_fd; // poller woke up with a dead FD |
| 50 | unsigned int poll_skip_fd; // poller skipped another thread's FD |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 51 | unsigned int conn_dead; // conn_fd_handler woke up on an FD indicating a dead connection |
Willy Tarreau | 7af4fa9 | 2020-06-17 20:49:49 +0200 | [diff] [blame] | 52 | unsigned int stream_calls; // calls to process_stream() |
Willy Tarreau | 394c9b4 | 2019-05-27 06:59:14 +0200 | [diff] [blame] | 53 | unsigned int ctxsw; // total number of context switches |
| 54 | unsigned int tasksw; // total number of task switches |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 55 | unsigned int empty_rq; // calls to process_runnable_tasks() with nothing for the thread |
| 56 | unsigned int long_rq; // process_runnable_tasks() left with tasks in the run queue |
| 57 | unsigned int cpust_total; // sum of half-ms stolen per thread |
Willy Tarreau | b159132 | 2020-06-29 14:17:59 +0200 | [diff] [blame] | 58 | unsigned int fd_takeover; // number of times this thread stole another one's FD |
Willy Tarreau | 4f72ec8 | 2020-06-17 19:12:43 +0200 | [diff] [blame] | 59 | ALWAYS_ALIGN(64); |
| 60 | |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 61 | struct freq_ctr cpust_1s; // avg amount of half-ms stolen over last second |
Willy Tarreau | fa1258f | 2021-04-10 23:00:53 +0200 | [diff] [blame] | 62 | struct freq_ctr cpust_15s; // avg amount of half-ms stolen over last 15s |
Willy Tarreau | baba82f | 2018-11-22 08:42:42 +0100 | [diff] [blame] | 63 | unsigned int avg_loop_us; // average run time per loop over last 1024 runs |
Willy Tarreau | 64a9c05 | 2019-04-12 15:27:17 +0200 | [diff] [blame] | 64 | unsigned int accepted; // accepted incoming connections |
Willy Tarreau | 8a03408 | 2019-02-27 10:45:55 +0100 | [diff] [blame] | 65 | unsigned int accq_pushed; // accept queue connections pushed |
| 66 | unsigned int accq_full; // accept queue connection not pushed because full |
Willy Tarreau | a8b2ce0 | 2019-05-28 17:04:16 +0200 | [diff] [blame] | 67 | unsigned int pool_fail; // failed a pool allocation |
| 68 | unsigned int buf_wait; // waited on a buffer allocation |
Willy Tarreau | d6a7850 | 2019-05-27 07:03:38 +0200 | [diff] [blame] | 69 | #if defined(DEBUG_DEV) |
| 70 | /* keep these ones at the end */ |
| 71 | unsigned int ctr0; // general purposee debug counter |
| 72 | unsigned int ctr1; // general purposee debug counter |
| 73 | unsigned int ctr2; // general purposee debug counter |
| 74 | #endif |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 75 | char __pad[0]; // unused except to check remaining room |
| 76 | char __end[0] __attribute__((aligned(64))); // align size to 64. |
| 77 | }; |
| 78 | |
Willy Tarreau | 3fb6a7b | 2021-01-28 19:19:26 +0100 | [diff] [blame] | 79 | |
| 80 | /* global profiling stats from the scheduler: each entry corresponds to a |
| 81 | * task or tasklet ->process function pointer, with a number of calls and |
| 82 | * a total time. Each entry is unique, except entry 0 which is for colliding |
| 83 | * hashes (i.e. others). All of these must be accessed atomically. |
| 84 | */ |
| 85 | struct sched_activity { |
| 86 | const void *func; |
| 87 | uint64_t calls; |
| 88 | uint64_t cpu_time; |
| 89 | uint64_t lat_time; |
| 90 | }; |
| 91 | |
Willy Tarreau | a04ded5 | 2020-06-02 10:29:48 +0200 | [diff] [blame] | 92 | #endif /* _HAPROXY_ACTIVITY_T_H */ |
Willy Tarreau | 609aad9 | 2018-11-22 08:31:09 +0100 | [diff] [blame] | 93 | |
| 94 | /* |
| 95 | * Local variables: |
| 96 | * c-indent-level: 8 |
| 97 | * c-basic-offset: 8 |
| 98 | * End: |
| 99 | */ |