FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
perfmon.h
Go to the documentation of this file.
1 /*
2  * perfmon.h - performance monitor
3  *
4  * Copyright (c) 2018 Cisco Systems and/or its affiliates
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef __included_perfmon_h__
18 #define __included_perfmon_h__
19 
20 #include <vnet/vnet.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/ethernet/ethernet.h>
23 #include <vlib/log.h>
24 
25 #include <vppinfra/hash.h>
26 #include <vppinfra/error.h>
27 
28 #include <linux/perf_event.h>
29 #include <perfmon/perfmon_intel.h>
30 
31 #define foreach_perfmon_event \
32 _(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, "cpu-cycles") \
33 _(PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, "instructions") \
34 _(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES, \
35  "cache-references") \
36 _(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES, "cache-misses") \
37 _(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS, "branches") \
38  _(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES, "branch-misses") \
39 _(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES, "bus-cycles") \
40 _(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, \
41  "stall-frontend") \
42 _(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, \
43  "stall-backend") \
44 _(PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, "ref-cpu-cycles") \
45 _(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS, "page-faults") \
46 _(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES, "context-switches") \
47 _(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS, "cpu-migrations") \
48 _(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN, "minor-pagefaults") \
49 _(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ, "major-pagefaults") \
50 _(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS, "emulation-faults")
51 
52 typedef struct
53 {
54  char *name;
55  int pe_type;
56  int pe_config;
58 
59 typedef enum
60 {
64 
65 typedef struct
66 {
72 
73 typedef struct
74 {
75  u8 *name;
78 
79 typedef struct
80 {
81  /* API message ID base */
83 
84  /* on/off switch for the periodic function */
85  volatile u8 state;
86 
87  /* capture pool, hash table */
90 
91  /* vector of registered perfmon tables */
93 
94  /* active table */
96 
98 
99  /* vector of single events to collect */
101 
102  /* vector of paired events to collect */
104 
105  /* Base indices of synthetic event tuples */
108 
109  /* Length of time to capture a single event */
111 
112  /* Current event (index) being collected */
114  int n_active;
116  /* mmap base / size of (mapped) struct perf_event_mmap_page */
119 
120  /* Current perf_event file descriptors, per thread */
121  int **pm_fds;
122 
123  /* thread bitmap */
125 
126  /* Logging */
128 
129  /* convenience */
134 
136 
138 uword *perfmon_parse_table (perfmon_main_t * pm, char *path, char *filename);
139 
140 /* Periodic function events */
141 #define PERFMON_START 1
142 
143 #endif /* __included_perfmon_h__ */
144 
145 /*
146  * fd.io coding-style-patch-verification: ON
147  *
148  * Local Variables:
149  * eval: (c-set-style "gnu")
150  * End:
151  */
perfmon_capture_t * capture_pool
Definition: perfmon.h:88
u32 ** rdpmc_indices
Definition: perfmon.h:115
volatile u8 state
Definition: perfmon.h:85
u32 current_event
Definition: perfmon.h:113
f64 timeout_interval
Definition: perfmon.h:110
u64 * vectors_this_counter
Definition: perfmon.h:70
ethernet_main_t * ethernet_main
Definition: perfmon.h:132
int ** pm_fds
Definition: perfmon.h:121
perfmon_event_config_t * paired_events_to_collect
Definition: perfmon.h:103
unsigned long u64
Definition: types.h:89
vlib_node_registration_t perfmon_periodic_node
(constructor) VLIB_REGISTER_NODE (perfmon_periodic_node)
u32 mispredict_event_index
Definition: perfmon.h:107
vlib_main_t * vlib_main
Definition: perfmon.h:130
u16 msg_id_base
Definition: perfmon.h:82
uword * perfmon_parse_table(perfmon_main_t *pm, char *path, char *filename)
unsigned char u8
Definition: types.h:56
double f64
Definition: types.h:142
u32 vlib_log_class_t
Definition: vlib.h:51
perfmon_main_t perfmon_main
Definition: perfmon.c:28
u8 * thread_and_node_name
Definition: perfmon.h:67
unsigned int u32
Definition: types.h:88
vnet_main_t * vnet_main
Definition: perfmon.h:131
u8 ** counter_names
Definition: perfmon.h:68
unsigned short u16
Definition: types.h:57
uword * pmc_event_by_name
Definition: perfmon.h:97
perfmon_intel_pmc_event_t * perfmon_table
Definition: perfmon.h:95
perfmon_state_t
Definition: perfmon.h:59
vlib_log_class_t log_class
Definition: perfmon.h:127
perfmon_event_config_t * single_events_to_collect
Definition: perfmon.h:100
u32 ipc_event_index
Definition: perfmon.h:106
uword * capture_by_thread_and_node_name
Definition: perfmon.h:89
struct _vlib_node_registration vlib_node_registration_t
uword * thread_bitmap
Definition: perfmon.h:124
u8 *** perf_event_pages
Definition: perfmon.h:117
u64 * counter_values
Definition: perfmon.h:69
perfmon_intel_pmc_registration_t * perfmon_tables
Definition: perfmon.h:92
u64 uword
Definition: types.h:112