FD.io VPP
v19.01.3-6-g70449b9b9
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
30
#define foreach_perfmon_event \
31
_(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, "cpu-cycles") \
32
_(PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, "instructions") \
33
_(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES, \
34
"cache-references") \
35
_(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES, "cache-misses") \
36
_(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS, "branches") \
37
_(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES, "branch-misses") \
38
_(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES, "bus-cycles") \
39
_(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, \
40
"stall-frontend") \
41
_(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, \
42
"stall-backend") \
43
_(PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, "ref-cpu-cycles") \
44
_(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS, "page-faults") \
45
_(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES, "context-switches") \
46
_(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS, "cpu-migrations") \
47
_(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN, "minor-pagefaults") \
48
_(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ, "major-pagefaults") \
49
_(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS, "emulation-faults")
50
51
typedef
struct
52
{
53
char
*
name
;
54
int
pe_type
;
55
int
pe_config
;
56
}
perfmon_event_config_t
;
57
58
typedef
enum
59
{
60
PERFMON_STATE_OFF
= 0,
61
PERFMON_STATE_RUNNING
,
62
}
perfmon_state_t
;
63
64
typedef
struct
65
{
66
u8
*
thread_and_node_name
;
67
u8
**
counter_names
;
68
u64
*
counter_values
;
69
u64
*
vectors_this_counter
;
70
}
perfmon_capture_t
;
71
72
typedef
struct
73
{
74
u32
cpuid
;
75
const
char
**
table
;
76
}
perfmon_cpuid_and_table_t
;
77
78
typedef
struct
79
{
80
u8
*
name
;
81
u8
*
value
;
82
}
name_value_pair_t
;
83
84
typedef
struct
85
{
86
/* API message ID base */
87
u16
msg_id_base
;
88
89
/* on/off switch for the periodic function */
90
volatile
u8
state
;
91
92
/* capture pool, hash table */
93
perfmon_capture_t
*
capture_pool
;
94
uword
*
capture_by_thread_and_node_name
;
95
96
/* CPU-specific event tables, hash table of selected table (if any) */
97
perfmon_cpuid_and_table_t
*
perfmon_tables
;
98
uword
*
perfmon_table
;
99
100
/* vector of events to collect */
101
perfmon_event_config_t
*
events_to_collect
;
102
103
/* Base indices of synthetic event tuples */
104
u32
ipc_event_index
;
105
u32
mispredict_event_index
;
106
107
/* Length of time to capture a single event */
108
f64
timeout_interval
;
109
110
/* Current event (index) being collected */
111
u32
current_event
;
112
u32
*
rdpmc_indices
;
113
/* mmap base / size of (mapped) struct perf_event_mmap_page */
114
u8
**
perf_event_pages
;
115
u32
page_size
;
116
117
/* Current perf_event file descriptors, per thread */
118
int
*
pm_fds
;
119
120
/* Logging */
121
vlib_log_class_t
log_class
;
122
123
/* convenience */
124
vlib_main_t
*
vlib_main
;
125
vnet_main_t
*
vnet_main
;
126
ethernet_main_t
*
ethernet_main
;
127
}
perfmon_main_t
;
128
129
extern
perfmon_main_t
perfmon_main
;
130
131
extern
vlib_node_registration_t
perfmon_periodic_node
;
132
uword
*
perfmon_parse_table
(
perfmon_main_t
* pm,
char
*path,
char
*filename);
133
134
/* Periodic function events */
135
#define PERFMON_START 1
136
137
#endif
/* __included_perfmon_h__ */
138
139
/*
140
* fd.io coding-style-patch-verification: ON
141
*
142
* Local Variables:
143
* eval: (c-set-style "gnu")
144
* End:
145
*/
perfmon_main_t::capture_pool
perfmon_capture_t * capture_pool
Definition:
perfmon.h:93
perfmon_main_t::state
volatile u8 state
Definition:
perfmon.h:90
perfmon_main_t::current_event
u32 current_event
Definition:
perfmon.h:111
perfmon_main_t::timeout_interval
f64 timeout_interval
Definition:
perfmon.h:108
perfmon_event_config_t::pe_config
int pe_config
Definition:
perfmon.h:55
vlib_log_class_t
u32 vlib_log_class_t
Definition:
log.h:21
perfmon_cpuid_and_table_t::cpuid
u32 cpuid
Definition:
perfmon.h:74
perfmon_capture_t::vectors_this_counter
u64 * vectors_this_counter
Definition:
perfmon.h:69
perfmon_main_t::ethernet_main
ethernet_main_t * ethernet_main
Definition:
perfmon.h:126
perfmon_main_t::events_to_collect
perfmon_event_config_t * events_to_collect
Definition:
perfmon.h:101
u64
unsigned long u64
Definition:
types.h:89
perfmon_event_config_t
Definition:
perfmon.h:51
PERFMON_STATE_OFF
Definition:
perfmon.h:60
perfmon_periodic_node
vlib_node_registration_t perfmon_periodic_node
(constructor) VLIB_REGISTER_NODE (perfmon_periodic_node)
Definition:
perfmon_periodic.c:419
perfmon_main_t::mispredict_event_index
u32 mispredict_event_index
Definition:
perfmon.h:105
perfmon_main_t::vlib_main
vlib_main_t * vlib_main
Definition:
perfmon.h:124
perfmon_main_t::msg_id_base
u16 msg_id_base
Definition:
perfmon.h:87
name_value_pair_t
Definition:
perfmon.h:78
perfmon_main_t::rdpmc_indices
u32 * rdpmc_indices
Definition:
perfmon.h:112
ip.h
perfmon_parse_table
uword * perfmon_parse_table(perfmon_main_t *pm, char *path, char *filename)
Definition:
parse_util.c:46
u8
unsigned char u8
Definition:
types.h:56
hash.h
f64
double f64
Definition:
types.h:142
perfmon_main_t::perfmon_table
uword * perfmon_table
Definition:
perfmon.h:98
perfmon_main
perfmon_main_t perfmon_main
Definition:
perfmon.c:27
name_value_pair_t::value
u8 * value
Definition:
perfmon.h:81
perfmon_capture_t::thread_and_node_name
u8 * thread_and_node_name
Definition:
perfmon.h:66
ethernet_main_t
Definition:
ethernet.h:290
u32
unsigned int u32
Definition:
types.h:88
perfmon_event_config_t::pe_type
int pe_type
Definition:
perfmon.h:54
perfmon_capture_t
Definition:
perfmon.h:64
perfmon_main_t::vnet_main
vnet_main_t * vnet_main
Definition:
perfmon.h:125
ethernet.h
perfmon_capture_t::counter_names
u8 ** counter_names
Definition:
perfmon.h:67
name_value_pair_t::name
u8 * name
Definition:
perfmon.h:80
perfmon_event_config_t::name
char * name
Definition:
perfmon.h:53
u16
unsigned short u16
Definition:
types.h:57
perfmon_cpuid_and_table_t
Definition:
perfmon.h:72
perfmon_cpuid_and_table_t::table
const char ** table
Definition:
perfmon.h:75
perfmon_state_t
perfmon_state_t
Definition:
perfmon.h:58
perfmon_main_t::log_class
vlib_log_class_t log_class
Definition:
perfmon.h:121
vnet.h
perfmon_main_t::pm_fds
int * pm_fds
Definition:
perfmon.h:118
perfmon_main_t::perf_event_pages
u8 ** perf_event_pages
Definition:
perfmon.h:114
perfmon_main_t::perfmon_tables
perfmon_cpuid_and_table_t * perfmon_tables
Definition:
perfmon.h:97
vnet_main_t
Definition:
vnet.h:51
perfmon_main_t::ipc_event_index
u32 ipc_event_index
Definition:
perfmon.h:104
perfmon_main_t::capture_by_thread_and_node_name
uword * capture_by_thread_and_node_name
Definition:
perfmon.h:94
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
PERFMON_STATE_RUNNING
Definition:
perfmon.h:61
perfmon_capture_t::counter_values
u64 * counter_values
Definition:
perfmon.h:68
vlib_main_t
Definition:
main.h:61
uword
u64 uword
Definition:
types.h:112
perfmon_main_t::page_size
u32 page_size
Definition:
perfmon.h:115
error.h
perfmon_main_t
Definition:
perfmon.h:84
log.h
src
plugins
perfmon
perfmon.h
Generated on Sun Dec 8 2019 18:02:18 for FD.io VPP by
1.8.13