1 #ifndef __PERF_RECORD_H
2 #define __PERF_RECORD_H
10 #include "perf_regs.h"
13 struct perf_event_header header
;
18 char filename
[PATH_MAX
];
22 struct perf_event_header header
;
33 char filename
[PATH_MAX
];
37 struct perf_event_header header
;
43 struct perf_event_header header
;
50 struct perf_event_header header
;
55 struct lost_samples_event
{
56 struct perf_event_header header
;
61 * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
64 struct perf_event_header header
;
72 struct throttle_event
{
73 struct perf_event_header header
;
79 #define PERF_SAMPLE_MASK \
80 (PERF_SAMPLE_IP | PERF_SAMPLE_TID | \
81 PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \
82 PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \
83 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \
84 PERF_SAMPLE_IDENTIFIER)
86 /* perf sample has 16 bits size limit */
87 #define PERF_SAMPLE_MAX_SIZE (1 << 16)
90 struct perf_event_header header
;
99 /* Cached values/mask filled by first register access. */
100 u64 cache_regs
[PERF_REGS_MAX
];
110 struct sample_read_value
{
121 struct sample_read_value
*values
;
123 struct sample_read_value one
;
127 struct ip_callchain
{
132 struct branch_flags
{
140 struct branch_entry
{
143 struct branch_flags flags
;
146 struct branch_stack
{
148 struct branch_entry entries
[0];
152 PERF_IP_FLAG_BRANCH
= 1ULL << 0,
153 PERF_IP_FLAG_CALL
= 1ULL << 1,
154 PERF_IP_FLAG_RETURN
= 1ULL << 2,
155 PERF_IP_FLAG_CONDITIONAL
= 1ULL << 3,
156 PERF_IP_FLAG_SYSCALLRET
= 1ULL << 4,
157 PERF_IP_FLAG_ASYNC
= 1ULL << 5,
158 PERF_IP_FLAG_INTERRUPT
= 1ULL << 6,
159 PERF_IP_FLAG_TX_ABORT
= 1ULL << 7,
160 PERF_IP_FLAG_TRACE_BEGIN
= 1ULL << 8,
161 PERF_IP_FLAG_TRACE_END
= 1ULL << 9,
162 PERF_IP_FLAG_IN_TX
= 1ULL << 10,
165 #define PERF_IP_FLAG_CHARS "bcrosyiABEx"
167 #define PERF_BRANCH_MASK (\
168 PERF_IP_FLAG_BRANCH |\
170 PERF_IP_FLAG_RETURN |\
171 PERF_IP_FLAG_CONDITIONAL |\
172 PERF_IP_FLAG_SYSCALLRET |\
173 PERF_IP_FLAG_ASYNC |\
174 PERF_IP_FLAG_INTERRUPT |\
175 PERF_IP_FLAG_TX_ABORT |\
176 PERF_IP_FLAG_TRACE_BEGIN |\
177 PERF_IP_FLAG_TRACE_END)
195 struct ip_callchain
*callchain
;
196 struct branch_stack
*branch_stack
;
197 struct regs_dump user_regs
;
198 struct regs_dump intr_regs
;
199 struct stack_dump user_stack
;
200 struct sample_read read
;
203 #define PERF_MEM_DATA_SRC_NONE \
204 (PERF_MEM_S(OP, NA) |\
205 PERF_MEM_S(LVL, NA) |\
206 PERF_MEM_S(SNOOP, NA) |\
207 PERF_MEM_S(LOCK, NA) |\
210 struct build_id_event
{
211 struct perf_event_header header
;
213 u8 build_id
[PERF_ALIGN(BUILD_ID_SIZE
, sizeof(u64
))];
217 enum perf_user_event_type
{ /* above any possible kernel type */
218 PERF_RECORD_USER_TYPE_START
= 64,
219 PERF_RECORD_HEADER_ATTR
= 64,
220 PERF_RECORD_HEADER_EVENT_TYPE
= 65, /* depreceated */
221 PERF_RECORD_HEADER_TRACING_DATA
= 66,
222 PERF_RECORD_HEADER_BUILD_ID
= 67,
223 PERF_RECORD_FINISHED_ROUND
= 68,
224 PERF_RECORD_ID_INDEX
= 69,
225 PERF_RECORD_AUXTRACE_INFO
= 70,
226 PERF_RECORD_AUXTRACE
= 71,
227 PERF_RECORD_AUXTRACE_ERROR
= 72,
228 PERF_RECORD_HEADER_MAX
231 enum auxtrace_error_type
{
232 PERF_AUXTRACE_ERROR_ITRACE
= 1,
233 PERF_AUXTRACE_ERROR_MAX
237 * The kernel collects the number of events it couldn't send in a stretch and
238 * when possible sends this number in a PERF_RECORD_LOST event. The number of
239 * such "chunks" of lost events is stored in .nr_events[PERF_EVENT_LOST] while
240 * total_lost tells exactly how many events the kernel in fact lost, i.e. it is
241 * the sum of all struct lost_event.lost fields reported.
243 * The kernel discards mixed up samples and sends the number in a
244 * PERF_RECORD_LOST_SAMPLES event. The number of lost-samples events is stored
245 * in .nr_events[PERF_RECORD_LOST_SAMPLES] while total_lost_samples tells
246 * exactly how many samples the kernel in fact dropped, i.e. it is the sum of
247 * all struct lost_samples_event.lost fields reported.
249 * The total_period is needed because by default auto-freq is used, so
250 * multipling nr_events[PERF_EVENT_SAMPLE] by a frequency isn't possible to get
251 * the total number of low level events, it is necessary to to sum all struct
252 * sample_event.period and stash the result in total_period.
254 struct events_stats
{
256 u64 total_non_filtered_period
;
258 u64 total_lost_samples
;
259 u64 total_invalid_chains
;
260 u32 nr_events
[PERF_RECORD_HEADER_MAX
];
261 u32 nr_non_filtered_samples
;
263 u32 nr_unknown_events
;
264 u32 nr_invalid_chains
;
266 u32 nr_unprocessable_samples
;
267 u32 nr_auxtrace_errors
[PERF_AUXTRACE_ERROR_MAX
];
268 u32 nr_proc_map_timeout
;
272 struct perf_event_header header
;
273 struct perf_event_attr attr
;
277 #define MAX_EVENT_NAME 64
279 struct perf_trace_event_type
{
281 char name
[MAX_EVENT_NAME
];
284 struct event_type_event
{
285 struct perf_event_header header
;
286 struct perf_trace_event_type event_type
;
289 struct tracing_data_event
{
290 struct perf_event_header header
;
294 struct id_index_entry
{
301 struct id_index_event
{
302 struct perf_event_header header
;
304 struct id_index_entry entries
[0];
307 struct auxtrace_info_event
{
308 struct perf_event_header header
;
310 u32 reserved__
; /* For alignment */
314 struct auxtrace_event
{
315 struct perf_event_header header
;
322 u32 reserved__
; /* For alignment */
325 #define MAX_AUXTRACE_ERROR_MSG 64
327 struct auxtrace_error_event
{
328 struct perf_event_header header
;
334 u32 reserved__
; /* For alignment */
336 char msg
[MAX_AUXTRACE_ERROR_MSG
];
340 struct perf_event_header header
;
346 struct itrace_start_event
{
347 struct perf_event_header header
;
351 struct context_switch_event
{
352 struct perf_event_header header
;
358 struct perf_event_header header
;
359 struct mmap_event mmap
;
360 struct mmap2_event mmap2
;
361 struct comm_event comm
;
362 struct fork_event fork
;
363 struct lost_event lost
;
364 struct lost_samples_event lost_samples
;
365 struct read_event read
;
366 struct throttle_event throttle
;
367 struct sample_event sample
;
368 struct attr_event attr
;
369 struct event_type_event event_type
;
370 struct tracing_data_event tracing_data
;
371 struct build_id_event build_id
;
372 struct id_index_event id_index
;
373 struct auxtrace_info_event auxtrace_info
;
374 struct auxtrace_event auxtrace
;
375 struct auxtrace_error_event auxtrace_error
;
376 struct aux_event aux
;
377 struct itrace_start_event itrace_start
;
378 struct context_switch_event context_switch
;
381 void perf_event__print_totals(void);
386 typedef int (*perf_event__handler_t
)(struct perf_tool
*tool
,
387 union perf_event
*event
,
388 struct perf_sample
*sample
,
389 struct machine
*machine
);
391 int perf_event__synthesize_thread_map(struct perf_tool
*tool
,
392 struct thread_map
*threads
,
393 perf_event__handler_t process
,
394 struct machine
*machine
, bool mmap_data
,
395 unsigned int proc_map_timeout
);
396 int perf_event__synthesize_threads(struct perf_tool
*tool
,
397 perf_event__handler_t process
,
398 struct machine
*machine
, bool mmap_data
,
399 unsigned int proc_map_timeout
);
400 int perf_event__synthesize_kernel_mmap(struct perf_tool
*tool
,
401 perf_event__handler_t process
,
402 struct machine
*machine
);
404 int perf_event__synthesize_modules(struct perf_tool
*tool
,
405 perf_event__handler_t process
,
406 struct machine
*machine
);
408 int perf_event__process_comm(struct perf_tool
*tool
,
409 union perf_event
*event
,
410 struct perf_sample
*sample
,
411 struct machine
*machine
);
412 int perf_event__process_lost(struct perf_tool
*tool
,
413 union perf_event
*event
,
414 struct perf_sample
*sample
,
415 struct machine
*machine
);
416 int perf_event__process_lost_samples(struct perf_tool
*tool
,
417 union perf_event
*event
,
418 struct perf_sample
*sample
,
419 struct machine
*machine
);
420 int perf_event__process_aux(struct perf_tool
*tool
,
421 union perf_event
*event
,
422 struct perf_sample
*sample
,
423 struct machine
*machine
);
424 int perf_event__process_itrace_start(struct perf_tool
*tool
,
425 union perf_event
*event
,
426 struct perf_sample
*sample
,
427 struct machine
*machine
);
428 int perf_event__process_switch(struct perf_tool
*tool
,
429 union perf_event
*event
,
430 struct perf_sample
*sample
,
431 struct machine
*machine
);
432 int perf_event__process_mmap(struct perf_tool
*tool
,
433 union perf_event
*event
,
434 struct perf_sample
*sample
,
435 struct machine
*machine
);
436 int perf_event__process_mmap2(struct perf_tool
*tool
,
437 union perf_event
*event
,
438 struct perf_sample
*sample
,
439 struct machine
*machine
);
440 int perf_event__process_fork(struct perf_tool
*tool
,
441 union perf_event
*event
,
442 struct perf_sample
*sample
,
443 struct machine
*machine
);
444 int perf_event__process_exit(struct perf_tool
*tool
,
445 union perf_event
*event
,
446 struct perf_sample
*sample
,
447 struct machine
*machine
);
448 int perf_event__process(struct perf_tool
*tool
,
449 union perf_event
*event
,
450 struct perf_sample
*sample
,
451 struct machine
*machine
);
453 struct addr_location
;
455 int perf_event__preprocess_sample(const union perf_event
*event
,
456 struct machine
*machine
,
457 struct addr_location
*al
,
458 struct perf_sample
*sample
);
460 void addr_location__put(struct addr_location
*al
);
464 bool is_bts_event(struct perf_event_attr
*attr
);
465 bool sample_addr_correlates_sym(struct perf_event_attr
*attr
);
466 void perf_event__preprocess_sample_addr(union perf_event
*event
,
467 struct perf_sample
*sample
,
468 struct thread
*thread
,
469 struct addr_location
*al
);
471 const char *perf_event__name(unsigned int id
);
473 size_t perf_event__sample_event_size(const struct perf_sample
*sample
, u64 type
,
475 int perf_event__synthesize_sample(union perf_event
*event
, u64 type
,
477 const struct perf_sample
*sample
,
480 int perf_event__synthesize_mmap_events(struct perf_tool
*tool
,
481 union perf_event
*event
,
482 pid_t pid
, pid_t tgid
,
483 perf_event__handler_t process
,
484 struct machine
*machine
,
486 unsigned int proc_map_timeout
);
488 size_t perf_event__fprintf_comm(union perf_event
*event
, FILE *fp
);
489 size_t perf_event__fprintf_mmap(union perf_event
*event
, FILE *fp
);
490 size_t perf_event__fprintf_mmap2(union perf_event
*event
, FILE *fp
);
491 size_t perf_event__fprintf_task(union perf_event
*event
, FILE *fp
);
492 size_t perf_event__fprintf_aux(union perf_event
*event
, FILE *fp
);
493 size_t perf_event__fprintf_itrace_start(union perf_event
*event
, FILE *fp
);
494 size_t perf_event__fprintf_switch(union perf_event
*event
, FILE *fp
);
495 size_t perf_event__fprintf(union perf_event
*event
, FILE *fp
);
497 u64
kallsyms__get_function_start(const char *kallsyms_filename
,
498 const char *symbol_name
);
500 #endif /* __PERF_RECORD_H */