blob: 02fd2f34e641806a6c64448bb1b1e10e4398932b [file] [log] [blame]
Willy Tarreau609aad92018-11-22 08:31:09 +01001/*
Willy Tarreaua04ded52020-06-02 10:29:48 +02002 * include/haproxy/activity-t.h
Willy Tarreau609aad92018-11-22 08:31:09 +01003 * This file contains structure declarations for activity measurements.
4 *
Willy Tarreaua04ded52020-06-02 10:29:48 +02005 * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
Willy Tarreau609aad92018-11-22 08:31:09 +01006 *
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 Tarreaua04ded52020-06-02 10:29:48 +020022#ifndef _HAPROXY_ACTIVITY_T_H
23#define _HAPROXY_ACTIVITY_T_H
Willy Tarreau609aad92018-11-22 08:31:09 +010024
Willy Tarreau4c7e4b72020-05-27 12:58:42 +020025#include <haproxy/api-t.h>
Willy Tarreau66347942020-06-01 12:18:08 +020026#include <haproxy/freq_ctr-t.h>
Willy Tarreau609aad92018-11-22 08:31:09 +010027
Willy Tarreaua04ded52020-06-02 10:29:48 +020028/* bit fields for the "profiling" global variable */
29#define HA_PROF_TASKS_OFF 0x00000000 /* per-task CPU profiling forced disabled */
Willy Tarreauaa622b82021-01-28 21:44:22 +010030#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 Tarreaua04ded52020-06-02 10:29:48 +020033#define HA_PROF_TASKS_MASK 0x00000003 /* per-task CPU profiling mask */
34
Willy Tarreau00dd44f2021-05-05 16:44:23 +020035#define HA_PROF_MEMORY 0x00000004 /* memory profiling */
36
Willy Tarreau609aad92018-11-22 08:31:09 +010037/* 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 */
42struct activity {
43 unsigned int loops; // complete loops in run_poll_loop()
Willy Tarreau609aad92018-11-22 08:31:09 +010044 unsigned int wake_tasks; // active tasks prevented poll() from sleeping
45 unsigned int wake_signal; // pending signal prevented poll() from sleeping
Willy Tarreaue5451532020-06-17 20:25:18 +020046 unsigned int poll_io; // number of times poll() reported I/O events
Willy Tarreau609aad92018-11-22 08:31:09 +010047 unsigned int poll_exp; // number of times poll() sees an expired timeout (includes wake_*)
Willy Tarreaue4063862020-06-17 20:35:33 +020048 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 Tarreau609aad92018-11-22 08:31:09 +010051 unsigned int conn_dead; // conn_fd_handler woke up on an FD indicating a dead connection
Willy Tarreau7af4fa92020-06-17 20:49:49 +020052 unsigned int stream_calls; // calls to process_stream()
Willy Tarreau394c9b42019-05-27 06:59:14 +020053 unsigned int ctxsw; // total number of context switches
54 unsigned int tasksw; // total number of task switches
Willy Tarreau609aad92018-11-22 08:31:09 +010055 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 Tarreaub1591322020-06-29 14:17:59 +020058 unsigned int fd_takeover; // number of times this thread stole another one's FD
Willy Tarreau4f72ec82020-06-17 19:12:43 +020059 ALWAYS_ALIGN(64);
60
Willy Tarreau609aad92018-11-22 08:31:09 +010061 struct freq_ctr cpust_1s; // avg amount of half-ms stolen over last second
Willy Tarreaufa1258f2021-04-10 23:00:53 +020062 struct freq_ctr cpust_15s; // avg amount of half-ms stolen over last 15s
Willy Tarreaubaba82f2018-11-22 08:42:42 +010063 unsigned int avg_loop_us; // average run time per loop over last 1024 runs
Willy Tarreau64a9c052019-04-12 15:27:17 +020064 unsigned int accepted; // accepted incoming connections
Willy Tarreau8a034082019-02-27 10:45:55 +010065 unsigned int accq_pushed; // accept queue connections pushed
66 unsigned int accq_full; // accept queue connection not pushed because full
Willy Tarreaua8b2ce02019-05-28 17:04:16 +020067 unsigned int pool_fail; // failed a pool allocation
68 unsigned int buf_wait; // waited on a buffer allocation
Willy Tarreaud6a78502019-05-27 07:03:38 +020069#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 Tarreau609aad92018-11-22 08:31:09 +010075 char __pad[0]; // unused except to check remaining room
76 char __end[0] __attribute__((aligned(64))); // align size to 64.
77};
78
Willy Tarreau3fb6a7b2021-01-28 19:19:26 +010079
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 */
85struct sched_activity {
86 const void *func;
87 uint64_t calls;
88 uint64_t cpu_time;
89 uint64_t lat_time;
90};
91
Willy Tarreaua04ded52020-06-02 10:29:48 +020092#endif /* _HAPROXY_ACTIVITY_T_H */
Willy Tarreau609aad92018-11-22 08:31:09 +010093
94/*
95 * Local variables:
96 * c-indent-level: 8
97 * c-basic-offset: 8
98 * End:
99 */