Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 2 | #ifndef __PERF_RECORD_H |
| 3 | #define __PERF_RECORD_H |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 4 | |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 5 | #include <limits.h> |
Arnaldo Carvalho de Melo | 482ad89 | 2011-12-02 11:06:37 -0200 | [diff] [blame] | 6 | #include <stdio.h> |
Arnaldo Carvalho de Melo | e8b3ae4 | 2017-04-19 21:33:07 -0300 | [diff] [blame] | 7 | #include <linux/kernel.h> |
Song Liu | 9aa0bfa | 2019-01-17 08:15:17 -0800 | [diff] [blame] | 8 | #include <linux/bpf.h> |
Arnaldo Carvalho de Melo | 514c540 | 2019-03-27 15:22:52 -0300 | [diff] [blame] | 9 | #include <linux/perf_event.h> |
Jiri Olsa | 1345e2e | 2019-08-25 20:17:41 +0200 | [diff] [blame] | 10 | #include <perf/event.h> |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 11 | |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 12 | #include "../perf.h" |
Jiri Olsa | 4383db8 | 2012-10-27 23:18:29 +0200 | [diff] [blame] | 13 | #include "build-id.h" |
Jiri Olsa | 0c4e774 | 2014-04-17 19:39:10 +0200 | [diff] [blame] | 14 | #include "perf_regs.h" |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 15 | |
Jiri Olsa | 1345e2e | 2019-08-25 20:17:41 +0200 | [diff] [blame] | 16 | #ifdef __LP64__ |
| 17 | /* |
| 18 | * /usr/include/inttypes.h uses just 'lu' for PRIu64, but we end up defining |
| 19 | * __u64 as long long unsigned int, and then -Werror=format= kicks in and |
| 20 | * complains of the mismatched types, so use these two special extra PRI |
| 21 | * macros to overcome that. |
| 22 | */ |
| 23 | #define PRI_lu64 "l" PRIu64 |
| 24 | #define PRI_lx64 "l" PRIx64 |
Jiri Olsa | fecb410 | 2019-08-28 15:57:01 +0200 | [diff] [blame] | 25 | #define PRI_ld64 "l" PRId64 |
Jiri Olsa | 1345e2e | 2019-08-25 20:17:41 +0200 | [diff] [blame] | 26 | #else |
| 27 | #define PRI_lu64 PRIu64 |
| 28 | #define PRI_lx64 PRIx64 |
Jiri Olsa | fecb410 | 2019-08-28 15:57:01 +0200 | [diff] [blame] | 29 | #define PRI_ld64 PRId64 |
Jiri Olsa | 1345e2e | 2019-08-25 20:17:41 +0200 | [diff] [blame] | 30 | #endif |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 31 | |
Frederic Weisbecker | a285412 | 2011-05-21 19:33:04 +0200 | [diff] [blame] | 32 | #define PERF_SAMPLE_MASK \ |
| 33 | (PERF_SAMPLE_IP | PERF_SAMPLE_TID | \ |
| 34 | PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \ |
| 35 | PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \ |
Adrian Hunter | 7556257 | 2013-08-27 11:23:09 +0300 | [diff] [blame] | 36 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \ |
| 37 | PERF_SAMPLE_IDENTIFIER) |
Frederic Weisbecker | a285412 | 2011-05-21 19:33:04 +0200 | [diff] [blame] | 38 | |
Jiri Olsa | a65cb4b | 2013-10-02 15:46:39 +0200 | [diff] [blame] | 39 | /* perf sample has 16 bits size limit */ |
| 40 | #define PERF_SAMPLE_MAX_SIZE (1 << 16) |
| 41 | |
Jiri Olsa | 0f6a301 | 2012-08-07 15:20:45 +0200 | [diff] [blame] | 42 | struct regs_dump { |
Adrian Hunter | 5b95a4a3 | 2013-08-27 11:23:10 +0300 | [diff] [blame] | 43 | u64 abi; |
Jiri Olsa | 352ea45 | 2014-01-07 13:47:25 +0100 | [diff] [blame] | 44 | u64 mask; |
Jiri Olsa | 0f6a301 | 2012-08-07 15:20:45 +0200 | [diff] [blame] | 45 | u64 *regs; |
Jiri Olsa | 0c4e774 | 2014-04-17 19:39:10 +0200 | [diff] [blame] | 46 | |
| 47 | /* Cached values/mask filled by first register access. */ |
| 48 | u64 cache_regs[PERF_REGS_MAX]; |
| 49 | u64 cache_mask; |
Jiri Olsa | 0f6a301 | 2012-08-07 15:20:45 +0200 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | struct stack_dump { |
| 53 | u16 offset; |
| 54 | u64 size; |
| 55 | char *data; |
| 56 | }; |
| 57 | |
Jiri Olsa | 9ede473 | 2012-10-10 17:38:13 +0200 | [diff] [blame] | 58 | struct sample_read_value { |
| 59 | u64 value; |
| 60 | u64 id; |
| 61 | }; |
| 62 | |
| 63 | struct sample_read { |
| 64 | u64 time_enabled; |
| 65 | u64 time_running; |
| 66 | union { |
| 67 | struct { |
| 68 | u64 nr; |
| 69 | struct sample_read_value *values; |
| 70 | } group; |
| 71 | struct sample_read_value one; |
| 72 | }; |
| 73 | }; |
| 74 | |
Jiri Olsa | 0776eb5 | 2014-05-05 12:41:45 +0200 | [diff] [blame] | 75 | struct ip_callchain { |
| 76 | u64 nr; |
| 77 | u64 ips[0]; |
| 78 | }; |
| 79 | |
Arnaldo Carvalho de Melo | f1a397f | 2019-01-22 10:58:22 -0200 | [diff] [blame] | 80 | struct branch_stack; |
Jiri Olsa | 0776eb5 | 2014-05-05 12:41:45 +0200 | [diff] [blame] | 81 | |
Adrian Hunter | 00447cc | 2014-10-30 16:09:42 +0200 | [diff] [blame] | 82 | enum { |
| 83 | PERF_IP_FLAG_BRANCH = 1ULL << 0, |
| 84 | PERF_IP_FLAG_CALL = 1ULL << 1, |
| 85 | PERF_IP_FLAG_RETURN = 1ULL << 2, |
| 86 | PERF_IP_FLAG_CONDITIONAL = 1ULL << 3, |
| 87 | PERF_IP_FLAG_SYSCALLRET = 1ULL << 4, |
| 88 | PERF_IP_FLAG_ASYNC = 1ULL << 5, |
| 89 | PERF_IP_FLAG_INTERRUPT = 1ULL << 6, |
| 90 | PERF_IP_FLAG_TX_ABORT = 1ULL << 7, |
| 91 | PERF_IP_FLAG_TRACE_BEGIN = 1ULL << 8, |
| 92 | PERF_IP_FLAG_TRACE_END = 1ULL << 9, |
| 93 | PERF_IP_FLAG_IN_TX = 1ULL << 10, |
| 94 | }; |
| 95 | |
Adrian Hunter | 400ea6d | 2015-04-09 18:54:05 +0300 | [diff] [blame] | 96 | #define PERF_IP_FLAG_CHARS "bcrosyiABEx" |
| 97 | |
Adrian Hunter | 00447cc | 2014-10-30 16:09:42 +0200 | [diff] [blame] | 98 | #define PERF_BRANCH_MASK (\ |
| 99 | PERF_IP_FLAG_BRANCH |\ |
| 100 | PERF_IP_FLAG_CALL |\ |
| 101 | PERF_IP_FLAG_RETURN |\ |
| 102 | PERF_IP_FLAG_CONDITIONAL |\ |
| 103 | PERF_IP_FLAG_SYSCALLRET |\ |
| 104 | PERF_IP_FLAG_ASYNC |\ |
| 105 | PERF_IP_FLAG_INTERRUPT |\ |
| 106 | PERF_IP_FLAG_TX_ABORT |\ |
| 107 | PERF_IP_FLAG_TRACE_BEGIN |\ |
| 108 | PERF_IP_FLAG_TRACE_END) |
| 109 | |
Andi Kleen | faaa876 | 2016-10-07 16:42:26 +0300 | [diff] [blame] | 110 | #define MAX_INSN 16 |
| 111 | |
Arnaldo Carvalho de Melo | 8d50e5b | 2011-01-29 13:02:00 -0200 | [diff] [blame] | 112 | struct perf_sample { |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 113 | u64 ip; |
| 114 | u32 pid, tid; |
| 115 | u64 time; |
| 116 | u64 addr; |
| 117 | u64 id; |
| 118 | u64 stream_id; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 119 | u64 period; |
Andi Kleen | 0548429 | 2013-01-24 16:10:29 +0100 | [diff] [blame] | 120 | u64 weight; |
Andi Kleen | 475eeab | 2013-09-20 07:40:43 -0700 | [diff] [blame] | 121 | u64 transaction; |
Adrian Hunter | 61d276f | 2019-05-20 14:37:12 +0300 | [diff] [blame] | 122 | u64 insn_cnt; |
| 123 | u64 cyc_cnt; |
Arnaldo Carvalho de Melo | eed05fe | 2010-04-05 12:53:45 -0300 | [diff] [blame] | 124 | u32 cpu; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 125 | u32 raw_size; |
Stephane Eranian | 98a3b32 | 2013-01-24 16:10:35 +0100 | [diff] [blame] | 126 | u64 data_src; |
Kan Liang | 3b0a5da | 2017-08-29 13:11:08 -0400 | [diff] [blame] | 127 | u64 phys_addr; |
Adrian Hunter | bf49390 | 2014-07-31 09:01:04 +0300 | [diff] [blame] | 128 | u32 flags; |
| 129 | u16 insn_len; |
Arnaldo Carvalho de Melo | 473398a | 2016-03-22 18:23:43 -0300 | [diff] [blame] | 130 | u8 cpumode; |
Jiri Olsa | 28a0b39 | 2018-01-07 17:03:52 +0100 | [diff] [blame] | 131 | u16 misc; |
Andi Kleen | faaa876 | 2016-10-07 16:42:26 +0300 | [diff] [blame] | 132 | char insn[MAX_INSN]; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 133 | void *raw_data; |
Arnaldo Carvalho de Melo | eed05fe | 2010-04-05 12:53:45 -0300 | [diff] [blame] | 134 | struct ip_callchain *callchain; |
Roberto Agostino Vitillo | b538752 | 2012-02-09 23:21:01 +0100 | [diff] [blame] | 135 | struct branch_stack *branch_stack; |
Jiri Olsa | 0f6a301 | 2012-08-07 15:20:45 +0200 | [diff] [blame] | 136 | struct regs_dump user_regs; |
Stephane Eranian | 6a21c0b | 2014-09-24 13:48:39 +0200 | [diff] [blame] | 137 | struct regs_dump intr_regs; |
Jiri Olsa | 0f6a301 | 2012-08-07 15:20:45 +0200 | [diff] [blame] | 138 | struct stack_dump user_stack; |
Jiri Olsa | 9ede473 | 2012-10-10 17:38:13 +0200 | [diff] [blame] | 139 | struct sample_read read; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 140 | }; |
| 141 | |
Stephane Eranian | 98a3b32 | 2013-01-24 16:10:35 +0100 | [diff] [blame] | 142 | #define PERF_MEM_DATA_SRC_NONE \ |
| 143 | (PERF_MEM_S(OP, NA) |\ |
| 144 | PERF_MEM_S(LVL, NA) |\ |
| 145 | PERF_MEM_S(SNOOP, NA) |\ |
| 146 | PERF_MEM_S(LOCK, NA) |\ |
| 147 | PERF_MEM_S(TLB, NA)) |
| 148 | |
Frederic Weisbecker | 9840280 | 2010-05-02 22:05:29 +0200 | [diff] [blame] | 149 | enum perf_user_event_type { /* above any possible kernel type */ |
Thomas Gleixner | 9aefcab0 | 2010-12-07 12:48:47 +0000 | [diff] [blame] | 150 | PERF_RECORD_USER_TYPE_START = 64, |
Tom Zanussi | 2c46dbb | 2010-04-01 23:59:19 -0500 | [diff] [blame] | 151 | PERF_RECORD_HEADER_ATTR = 64, |
Kim Phillips | 1291927 | 2017-05-03 13:13:50 +0100 | [diff] [blame] | 152 | PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */ |
Tom Zanussi | 9215545 | 2010-04-01 23:59:21 -0500 | [diff] [blame] | 153 | PERF_RECORD_HEADER_TRACING_DATA = 66, |
Tom Zanussi | c7929e4 | 2010-04-01 23:59:22 -0500 | [diff] [blame] | 154 | PERF_RECORD_HEADER_BUILD_ID = 67, |
Frederic Weisbecker | 9840280 | 2010-05-02 22:05:29 +0200 | [diff] [blame] | 155 | PERF_RECORD_FINISHED_ROUND = 68, |
Adrian Hunter | 3c659ee | 2014-10-27 15:49:22 +0200 | [diff] [blame] | 156 | PERF_RECORD_ID_INDEX = 69, |
Adrian Hunter | a16ac02 | 2015-04-09 18:53:43 +0300 | [diff] [blame] | 157 | PERF_RECORD_AUXTRACE_INFO = 70, |
| 158 | PERF_RECORD_AUXTRACE = 71, |
Adrian Hunter | e9bf54d | 2015-04-09 18:53:47 +0300 | [diff] [blame] | 159 | PERF_RECORD_AUXTRACE_ERROR = 72, |
Jiri Olsa | 5f3339d | 2015-10-25 15:51:19 +0100 | [diff] [blame] | 160 | PERF_RECORD_THREAD_MAP = 73, |
Jiri Olsa | 6640b6c | 2015-10-25 15:51:23 +0100 | [diff] [blame] | 161 | PERF_RECORD_CPU_MAP = 74, |
Jiri Olsa | 374fb9e | 2015-10-25 15:51:27 +0100 | [diff] [blame] | 162 | PERF_RECORD_STAT_CONFIG = 75, |
Jiri Olsa | d80518c | 2015-10-25 15:51:30 +0100 | [diff] [blame] | 163 | PERF_RECORD_STAT = 76, |
Jiri Olsa | 2d8f0f1 | 2015-10-25 15:51:33 +0100 | [diff] [blame] | 164 | PERF_RECORD_STAT_ROUND = 77, |
Jiri Olsa | ffe77725 | 2015-10-25 15:51:36 +0100 | [diff] [blame] | 165 | PERF_RECORD_EVENT_UPDATE = 78, |
Adrian Hunter | 46bc29b | 2016-03-08 10:38:44 +0200 | [diff] [blame] | 166 | PERF_RECORD_TIME_CONV = 79, |
David Carrillo-Cisneros | e9def1b | 2017-07-17 21:25:48 -0700 | [diff] [blame] | 167 | PERF_RECORD_HEADER_FEATURE = 80, |
Alexey Budankov | 42e1fd8 | 2019-03-18 20:41:33 +0300 | [diff] [blame] | 168 | PERF_RECORD_COMPRESSED = 81, |
Tom Zanussi | 2c46dbb | 2010-04-01 23:59:19 -0500 | [diff] [blame] | 169 | PERF_RECORD_HEADER_MAX |
| 170 | }; |
| 171 | |
Adrian Hunter | 85ed472 | 2015-04-09 18:53:50 +0300 | [diff] [blame] | 172 | enum auxtrace_error_type { |
| 173 | PERF_AUXTRACE_ERROR_ITRACE = 1, |
| 174 | PERF_AUXTRACE_ERROR_MAX |
| 175 | }; |
| 176 | |
Adrian Hunter | 1405720 | 2017-06-21 13:17:19 +0300 | [diff] [blame] | 177 | /* Attribute type for custom synthesized events */ |
| 178 | #define PERF_TYPE_SYNTH (INT_MAX + 1U) |
| 179 | |
Adrian Hunter | 65c5e18 | 2017-06-30 11:36:42 +0300 | [diff] [blame] | 180 | /* Attribute config for custom synthesized events */ |
| 181 | enum perf_synth_id { |
| 182 | PERF_SYNTH_INTEL_PTWRITE, |
| 183 | PERF_SYNTH_INTEL_MWAIT, |
| 184 | PERF_SYNTH_INTEL_PWRE, |
| 185 | PERF_SYNTH_INTEL_EXSTOP, |
| 186 | PERF_SYNTH_INTEL_PWRX, |
| 187 | PERF_SYNTH_INTEL_CBR, |
| 188 | }; |
| 189 | |
| 190 | /* |
| 191 | * Raw data formats for synthesized events. Note that 4 bytes of padding are |
| 192 | * present to match the 'size' member of PERF_SAMPLE_RAW data which is always |
| 193 | * 8-byte aligned. That means we must dereference raw_data with an offset of 4. |
| 194 | * Refer perf_sample__synth_ptr() and perf_synth__raw_data(). It also means the |
| 195 | * structure sizes are 4 bytes bigger than the raw_size, refer |
| 196 | * perf_synth__raw_size(). |
| 197 | */ |
| 198 | |
| 199 | struct perf_synth_intel_ptwrite { |
| 200 | u32 padding; |
| 201 | union { |
| 202 | struct { |
| 203 | u32 ip : 1, |
| 204 | reserved : 31; |
| 205 | }; |
| 206 | u32 flags; |
| 207 | }; |
| 208 | u64 payload; |
| 209 | }; |
| 210 | |
| 211 | struct perf_synth_intel_mwait { |
| 212 | u32 padding; |
| 213 | u32 reserved; |
| 214 | union { |
| 215 | struct { |
| 216 | u64 hints : 8, |
| 217 | reserved1 : 24, |
| 218 | extensions : 2, |
| 219 | reserved2 : 30; |
| 220 | }; |
| 221 | u64 payload; |
| 222 | }; |
| 223 | }; |
| 224 | |
| 225 | struct perf_synth_intel_pwre { |
| 226 | u32 padding; |
| 227 | u32 reserved; |
| 228 | union { |
| 229 | struct { |
| 230 | u64 reserved1 : 7, |
| 231 | hw : 1, |
| 232 | subcstate : 4, |
| 233 | cstate : 4, |
| 234 | reserved2 : 48; |
| 235 | }; |
| 236 | u64 payload; |
| 237 | }; |
| 238 | }; |
| 239 | |
| 240 | struct perf_synth_intel_exstop { |
| 241 | u32 padding; |
| 242 | union { |
| 243 | struct { |
| 244 | u32 ip : 1, |
| 245 | reserved : 31; |
| 246 | }; |
| 247 | u32 flags; |
| 248 | }; |
| 249 | }; |
| 250 | |
| 251 | struct perf_synth_intel_pwrx { |
| 252 | u32 padding; |
| 253 | u32 reserved; |
| 254 | union { |
| 255 | struct { |
| 256 | u64 deepest_cstate : 4, |
| 257 | last_cstate : 4, |
| 258 | wake_reason : 4, |
| 259 | reserved1 : 52; |
| 260 | }; |
| 261 | u64 payload; |
| 262 | }; |
| 263 | }; |
| 264 | |
| 265 | struct perf_synth_intel_cbr { |
| 266 | u32 padding; |
| 267 | union { |
| 268 | struct { |
| 269 | u32 cbr : 8, |
| 270 | reserved1 : 8, |
| 271 | max_nonturbo : 8, |
| 272 | reserved2 : 8; |
| 273 | }; |
| 274 | u32 flags; |
| 275 | }; |
| 276 | u32 freq; |
| 277 | u32 reserved3; |
| 278 | }; |
| 279 | |
| 280 | /* |
| 281 | * raw_data is always 4 bytes from an 8-byte boundary, so subtract 4 to get |
| 282 | * 8-byte alignment. |
| 283 | */ |
| 284 | static inline void *perf_sample__synth_ptr(struct perf_sample *sample) |
| 285 | { |
| 286 | return sample->raw_data - 4; |
| 287 | } |
| 288 | |
| 289 | static inline void *perf_synth__raw_data(void *p) |
| 290 | { |
| 291 | return p + 4; |
| 292 | } |
| 293 | |
| 294 | #define perf_synth__raw_size(d) (sizeof(d) - 4) |
| 295 | |
| 296 | #define perf_sample__bad_synth_size(s, d) ((s)->raw_size < sizeof(d) - 4) |
| 297 | |
Arnaldo Carvalho de Melo | 4318bcb | 2014-10-10 15:46:05 -0300 | [diff] [blame] | 298 | /* |
| 299 | * The kernel collects the number of events it couldn't send in a stretch and |
| 300 | * when possible sends this number in a PERF_RECORD_LOST event. The number of |
| 301 | * such "chunks" of lost events is stored in .nr_events[PERF_EVENT_LOST] while |
| 302 | * total_lost tells exactly how many events the kernel in fact lost, i.e. it is |
Arnaldo Carvalho de Melo | 69d81f0 | 2019-08-26 19:02:31 -0300 | [diff] [blame] | 303 | * the sum of all struct perf_record_lost.lost fields reported. |
Arnaldo Carvalho de Melo | 4318bcb | 2014-10-10 15:46:05 -0300 | [diff] [blame] | 304 | * |
Kan Liang | c4937a9 | 2015-05-10 15:13:15 -0400 | [diff] [blame] | 305 | * The kernel discards mixed up samples and sends the number in a |
| 306 | * PERF_RECORD_LOST_SAMPLES event. The number of lost-samples events is stored |
| 307 | * in .nr_events[PERF_RECORD_LOST_SAMPLES] while total_lost_samples tells |
| 308 | * exactly how many samples the kernel in fact dropped, i.e. it is the sum of |
Arnaldo Carvalho de Melo | 69d81f0 | 2019-08-26 19:02:31 -0300 | [diff] [blame] | 309 | * all struct perf_record_lost_samples.lost fields reported. |
Kan Liang | c4937a9 | 2015-05-10 15:13:15 -0400 | [diff] [blame] | 310 | * |
Arnaldo Carvalho de Melo | 4318bcb | 2014-10-10 15:46:05 -0300 | [diff] [blame] | 311 | * The total_period is needed because by default auto-freq is used, so |
| 312 | * multipling nr_events[PERF_EVENT_SAMPLE] by a frequency isn't possible to get |
| 313 | * the total number of low level events, it is necessary to to sum all struct |
Arnaldo Carvalho de Melo | 69d81f0 | 2019-08-26 19:02:31 -0300 | [diff] [blame] | 314 | * perf_record_sample.period and stash the result in total_period. |
Arnaldo Carvalho de Melo | 4318bcb | 2014-10-10 15:46:05 -0300 | [diff] [blame] | 315 | */ |
| 316 | struct events_stats { |
| 317 | u64 total_period; |
| 318 | u64 total_non_filtered_period; |
| 319 | u64 total_lost; |
Kan Liang | c4937a9 | 2015-05-10 15:13:15 -0400 | [diff] [blame] | 320 | u64 total_lost_samples; |
Adrian Hunter | a38f48e | 2015-09-25 16:15:37 +0300 | [diff] [blame] | 321 | u64 total_aux_lost; |
Alexander Shishkin | 05a1f47 | 2017-03-16 18:41:59 +0200 | [diff] [blame] | 322 | u64 total_aux_partial; |
Arnaldo Carvalho de Melo | 4318bcb | 2014-10-10 15:46:05 -0300 | [diff] [blame] | 323 | u64 total_invalid_chains; |
| 324 | u32 nr_events[PERF_RECORD_HEADER_MAX]; |
| 325 | u32 nr_non_filtered_samples; |
| 326 | u32 nr_lost_warned; |
| 327 | u32 nr_unknown_events; |
| 328 | u32 nr_invalid_chains; |
| 329 | u32 nr_unknown_id; |
| 330 | u32 nr_unprocessable_samples; |
Adrian Hunter | 85ed472 | 2015-04-09 18:53:50 +0300 | [diff] [blame] | 331 | u32 nr_auxtrace_errors[PERF_AUXTRACE_ERROR_MAX]; |
Kan Liang | 930e6fc | 2015-06-17 09:51:10 -0400 | [diff] [blame] | 332 | u32 nr_proc_map_timeout; |
Arnaldo Carvalho de Melo | 4318bcb | 2014-10-10 15:46:05 -0300 | [diff] [blame] | 333 | }; |
| 334 | |
Jiri Olsa | 2d8f0f1 | 2015-10-25 15:51:33 +0100 | [diff] [blame] | 335 | enum { |
| 336 | PERF_STAT_ROUND_TYPE__INTERVAL = 0, |
| 337 | PERF_STAT_ROUND_TYPE__FINAL = 1, |
| 338 | }; |
| 339 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 340 | void perf_event__print_totals(void); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 341 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 342 | struct perf_tool; |
Jiri Olsa | 9749b90 | 2019-07-21 13:23:50 +0200 | [diff] [blame] | 343 | struct perf_thread_map; |
Jiri Olsa | f854839 | 2019-07-21 13:23:49 +0200 | [diff] [blame] | 344 | struct perf_cpu_map; |
Jiri Olsa | 6742434 | 2015-10-25 15:51:28 +0100 | [diff] [blame] | 345 | struct perf_stat_config; |
Jiri Olsa | 5796f8f | 2015-10-25 15:51:31 +0100 | [diff] [blame] | 346 | struct perf_counts_values; |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 347 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 348 | typedef int (*perf_event__handler_t)(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 349 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 350 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 351 | struct machine *machine); |
Arnaldo Carvalho de Melo | cf55311 | 2010-01-07 19:59:40 -0200 | [diff] [blame] | 352 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 353 | int perf_event__synthesize_thread_map(struct perf_tool *tool, |
Jiri Olsa | 9749b90 | 2019-07-21 13:23:50 +0200 | [diff] [blame] | 354 | struct perf_thread_map *threads, |
Arnaldo Carvalho de Melo | 7c940c1 | 2011-02-11 11:45:54 -0200 | [diff] [blame] | 355 | perf_event__handler_t process, |
Mark Drayton | 3fcb10e | 2018-12-04 12:34:20 -0800 | [diff] [blame] | 356 | struct machine *machine, bool mmap_data); |
Jiri Olsa | 99471c9 | 2015-10-25 15:51:20 +0100 | [diff] [blame] | 357 | int perf_event__synthesize_thread_map2(struct perf_tool *tool, |
Jiri Olsa | 9749b90 | 2019-07-21 13:23:50 +0200 | [diff] [blame] | 358 | struct perf_thread_map *threads, |
Jiri Olsa | 99471c9 | 2015-10-25 15:51:20 +0100 | [diff] [blame] | 359 | perf_event__handler_t process, |
| 360 | struct machine *machine); |
Jiri Olsa | 6c87290 | 2015-10-25 15:51:24 +0100 | [diff] [blame] | 361 | int perf_event__synthesize_cpu_map(struct perf_tool *tool, |
Jiri Olsa | f854839 | 2019-07-21 13:23:49 +0200 | [diff] [blame] | 362 | struct perf_cpu_map *cpus, |
Jiri Olsa | 6c87290 | 2015-10-25 15:51:24 +0100 | [diff] [blame] | 363 | perf_event__handler_t process, |
| 364 | struct machine *machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 365 | int perf_event__synthesize_threads(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 366 | perf_event__handler_t process, |
Kan Liang | 9d9cad7 | 2015-06-17 09:51:11 -0400 | [diff] [blame] | 367 | struct machine *machine, bool mmap_data, |
Kan Liang | 340b47f | 2017-09-29 07:47:54 -0700 | [diff] [blame] | 368 | unsigned int nr_threads_synthesize); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 369 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 370 | perf_event__handler_t process, |
Adrian Hunter | 0ae617b | 2014-01-29 16:14:40 +0200 | [diff] [blame] | 371 | struct machine *machine); |
Jiri Olsa | 6742434 | 2015-10-25 15:51:28 +0100 | [diff] [blame] | 372 | int perf_event__synthesize_stat_config(struct perf_tool *tool, |
| 373 | struct perf_stat_config *config, |
| 374 | perf_event__handler_t process, |
| 375 | struct machine *machine); |
Jiri Olsa | 8e38159 | 2015-10-25 15:51:29 +0100 | [diff] [blame] | 376 | void perf_event__read_stat_config(struct perf_stat_config *config, |
Jiri Olsa | 7293237 | 2019-08-28 15:57:16 +0200 | [diff] [blame^] | 377 | struct perf_record_stat_config *event); |
Jiri Olsa | 5796f8f | 2015-10-25 15:51:31 +0100 | [diff] [blame] | 378 | int perf_event__synthesize_stat(struct perf_tool *tool, |
| 379 | u32 cpu, u32 thread, u64 id, |
| 380 | struct perf_counts_values *count, |
| 381 | perf_event__handler_t process, |
| 382 | struct machine *machine); |
Jiri Olsa | d4c2259 | 2015-10-25 15:51:34 +0100 | [diff] [blame] | 383 | int perf_event__synthesize_stat_round(struct perf_tool *tool, |
| 384 | u64 time, u64 type, |
| 385 | perf_event__handler_t process, |
| 386 | struct machine *machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 387 | int perf_event__synthesize_modules(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 388 | perf_event__handler_t process, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 389 | struct machine *machine); |
| 390 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 391 | int perf_event__process_comm(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 392 | union perf_event *event, |
| 393 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 394 | struct machine *machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 395 | int perf_event__process_lost(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 396 | union perf_event *event, |
| 397 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 398 | struct machine *machine); |
Kan Liang | c4937a9 | 2015-05-10 15:13:15 -0400 | [diff] [blame] | 399 | int perf_event__process_lost_samples(struct perf_tool *tool, |
| 400 | union perf_event *event, |
| 401 | struct perf_sample *sample, |
| 402 | struct machine *machine); |
Adrian Hunter | 4a96f7a | 2015-04-30 17:37:29 +0300 | [diff] [blame] | 403 | int perf_event__process_aux(struct perf_tool *tool, |
| 404 | union perf_event *event, |
| 405 | struct perf_sample *sample, |
| 406 | struct machine *machine); |
Adrian Hunter | 0ad21f6 | 2015-04-30 17:37:30 +0300 | [diff] [blame] | 407 | int perf_event__process_itrace_start(struct perf_tool *tool, |
| 408 | union perf_event *event, |
| 409 | struct perf_sample *sample, |
| 410 | struct machine *machine); |
Adrian Hunter | 0286039 | 2015-07-21 12:44:03 +0300 | [diff] [blame] | 411 | int perf_event__process_switch(struct perf_tool *tool, |
| 412 | union perf_event *event, |
| 413 | struct perf_sample *sample, |
| 414 | struct machine *machine); |
Hari Bathini | f3b3614 | 2017-03-08 02:11:43 +0530 | [diff] [blame] | 415 | int perf_event__process_namespaces(struct perf_tool *tool, |
| 416 | union perf_event *event, |
| 417 | struct perf_sample *sample, |
| 418 | struct machine *machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 419 | int perf_event__process_mmap(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 420 | union perf_event *event, |
| 421 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 422 | struct machine *machine); |
Stephane Eranian | 5c5e854 | 2013-08-21 12:10:25 +0200 | [diff] [blame] | 423 | int perf_event__process_mmap2(struct perf_tool *tool, |
| 424 | union perf_event *event, |
| 425 | struct perf_sample *sample, |
| 426 | struct machine *machine); |
Arnaldo Carvalho de Melo | f62d3f0 | 2012-10-06 15:44:59 -0300 | [diff] [blame] | 427 | int perf_event__process_fork(struct perf_tool *tool, |
| 428 | union perf_event *event, |
| 429 | struct perf_sample *sample, |
| 430 | struct machine *machine); |
| 431 | int perf_event__process_exit(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 432 | union perf_event *event, |
| 433 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 434 | struct machine *machine); |
Song Liu | 9aa0bfa | 2019-01-17 08:15:17 -0800 | [diff] [blame] | 435 | int perf_event__process_ksymbol(struct perf_tool *tool, |
| 436 | union perf_event *event, |
| 437 | struct perf_sample *sample, |
| 438 | struct machine *machine); |
Arnaldo Carvalho de Melo | 3f604b5 | 2019-08-26 19:28:13 -0300 | [diff] [blame] | 439 | int perf_event__process_bpf(struct perf_tool *tool, |
| 440 | union perf_event *event, |
| 441 | struct perf_sample *sample, |
| 442 | struct machine *machine); |
Adrian Hunter | a8ce99b | 2018-05-22 13:54:37 +0300 | [diff] [blame] | 443 | int perf_tool__process_synth_event(struct perf_tool *tool, |
| 444 | union perf_event *event, |
| 445 | struct machine *machine, |
| 446 | perf_event__handler_t process); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 447 | int perf_event__process(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 448 | union perf_event *event, |
| 449 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 450 | struct machine *machine); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 451 | |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 452 | struct addr_location; |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 453 | |
Arnaldo Carvalho de Melo | bb3eb56 | 2016-03-22 18:39:09 -0300 | [diff] [blame] | 454 | int machine__resolve(struct machine *machine, struct addr_location *al, |
| 455 | struct perf_sample *sample); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 456 | |
Arnaldo Carvalho de Melo | b91fc39 | 2015-04-06 20:43:22 -0300 | [diff] [blame] | 457 | void addr_location__put(struct addr_location *al); |
| 458 | |
Adrian Hunter | 9b0d2d8 | 2014-07-22 16:17:39 +0300 | [diff] [blame] | 459 | struct thread; |
| 460 | |
| 461 | bool is_bts_event(struct perf_event_attr *attr); |
| 462 | bool sample_addr_correlates_sym(struct perf_event_attr *attr); |
Arnaldo Carvalho de Melo | c2740a8 | 2016-03-22 18:44:46 -0300 | [diff] [blame] | 463 | void thread__resolve(struct thread *thread, struct addr_location *al, |
| 464 | struct perf_sample *sample); |
Adrian Hunter | 9b0d2d8 | 2014-07-22 16:17:39 +0300 | [diff] [blame] | 465 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 466 | const char *perf_event__name(unsigned int id); |
Arnaldo Carvalho de Melo | c8446b9 | 2010-05-14 10:36:42 -0300 | [diff] [blame] | 467 | |
Adrian Hunter | b1cf6f6 | 2013-08-27 11:23:12 +0300 | [diff] [blame] | 468 | size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, |
Jiri Olsa | 352ea45 | 2014-01-07 13:47:25 +0100 | [diff] [blame] | 469 | u64 read_format); |
Andrew Vagin | 74eec26 | 2011-11-28 12:03:31 +0300 | [diff] [blame] | 470 | int perf_event__synthesize_sample(union perf_event *event, u64 type, |
Jiri Olsa | 352ea45 | 2014-01-07 13:47:25 +0100 | [diff] [blame] | 471 | u64 read_format, |
Adrian Hunter | 936f1f3 | 2018-01-16 15:14:52 +0200 | [diff] [blame] | 472 | const struct perf_sample *sample); |
Arnaldo Carvalho de Melo | d0dd74e | 2011-01-21 13:46:41 -0200 | [diff] [blame] | 473 | |
Namhyung Kim | e803cf9 | 2015-09-22 09:24:55 +0900 | [diff] [blame] | 474 | pid_t perf_event__synthesize_comm(struct perf_tool *tool, |
| 475 | union perf_event *event, pid_t pid, |
| 476 | perf_event__handler_t process, |
| 477 | struct machine *machine); |
| 478 | |
Hari Bathini | e907caf | 2017-03-08 02:11:51 +0530 | [diff] [blame] | 479 | int perf_event__synthesize_namespaces(struct perf_tool *tool, |
| 480 | union perf_event *event, |
| 481 | pid_t pid, pid_t tgid, |
| 482 | perf_event__handler_t process, |
| 483 | struct machine *machine); |
| 484 | |
Jiri Olsa | a18382b | 2014-01-07 13:47:20 +0100 | [diff] [blame] | 485 | int perf_event__synthesize_mmap_events(struct perf_tool *tool, |
| 486 | union perf_event *event, |
| 487 | pid_t pid, pid_t tgid, |
| 488 | perf_event__handler_t process, |
| 489 | struct machine *machine, |
Mark Drayton | 3fcb10e | 2018-12-04 12:34:20 -0800 | [diff] [blame] | 490 | bool mmap_data); |
Jiri Olsa | a18382b | 2014-01-07 13:47:20 +0100 | [diff] [blame] | 491 | |
Adrian Hunter | a8ce99b | 2018-05-22 13:54:37 +0300 | [diff] [blame] | 492 | int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, |
| 493 | perf_event__handler_t process, |
| 494 | struct machine *machine); |
| 495 | |
Arnaldo Carvalho de Melo | 482ad89 | 2011-12-02 11:06:37 -0200 | [diff] [blame] | 496 | size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp); |
| 497 | size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp); |
Stephane Eranian | 5c5e854 | 2013-08-21 12:10:25 +0200 | [diff] [blame] | 498 | size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp); |
Arnaldo Carvalho de Melo | 482ad89 | 2011-12-02 11:06:37 -0200 | [diff] [blame] | 499 | size_t perf_event__fprintf_task(union perf_event *event, FILE *fp); |
Adrian Hunter | 4a96f7a | 2015-04-30 17:37:29 +0300 | [diff] [blame] | 500 | size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp); |
Adrian Hunter | 0ad21f6 | 2015-04-30 17:37:30 +0300 | [diff] [blame] | 501 | size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp); |
Adrian Hunter | 0286039 | 2015-07-21 12:44:03 +0300 | [diff] [blame] | 502 | size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp); |
Jiri Olsa | ec7fa596 | 2015-10-25 15:51:22 +0100 | [diff] [blame] | 503 | size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp); |
Jiri Olsa | eb12a1a | 2015-10-25 15:51:26 +0100 | [diff] [blame] | 504 | size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp); |
Hari Bathini | f3b3614 | 2017-03-08 02:11:43 +0530 | [diff] [blame] | 505 | size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp); |
Song Liu | 9aa0bfa | 2019-01-17 08:15:17 -0800 | [diff] [blame] | 506 | size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp); |
Arnaldo Carvalho de Melo | 3f604b5 | 2019-08-26 19:28:13 -0300 | [diff] [blame] | 507 | size_t perf_event__fprintf_bpf(union perf_event *event, FILE *fp); |
Arnaldo Carvalho de Melo | 482ad89 | 2011-12-02 11:06:37 -0200 | [diff] [blame] | 508 | size_t perf_event__fprintf(union perf_event *event, FILE *fp); |
| 509 | |
Arnaldo Carvalho de Melo | b843f62 | 2017-04-27 21:21:09 -0300 | [diff] [blame] | 510 | int kallsyms__get_function_start(const char *kallsyms_filename, |
| 511 | const char *symbol_name, u64 *addr); |
Adrian Hunter | 29b596b | 2014-01-29 16:14:37 +0200 | [diff] [blame] | 512 | |
Jiri Olsa | f854839 | 2019-07-21 13:23:49 +0200 | [diff] [blame] | 513 | void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max); |
Jiri Olsa | 7293237 | 2019-08-28 15:57:16 +0200 | [diff] [blame^] | 514 | void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, struct perf_cpu_map *map, |
Jiri Olsa | 6c87290 | 2015-10-25 15:51:24 +0100 | [diff] [blame] | 515 | u16 type, int max); |
Arnaldo Carvalho de Melo | 5ab8c68 | 2017-04-25 15:30:47 -0300 | [diff] [blame] | 516 | |
| 517 | void event_attr_init(struct perf_event_attr *attr); |
| 518 | |
| 519 | int perf_event_paranoid(void); |
Igor Lubashev | c22e150 | 2019-08-07 10:44:14 -0400 | [diff] [blame] | 520 | bool perf_event_paranoid_check(int max_level); |
Arnaldo Carvalho de Melo | 5ab8c68 | 2017-04-25 15:30:47 -0300 | [diff] [blame] | 521 | |
| 522 | extern int sysctl_perf_event_max_stack; |
| 523 | extern int sysctl_perf_event_max_contexts_per_stack; |
Mark Drayton | 3fcb10e | 2018-12-04 12:34:20 -0800 | [diff] [blame] | 524 | extern unsigned int proc_map_timeout; |
Arnaldo Carvalho de Melo | 5ab8c68 | 2017-04-25 15:30:47 -0300 | [diff] [blame] | 525 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 526 | #endif /* __PERF_RECORD_H */ |