blob: a7341e14eb4863b32c2e751172cda6af096460ff [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Ingo Molnarcdd6c482009-09-21 12:02:48 +02002#ifndef __PERF_RECORD_H
3#define __PERF_RECORD_H
John Kacur8b40f522009-09-24 18:02:18 +02004
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -02005#include <limits.h>
Arnaldo Carvalho de Melo482ad892011-12-02 11:06:37 -02006#include <stdio.h>
Arnaldo Carvalho de Meloe8b3ae42017-04-19 21:33:07 -03007#include <linux/kernel.h>
Song Liu9aa0bfa2019-01-17 08:15:17 -08008#include <linux/bpf.h>
Arnaldo Carvalho de Melo514c5402019-03-27 15:22:52 -03009#include <linux/perf_event.h>
Jiri Olsa1345e2e2019-08-25 20:17:41 +020010#include <perf/event.h>
Arnaldo Carvalho de Melo4a58e612009-12-27 21:37:00 -020011
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020012#include "../perf.h"
Jiri Olsa4383db82012-10-27 23:18:29 +020013#include "build-id.h"
Jiri Olsa0c4e7742014-04-17 19:39:10 +020014#include "perf_regs.h"
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020015
Jiri Olsa1345e2e2019-08-25 20:17:41 +020016#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 Olsafecb4102019-08-28 15:57:01 +020025#define PRI_ld64 "l" PRId64
Jiri Olsa1345e2e2019-08-25 20:17:41 +020026#else
27#define PRI_lu64 PRIu64
28#define PRI_lx64 PRIx64
Jiri Olsafecb4102019-08-28 15:57:01 +020029#define PRI_ld64 PRId64
Jiri Olsa1345e2e2019-08-25 20:17:41 +020030#endif
Frederic Weisbecker1fe2c102009-08-12 10:19:53 +020031
Frederic Weisbeckera2854122011-05-21 19:33:04 +020032#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 Hunter75562572013-08-27 11:23:09 +030036 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \
37 PERF_SAMPLE_IDENTIFIER)
Frederic Weisbeckera2854122011-05-21 19:33:04 +020038
Jiri Olsaa65cb4b2013-10-02 15:46:39 +020039/* perf sample has 16 bits size limit */
40#define PERF_SAMPLE_MAX_SIZE (1 << 16)
41
Jiri Olsa0f6a3012012-08-07 15:20:45 +020042struct regs_dump {
Adrian Hunter5b95a4a32013-08-27 11:23:10 +030043 u64 abi;
Jiri Olsa352ea452014-01-07 13:47:25 +010044 u64 mask;
Jiri Olsa0f6a3012012-08-07 15:20:45 +020045 u64 *regs;
Jiri Olsa0c4e7742014-04-17 19:39:10 +020046
47 /* Cached values/mask filled by first register access. */
48 u64 cache_regs[PERF_REGS_MAX];
49 u64 cache_mask;
Jiri Olsa0f6a3012012-08-07 15:20:45 +020050};
51
52struct stack_dump {
53 u16 offset;
54 u64 size;
55 char *data;
56};
57
Jiri Olsa9ede4732012-10-10 17:38:13 +020058struct sample_read_value {
59 u64 value;
60 u64 id;
61};
62
63struct 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 Olsa0776eb52014-05-05 12:41:45 +020075struct ip_callchain {
76 u64 nr;
77 u64 ips[0];
78};
79
Arnaldo Carvalho de Melof1a397f2019-01-22 10:58:22 -020080struct branch_stack;
Jiri Olsa0776eb52014-05-05 12:41:45 +020081
Adrian Hunter00447cc2014-10-30 16:09:42 +020082enum {
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 Hunter400ea6d2015-04-09 18:54:05 +030096#define PERF_IP_FLAG_CHARS "bcrosyiABEx"
97
Adrian Hunter00447cc2014-10-30 16:09:42 +020098#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 Kleenfaaa8762016-10-07 16:42:26 +0300110#define MAX_INSN 16
111
Arnaldo Carvalho de Melo8d50e5b2011-01-29 13:02:00 -0200112struct perf_sample {
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +0900113 u64 ip;
114 u32 pid, tid;
115 u64 time;
116 u64 addr;
117 u64 id;
118 u64 stream_id;
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +0900119 u64 period;
Andi Kleen05484292013-01-24 16:10:29 +0100120 u64 weight;
Andi Kleen475eeab2013-09-20 07:40:43 -0700121 u64 transaction;
Adrian Hunter61d276f2019-05-20 14:37:12 +0300122 u64 insn_cnt;
123 u64 cyc_cnt;
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -0300124 u32 cpu;
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +0900125 u32 raw_size;
Stephane Eranian98a3b322013-01-24 16:10:35 +0100126 u64 data_src;
Kan Liang3b0a5da2017-08-29 13:11:08 -0400127 u64 phys_addr;
Adrian Hunterbf493902014-07-31 09:01:04 +0300128 u32 flags;
129 u16 insn_len;
Arnaldo Carvalho de Melo473398a2016-03-22 18:23:43 -0300130 u8 cpumode;
Jiri Olsa28a0b392018-01-07 17:03:52 +0100131 u16 misc;
Andi Kleenfaaa8762016-10-07 16:42:26 +0300132 char insn[MAX_INSN];
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +0900133 void *raw_data;
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -0300134 struct ip_callchain *callchain;
Roberto Agostino Vitillob5387522012-02-09 23:21:01 +0100135 struct branch_stack *branch_stack;
Jiri Olsa0f6a3012012-08-07 15:20:45 +0200136 struct regs_dump user_regs;
Stephane Eranian6a21c0b2014-09-24 13:48:39 +0200137 struct regs_dump intr_regs;
Jiri Olsa0f6a3012012-08-07 15:20:45 +0200138 struct stack_dump user_stack;
Jiri Olsa9ede4732012-10-10 17:38:13 +0200139 struct sample_read read;
OGAWA Hirofumi180f95e2009-12-06 20:08:24 +0900140};
141
Stephane Eranian98a3b322013-01-24 16:10:35 +0100142#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 Weisbecker98402802010-05-02 22:05:29 +0200149enum perf_user_event_type { /* above any possible kernel type */
Thomas Gleixner9aefcab02010-12-07 12:48:47 +0000150 PERF_RECORD_USER_TYPE_START = 64,
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500151 PERF_RECORD_HEADER_ATTR = 64,
Kim Phillips12919272017-05-03 13:13:50 +0100152 PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */
Tom Zanussi92155452010-04-01 23:59:21 -0500153 PERF_RECORD_HEADER_TRACING_DATA = 66,
Tom Zanussic7929e42010-04-01 23:59:22 -0500154 PERF_RECORD_HEADER_BUILD_ID = 67,
Frederic Weisbecker98402802010-05-02 22:05:29 +0200155 PERF_RECORD_FINISHED_ROUND = 68,
Adrian Hunter3c659ee2014-10-27 15:49:22 +0200156 PERF_RECORD_ID_INDEX = 69,
Adrian Huntera16ac022015-04-09 18:53:43 +0300157 PERF_RECORD_AUXTRACE_INFO = 70,
158 PERF_RECORD_AUXTRACE = 71,
Adrian Huntere9bf54d2015-04-09 18:53:47 +0300159 PERF_RECORD_AUXTRACE_ERROR = 72,
Jiri Olsa5f3339d2015-10-25 15:51:19 +0100160 PERF_RECORD_THREAD_MAP = 73,
Jiri Olsa6640b6c2015-10-25 15:51:23 +0100161 PERF_RECORD_CPU_MAP = 74,
Jiri Olsa374fb9e2015-10-25 15:51:27 +0100162 PERF_RECORD_STAT_CONFIG = 75,
Jiri Olsad80518c2015-10-25 15:51:30 +0100163 PERF_RECORD_STAT = 76,
Jiri Olsa2d8f0f12015-10-25 15:51:33 +0100164 PERF_RECORD_STAT_ROUND = 77,
Jiri Olsaffe777252015-10-25 15:51:36 +0100165 PERF_RECORD_EVENT_UPDATE = 78,
Adrian Hunter46bc29b2016-03-08 10:38:44 +0200166 PERF_RECORD_TIME_CONV = 79,
David Carrillo-Cisnerose9def1b2017-07-17 21:25:48 -0700167 PERF_RECORD_HEADER_FEATURE = 80,
Alexey Budankov42e1fd82019-03-18 20:41:33 +0300168 PERF_RECORD_COMPRESSED = 81,
Tom Zanussi2c46dbb2010-04-01 23:59:19 -0500169 PERF_RECORD_HEADER_MAX
170};
171
Adrian Hunter85ed4722015-04-09 18:53:50 +0300172enum auxtrace_error_type {
173 PERF_AUXTRACE_ERROR_ITRACE = 1,
174 PERF_AUXTRACE_ERROR_MAX
175};
176
Adrian Hunter14057202017-06-21 13:17:19 +0300177/* Attribute type for custom synthesized events */
178#define PERF_TYPE_SYNTH (INT_MAX + 1U)
179
Adrian Hunter65c5e182017-06-30 11:36:42 +0300180/* Attribute config for custom synthesized events */
181enum 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
199struct 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
211struct 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
225struct 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
240struct 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
251struct 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
265struct 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 */
284static inline void *perf_sample__synth_ptr(struct perf_sample *sample)
285{
286 return sample->raw_data - 4;
287}
288
289static 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 Melo4318bcb2014-10-10 15:46:05 -0300298/*
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 Melo69d81f02019-08-26 19:02:31 -0300303 * the sum of all struct perf_record_lost.lost fields reported.
Arnaldo Carvalho de Melo4318bcb2014-10-10 15:46:05 -0300304 *
Kan Liangc4937a92015-05-10 15:13:15 -0400305 * 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 Melo69d81f02019-08-26 19:02:31 -0300309 * all struct perf_record_lost_samples.lost fields reported.
Kan Liangc4937a92015-05-10 15:13:15 -0400310 *
Arnaldo Carvalho de Melo4318bcb2014-10-10 15:46:05 -0300311 * 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 Melo69d81f02019-08-26 19:02:31 -0300314 * perf_record_sample.period and stash the result in total_period.
Arnaldo Carvalho de Melo4318bcb2014-10-10 15:46:05 -0300315 */
316struct events_stats {
317 u64 total_period;
318 u64 total_non_filtered_period;
319 u64 total_lost;
Kan Liangc4937a92015-05-10 15:13:15 -0400320 u64 total_lost_samples;
Adrian Huntera38f48e2015-09-25 16:15:37 +0300321 u64 total_aux_lost;
Alexander Shishkin05a1f472017-03-16 18:41:59 +0200322 u64 total_aux_partial;
Arnaldo Carvalho de Melo4318bcb2014-10-10 15:46:05 -0300323 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 Hunter85ed4722015-04-09 18:53:50 +0300331 u32 nr_auxtrace_errors[PERF_AUXTRACE_ERROR_MAX];
Kan Liang930e6fc2015-06-17 09:51:10 -0400332 u32 nr_proc_map_timeout;
Arnaldo Carvalho de Melo4318bcb2014-10-10 15:46:05 -0300333};
334
Jiri Olsa2d8f0f12015-10-25 15:51:33 +0100335enum {
336 PERF_STAT_ROUND_TYPE__INTERVAL = 0,
337 PERF_STAT_ROUND_TYPE__FINAL = 1,
338};
339
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200340void perf_event__print_totals(void);
Arnaldo Carvalho de Melo62daacb2009-11-27 16:29:22 -0200341
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200342struct perf_tool;
Jiri Olsa9749b902019-07-21 13:23:50 +0200343struct perf_thread_map;
Jiri Olsaf8548392019-07-21 13:23:49 +0200344struct perf_cpu_map;
Jiri Olsa67424342015-10-25 15:51:28 +0100345struct perf_stat_config;
Jiri Olsa5796f8f2015-10-25 15:51:31 +0100346struct perf_counts_values;
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -0200347
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200348typedef int (*perf_event__handler_t)(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200349 union perf_event *event,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200350 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200351 struct machine *machine);
Arnaldo Carvalho de Melocf553112010-01-07 19:59:40 -0200352
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200353int perf_event__synthesize_thread_map(struct perf_tool *tool,
Jiri Olsa9749b902019-07-21 13:23:50 +0200354 struct perf_thread_map *threads,
Arnaldo Carvalho de Melo7c940c12011-02-11 11:45:54 -0200355 perf_event__handler_t process,
Mark Drayton3fcb10e2018-12-04 12:34:20 -0800356 struct machine *machine, bool mmap_data);
Jiri Olsa99471c92015-10-25 15:51:20 +0100357int perf_event__synthesize_thread_map2(struct perf_tool *tool,
Jiri Olsa9749b902019-07-21 13:23:50 +0200358 struct perf_thread_map *threads,
Jiri Olsa99471c92015-10-25 15:51:20 +0100359 perf_event__handler_t process,
360 struct machine *machine);
Jiri Olsa6c872902015-10-25 15:51:24 +0100361int perf_event__synthesize_cpu_map(struct perf_tool *tool,
Jiri Olsaf8548392019-07-21 13:23:49 +0200362 struct perf_cpu_map *cpus,
Jiri Olsa6c872902015-10-25 15:51:24 +0100363 perf_event__handler_t process,
364 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200365int perf_event__synthesize_threads(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200366 perf_event__handler_t process,
Kan Liang9d9cad72015-06-17 09:51:11 -0400367 struct machine *machine, bool mmap_data,
Kan Liang340b47f2017-09-29 07:47:54 -0700368 unsigned int nr_threads_synthesize);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200369int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200370 perf_event__handler_t process,
Adrian Hunter0ae617b2014-01-29 16:14:40 +0200371 struct machine *machine);
Jiri Olsa67424342015-10-25 15:51:28 +0100372int 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 Olsa8e381592015-10-25 15:51:29 +0100376void perf_event__read_stat_config(struct perf_stat_config *config,
Jiri Olsa72932372019-08-28 15:57:16 +0200377 struct perf_record_stat_config *event);
Jiri Olsa5796f8f2015-10-25 15:51:31 +0100378int 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 Olsad4c22592015-10-25 15:51:34 +0100383int 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 Melo45694aa2011-11-28 08:30:20 -0200387int perf_event__synthesize_modules(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200388 perf_event__handler_t process,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200389 struct machine *machine);
390
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200391int perf_event__process_comm(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200392 union perf_event *event,
393 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200394 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200395int perf_event__process_lost(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200396 union perf_event *event,
397 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200398 struct machine *machine);
Kan Liangc4937a92015-05-10 15:13:15 -0400399int perf_event__process_lost_samples(struct perf_tool *tool,
400 union perf_event *event,
401 struct perf_sample *sample,
402 struct machine *machine);
Adrian Hunter4a96f7a2015-04-30 17:37:29 +0300403int perf_event__process_aux(struct perf_tool *tool,
404 union perf_event *event,
405 struct perf_sample *sample,
406 struct machine *machine);
Adrian Hunter0ad21f62015-04-30 17:37:30 +0300407int perf_event__process_itrace_start(struct perf_tool *tool,
408 union perf_event *event,
409 struct perf_sample *sample,
410 struct machine *machine);
Adrian Hunter02860392015-07-21 12:44:03 +0300411int perf_event__process_switch(struct perf_tool *tool,
412 union perf_event *event,
413 struct perf_sample *sample,
414 struct machine *machine);
Hari Bathinif3b36142017-03-08 02:11:43 +0530415int 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 Melo45694aa2011-11-28 08:30:20 -0200419int perf_event__process_mmap(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200420 union perf_event *event,
421 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200422 struct machine *machine);
Stephane Eranian5c5e8542013-08-21 12:10:25 +0200423int 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 Melof62d3f02012-10-06 15:44:59 -0300427int perf_event__process_fork(struct perf_tool *tool,
428 union perf_event *event,
429 struct perf_sample *sample,
430 struct machine *machine);
431int perf_event__process_exit(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200432 union perf_event *event,
433 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200434 struct machine *machine);
Song Liu9aa0bfa2019-01-17 08:15:17 -0800435int 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 Melo3f604b52019-08-26 19:28:13 -0300439int perf_event__process_bpf(struct perf_tool *tool,
440 union perf_event *event,
441 struct perf_sample *sample,
442 struct machine *machine);
Adrian Huntera8ce99b2018-05-22 13:54:37 +0300443int 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 Melo45694aa2011-11-28 08:30:20 -0200447int perf_event__process(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200448 union perf_event *event,
449 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200450 struct machine *machine);
Arnaldo Carvalho de Melo62daacb2009-11-27 16:29:22 -0200451
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -0200452struct addr_location;
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -0300453
Arnaldo Carvalho de Melobb3eb562016-03-22 18:39:09 -0300454int machine__resolve(struct machine *machine, struct addr_location *al,
455 struct perf_sample *sample);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -0200456
Arnaldo Carvalho de Melob91fc392015-04-06 20:43:22 -0300457void addr_location__put(struct addr_location *al);
458
Adrian Hunter9b0d2d82014-07-22 16:17:39 +0300459struct thread;
460
461bool is_bts_event(struct perf_event_attr *attr);
462bool sample_addr_correlates_sym(struct perf_event_attr *attr);
Arnaldo Carvalho de Meloc2740a82016-03-22 18:44:46 -0300463void thread__resolve(struct thread *thread, struct addr_location *al,
464 struct perf_sample *sample);
Adrian Hunter9b0d2d82014-07-22 16:17:39 +0300465
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200466const char *perf_event__name(unsigned int id);
Arnaldo Carvalho de Meloc8446b92010-05-14 10:36:42 -0300467
Adrian Hunterb1cf6f62013-08-27 11:23:12 +0300468size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
Jiri Olsa352ea452014-01-07 13:47:25 +0100469 u64 read_format);
Andrew Vagin74eec262011-11-28 12:03:31 +0300470int perf_event__synthesize_sample(union perf_event *event, u64 type,
Jiri Olsa352ea452014-01-07 13:47:25 +0100471 u64 read_format,
Adrian Hunter936f1f32018-01-16 15:14:52 +0200472 const struct perf_sample *sample);
Arnaldo Carvalho de Melod0dd74e2011-01-21 13:46:41 -0200473
Namhyung Kime803cf92015-09-22 09:24:55 +0900474pid_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 Bathinie907caf2017-03-08 02:11:51 +0530479int 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 Olsaa18382b2014-01-07 13:47:20 +0100485int 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 Drayton3fcb10e2018-12-04 12:34:20 -0800490 bool mmap_data);
Jiri Olsaa18382b2014-01-07 13:47:20 +0100491
Adrian Huntera8ce99b2018-05-22 13:54:37 +0300492int perf_event__synthesize_extra_kmaps(struct perf_tool *tool,
493 perf_event__handler_t process,
494 struct machine *machine);
495
Arnaldo Carvalho de Melo482ad892011-12-02 11:06:37 -0200496size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp);
497size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp);
Stephane Eranian5c5e8542013-08-21 12:10:25 +0200498size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp);
Arnaldo Carvalho de Melo482ad892011-12-02 11:06:37 -0200499size_t perf_event__fprintf_task(union perf_event *event, FILE *fp);
Adrian Hunter4a96f7a2015-04-30 17:37:29 +0300500size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp);
Adrian Hunter0ad21f62015-04-30 17:37:30 +0300501size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp);
Adrian Hunter02860392015-07-21 12:44:03 +0300502size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp);
Jiri Olsaec7fa5962015-10-25 15:51:22 +0100503size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp);
Jiri Olsaeb12a1a2015-10-25 15:51:26 +0100504size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp);
Hari Bathinif3b36142017-03-08 02:11:43 +0530505size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp);
Song Liu9aa0bfa2019-01-17 08:15:17 -0800506size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp);
Arnaldo Carvalho de Melo3f604b52019-08-26 19:28:13 -0300507size_t perf_event__fprintf_bpf(union perf_event *event, FILE *fp);
Arnaldo Carvalho de Melo482ad892011-12-02 11:06:37 -0200508size_t perf_event__fprintf(union perf_event *event, FILE *fp);
509
Arnaldo Carvalho de Melob843f622017-04-27 21:21:09 -0300510int kallsyms__get_function_start(const char *kallsyms_filename,
511 const char *symbol_name, u64 *addr);
Adrian Hunter29b596b2014-01-29 16:14:37 +0200512
Jiri Olsaf8548392019-07-21 13:23:49 +0200513void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max);
Jiri Olsa72932372019-08-28 15:57:16 +0200514void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, struct perf_cpu_map *map,
Jiri Olsa6c872902015-10-25 15:51:24 +0100515 u16 type, int max);
Arnaldo Carvalho de Melo5ab8c682017-04-25 15:30:47 -0300516
517void event_attr_init(struct perf_event_attr *attr);
518
519int perf_event_paranoid(void);
Igor Lubashevc22e1502019-08-07 10:44:14 -0400520bool perf_event_paranoid_check(int max_level);
Arnaldo Carvalho de Melo5ab8c682017-04-25 15:30:47 -0300521
522extern int sysctl_perf_event_max_stack;
523extern int sysctl_perf_event_max_contexts_per_stack;
Mark Drayton3fcb10e2018-12-04 12:34:20 -0800524extern unsigned int proc_map_timeout;
Arnaldo Carvalho de Melo5ab8c682017-04-25 15:30:47 -0300525
John Kacur8b40f522009-09-24 18:02:18 +0200526#endif /* __PERF_RECORD_H */