1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * auxtrace.h: AUX area trace support 4 * Copyright (c) 2013-2015, Intel Corporation. 5 */ 6 7 #ifndef __PERF_AUXTRACE_H 8 #define __PERF_AUXTRACE_H 9 10 #include <sys/types.h> 11 #include <errno.h> 12 #include <stdbool.h> 13 #include <stddef.h> 14 #include <stdio.h> // FILE 15 #include <linux/list.h> 16 #include <linux/perf_event.h> 17 #include <linux/types.h> 18 #include <asm/bitsperlong.h> 19 #include <asm/barrier.h> 20 21 union perf_event; 22 struct perf_session; 23 struct evlist; 24 struct evsel; 25 struct perf_tool; 26 struct mmap; 27 struct perf_sample; 28 struct option; 29 struct record_opts; 30 struct perf_record_auxtrace_error; 31 struct perf_record_auxtrace_info; 32 struct events_stats; 33 struct perf_pmu; 34 35 enum auxtrace_error_type { 36 PERF_AUXTRACE_ERROR_ITRACE = 1, 37 PERF_AUXTRACE_ERROR_MAX 38 }; 39 40 /* Auxtrace records must have the same alignment as perf event records */ 41 #define PERF_AUXTRACE_RECORD_ALIGNMENT 8 42 43 enum auxtrace_type { 44 PERF_AUXTRACE_UNKNOWN, 45 PERF_AUXTRACE_INTEL_PT, 46 PERF_AUXTRACE_INTEL_BTS, 47 PERF_AUXTRACE_CS_ETM, 48 PERF_AUXTRACE_ARM_SPE, 49 PERF_AUXTRACE_S390_CPUMSF, 50 }; 51 52 enum itrace_period_type { 53 PERF_ITRACE_PERIOD_INSTRUCTIONS, 54 PERF_ITRACE_PERIOD_TICKS, 55 PERF_ITRACE_PERIOD_NANOSECS, 56 }; 57 58 #define AUXTRACE_ERR_FLG_OVERFLOW (1 << ('o' - 'a')) 59 #define AUXTRACE_ERR_FLG_DATA_LOST (1 << ('l' - 'a')) 60 61 #define AUXTRACE_LOG_FLG_ALL_PERF_EVTS (1 << ('a' - 'a')) 62 63 /** 64 * struct itrace_synth_opts - AUX area tracing synthesis options. 65 * @set: indicates whether or not options have been set 66 * @default_no_sample: Default to no sampling. 67 * @inject: indicates the event (not just the sample) must be fully synthesized 68 * because 'perf inject' will write it out 69 * @instructions: whether to synthesize 'instructions' events 70 * @branches: whether to synthesize 'branches' events 71 * (branch misses only for Arm SPE) 72 * @transactions: whether to synthesize events for transactions 73 * @ptwrites: whether to synthesize events for ptwrites 74 * @pwr_events: whether to synthesize power events 75 * @other_events: whether to synthesize other events recorded due to the use of 76 * aux_output 77 * @errors: whether to synthesize decoder error events 78 * @dont_decode: whether to skip decoding entirely 79 * @log: write a decoding log 80 * @calls: limit branch samples to calls (can be combined with @returns) 81 * @returns: limit branch samples to returns (can be combined with @calls) 82 * @callchain: add callchain to 'instructions' events 83 * @add_callchain: add callchain to existing event records 84 * @thread_stack: feed branches to the thread_stack 85 * @last_branch: add branch context to 'instruction' events 86 * @add_last_branch: add branch context to existing event records 87 * @approx_ipc: approximate IPC 88 * @flc: whether to synthesize first level cache events 89 * @llc: whether to synthesize last level cache events 90 * @tlb: whether to synthesize TLB events 91 * @remote_access: whether to synthesize remote access events 92 * @mem: whether to synthesize memory events 93 * @timeless_decoding: prefer "timeless" decoding i.e. ignore timestamps 94 * @vm_time_correlation: perform VM Time Correlation 95 * @vm_tm_corr_dry_run: VM Time Correlation dry-run 96 * @vm_tm_corr_args: VM Time Correlation implementation-specific arguments 97 * @callchain_sz: maximum callchain size 98 * @last_branch_sz: branch context size 99 * @period: 'instructions' events period 100 * @period_type: 'instructions' events period type 101 * @initial_skip: skip N events at the beginning. 102 * @cpu_bitmap: CPUs for which to synthesize events, or NULL for all 103 * @ptime_range: time intervals to trace or NULL 104 * @range_num: number of time intervals to trace 105 * @error_plus_flags: flags to affect what errors are reported 106 * @error_minus_flags: flags to affect what errors are reported 107 * @log_plus_flags: flags to affect what is logged 108 * @log_minus_flags: flags to affect what is logged 109 * @quick: quicker (less detailed) decoding 110 */ 111 struct itrace_synth_opts { 112 bool set; 113 bool default_no_sample; 114 bool inject; 115 bool instructions; 116 bool branches; 117 bool transactions; 118 bool ptwrites; 119 bool pwr_events; 120 bool other_events; 121 bool errors; 122 bool dont_decode; 123 bool log; 124 bool calls; 125 bool returns; 126 bool callchain; 127 bool add_callchain; 128 bool thread_stack; 129 bool last_branch; 130 bool add_last_branch; 131 bool approx_ipc; 132 bool flc; 133 bool llc; 134 bool tlb; 135 bool remote_access; 136 bool mem; 137 bool timeless_decoding; 138 bool vm_time_correlation; 139 bool vm_tm_corr_dry_run; 140 char *vm_tm_corr_args; 141 unsigned int callchain_sz; 142 unsigned int last_branch_sz; 143 unsigned long long period; 144 enum itrace_period_type period_type; 145 unsigned long initial_skip; 146 unsigned long *cpu_bitmap; 147 struct perf_time_interval *ptime_range; 148 int range_num; 149 unsigned int error_plus_flags; 150 unsigned int error_minus_flags; 151 unsigned int log_plus_flags; 152 unsigned int log_minus_flags; 153 unsigned int quick; 154 }; 155 156 /** 157 * struct auxtrace_index_entry - indexes a AUX area tracing event within a 158 * perf.data file. 159 * @file_offset: offset within the perf.data file 160 * @sz: size of the event 161 */ 162 struct auxtrace_index_entry { 163 u64 file_offset; 164 u64 sz; 165 }; 166 167 #define PERF_AUXTRACE_INDEX_ENTRY_COUNT 256 168 169 /** 170 * struct auxtrace_index - index of AUX area tracing events within a perf.data 171 * file. 172 * @list: linking a number of arrays of entries 173 * @nr: number of entries 174 * @entries: array of entries 175 */ 176 struct auxtrace_index { 177 struct list_head list; 178 size_t nr; 179 struct auxtrace_index_entry entries[PERF_AUXTRACE_INDEX_ENTRY_COUNT]; 180 }; 181 182 /** 183 * struct auxtrace - session callbacks to allow AUX area data decoding. 184 * @process_event: lets the decoder see all session events 185 * @process_auxtrace_event: process a PERF_RECORD_AUXTRACE event 186 * @queue_data: queue an AUX sample or PERF_RECORD_AUXTRACE event for later 187 * processing 188 * @dump_auxtrace_sample: dump AUX area sample data 189 * @flush_events: process any remaining data 190 * @free_events: free resources associated with event processing 191 * @free: free resources associated with the session 192 */ 193 struct auxtrace { 194 int (*process_event)(struct perf_session *session, 195 union perf_event *event, 196 struct perf_sample *sample, 197 struct perf_tool *tool); 198 int (*process_auxtrace_event)(struct perf_session *session, 199 union perf_event *event, 200 struct perf_tool *tool); 201 int (*queue_data)(struct perf_session *session, 202 struct perf_sample *sample, union perf_event *event, 203 u64 data_offset); 204 void (*dump_auxtrace_sample)(struct perf_session *session, 205 struct perf_sample *sample); 206 int (*flush_events)(struct perf_session *session, 207 struct perf_tool *tool); 208 void (*free_events)(struct perf_session *session); 209 void (*free)(struct perf_session *session); 210 bool (*evsel_is_auxtrace)(struct perf_session *session, 211 struct evsel *evsel); 212 }; 213 214 /** 215 * struct auxtrace_buffer - a buffer containing AUX area tracing data. 216 * @list: buffers are queued in a list held by struct auxtrace_queue 217 * @size: size of the buffer in bytes 218 * @pid: in per-thread mode, the pid this buffer is associated with 219 * @tid: in per-thread mode, the tid this buffer is associated with 220 * @cpu: in per-cpu mode, the cpu this buffer is associated with 221 * @data: actual buffer data (can be null if the data has not been loaded) 222 * @data_offset: file offset at which the buffer can be read 223 * @mmap_addr: mmap address at which the buffer can be read 224 * @mmap_size: size of the mmap at @mmap_addr 225 * @data_needs_freeing: @data was malloc'd so free it when it is no longer 226 * needed 227 * @consecutive: the original data was split up and this buffer is consecutive 228 * to the previous buffer 229 * @offset: offset as determined by aux_head / aux_tail members of struct 230 * perf_event_mmap_page 231 * @reference: an implementation-specific reference determined when the data is 232 * recorded 233 * @buffer_nr: used to number each buffer 234 * @use_size: implementation actually only uses this number of bytes 235 * @use_data: implementation actually only uses data starting at this address 236 */ 237 struct auxtrace_buffer { 238 struct list_head list; 239 size_t size; 240 pid_t pid; 241 pid_t tid; 242 int cpu; 243 void *data; 244 off_t data_offset; 245 void *mmap_addr; 246 size_t mmap_size; 247 bool data_needs_freeing; 248 bool consecutive; 249 u64 offset; 250 u64 reference; 251 u64 buffer_nr; 252 size_t use_size; 253 void *use_data; 254 }; 255 256 /** 257 * struct auxtrace_queue - a queue of AUX area tracing data buffers. 258 * @head: head of buffer list 259 * @tid: in per-thread mode, the tid this queue is associated with 260 * @cpu: in per-cpu mode, the cpu this queue is associated with 261 * @set: %true once this queue has been dedicated to a specific thread or cpu 262 * @priv: implementation-specific data 263 */ 264 struct auxtrace_queue { 265 struct list_head head; 266 pid_t tid; 267 int cpu; 268 bool set; 269 void *priv; 270 }; 271 272 /** 273 * struct auxtrace_queues - an array of AUX area tracing queues. 274 * @queue_array: array of queues 275 * @nr_queues: number of queues 276 * @new_data: set whenever new data is queued 277 * @populated: queues have been fully populated using the auxtrace_index 278 * @next_buffer_nr: used to number each buffer 279 */ 280 struct auxtrace_queues { 281 struct auxtrace_queue *queue_array; 282 unsigned int nr_queues; 283 bool new_data; 284 bool populated; 285 u64 next_buffer_nr; 286 }; 287 288 /** 289 * struct auxtrace_heap_item - element of struct auxtrace_heap. 290 * @queue_nr: queue number 291 * @ordinal: value used for sorting (lowest ordinal is top of the heap) expected 292 * to be a timestamp 293 */ 294 struct auxtrace_heap_item { 295 unsigned int queue_nr; 296 u64 ordinal; 297 }; 298 299 /** 300 * struct auxtrace_heap - a heap suitable for sorting AUX area tracing queues. 301 * @heap_array: the heap 302 * @heap_cnt: the number of elements in the heap 303 * @heap_sz: maximum number of elements (grows as needed) 304 */ 305 struct auxtrace_heap { 306 struct auxtrace_heap_item *heap_array; 307 unsigned int heap_cnt; 308 unsigned int heap_sz; 309 }; 310 311 /** 312 * struct auxtrace_mmap - records an mmap of the auxtrace buffer. 313 * @base: address of mapped area 314 * @userpg: pointer to buffer's perf_event_mmap_page 315 * @mask: %0 if @len is not a power of two, otherwise (@len - %1) 316 * @len: size of mapped area 317 * @prev: previous aux_head 318 * @idx: index of this mmap 319 * @tid: tid for a per-thread mmap (also set if there is only 1 tid on a per-cpu 320 * mmap) otherwise %0 321 * @cpu: cpu number for a per-cpu mmap otherwise %-1 322 */ 323 struct auxtrace_mmap { 324 void *base; 325 void *userpg; 326 size_t mask; 327 size_t len; 328 u64 prev; 329 int idx; 330 pid_t tid; 331 int cpu; 332 }; 333 334 /** 335 * struct auxtrace_mmap_params - parameters to set up struct auxtrace_mmap. 336 * @mask: %0 if @len is not a power of two, otherwise (@len - %1) 337 * @offset: file offset of mapped area 338 * @len: size of mapped area 339 * @prot: mmap memory protection 340 * @idx: index of this mmap 341 * @tid: tid for a per-thread mmap (also set if there is only 1 tid on a per-cpu 342 * mmap) otherwise %0 343 * @cpu: cpu number for a per-cpu mmap otherwise %-1 344 */ 345 struct auxtrace_mmap_params { 346 size_t mask; 347 off_t offset; 348 size_t len; 349 int prot; 350 int idx; 351 pid_t tid; 352 int cpu; 353 }; 354 355 /** 356 * struct auxtrace_record - callbacks for recording AUX area data. 357 * @recording_options: validate and process recording options 358 * @info_priv_size: return the size of the private data in auxtrace_info_event 359 * @info_fill: fill-in the private data in auxtrace_info_event 360 * @free: free this auxtrace record structure 361 * @snapshot_start: starting a snapshot 362 * @snapshot_finish: finishing a snapshot 363 * @find_snapshot: find data to snapshot within auxtrace mmap 364 * @parse_snapshot_options: parse snapshot options 365 * @reference: provide a 64-bit reference number for auxtrace_event 366 * @read_finish: called after reading from an auxtrace mmap 367 * @alignment: alignment (if any) for AUX area data 368 * @default_aux_sample_size: default sample size for --aux sample option 369 * @pmu: associated pmu 370 * @evlist: selected events list 371 */ 372 struct auxtrace_record { 373 int (*recording_options)(struct auxtrace_record *itr, 374 struct evlist *evlist, 375 struct record_opts *opts); 376 size_t (*info_priv_size)(struct auxtrace_record *itr, 377 struct evlist *evlist); 378 int (*info_fill)(struct auxtrace_record *itr, 379 struct perf_session *session, 380 struct perf_record_auxtrace_info *auxtrace_info, 381 size_t priv_size); 382 void (*free)(struct auxtrace_record *itr); 383 int (*snapshot_start)(struct auxtrace_record *itr); 384 int (*snapshot_finish)(struct auxtrace_record *itr); 385 int (*find_snapshot)(struct auxtrace_record *itr, int idx, 386 struct auxtrace_mmap *mm, unsigned char *data, 387 u64 *head, u64 *old); 388 int (*parse_snapshot_options)(struct auxtrace_record *itr, 389 struct record_opts *opts, 390 const char *str); 391 u64 (*reference)(struct auxtrace_record *itr); 392 int (*read_finish)(struct auxtrace_record *itr, int idx); 393 unsigned int alignment; 394 unsigned int default_aux_sample_size; 395 struct perf_pmu *pmu; 396 struct evlist *evlist; 397 }; 398 399 /** 400 * struct addr_filter - address filter. 401 * @list: list node 402 * @range: true if it is a range filter 403 * @start: true if action is 'filter' or 'start' 404 * @action: 'filter', 'start' or 'stop' ('tracestop' is accepted but converted 405 * to 'stop') 406 * @sym_from: symbol name for the filter address 407 * @sym_to: symbol name that determines the filter size 408 * @sym_from_idx: selects n'th from symbols with the same name (0 means global 409 * and less than 0 means symbol must be unique) 410 * @sym_to_idx: same as @sym_from_idx but for @sym_to 411 * @addr: filter address 412 * @size: filter region size (for range filters) 413 * @filename: DSO file name or NULL for the kernel 414 * @str: allocated string that contains the other string members 415 */ 416 struct addr_filter { 417 struct list_head list; 418 bool range; 419 bool start; 420 const char *action; 421 const char *sym_from; 422 const char *sym_to; 423 int sym_from_idx; 424 int sym_to_idx; 425 u64 addr; 426 u64 size; 427 const char *filename; 428 char *str; 429 }; 430 431 /** 432 * struct addr_filters - list of address filters. 433 * @head: list of address filters 434 * @cnt: number of address filters 435 */ 436 struct addr_filters { 437 struct list_head head; 438 int cnt; 439 }; 440 441 struct auxtrace_cache; 442 443 #ifdef HAVE_AUXTRACE_SUPPORT 444 445 u64 compat_auxtrace_mmap__read_head(struct auxtrace_mmap *mm); 446 int compat_auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail); 447 448 static inline u64 auxtrace_mmap__read_head(struct auxtrace_mmap *mm, 449 int kernel_is_64_bit __maybe_unused) 450 { 451 struct perf_event_mmap_page *pc = mm->userpg; 452 u64 head; 453 454 #if BITS_PER_LONG == 32 455 if (kernel_is_64_bit) 456 return compat_auxtrace_mmap__read_head(mm); 457 #endif 458 head = READ_ONCE(pc->aux_head); 459 460 /* Ensure all reads are done after we read the head */ 461 smp_rmb(); 462 return head; 463 } 464 465 static inline int auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail, 466 int kernel_is_64_bit __maybe_unused) 467 { 468 struct perf_event_mmap_page *pc = mm->userpg; 469 470 #if BITS_PER_LONG == 32 471 if (kernel_is_64_bit) 472 return compat_auxtrace_mmap__write_tail(mm, tail); 473 #endif 474 /* Ensure all reads are done before we write the tail out */ 475 smp_mb(); 476 WRITE_ONCE(pc->aux_tail, tail); 477 return 0; 478 } 479 480 int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, 481 struct auxtrace_mmap_params *mp, 482 void *userpg, int fd); 483 void auxtrace_mmap__munmap(struct auxtrace_mmap *mm); 484 void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp, 485 off_t auxtrace_offset, 486 unsigned int auxtrace_pages, 487 bool auxtrace_overwrite); 488 void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, 489 struct evlist *evlist, int idx, 490 bool per_cpu); 491 492 typedef int (*process_auxtrace_t)(struct perf_tool *tool, 493 struct mmap *map, 494 union perf_event *event, void *data1, 495 size_t len1, void *data2, size_t len2); 496 497 int auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr, 498 struct perf_tool *tool, process_auxtrace_t fn); 499 500 int auxtrace_mmap__read_snapshot(struct mmap *map, 501 struct auxtrace_record *itr, 502 struct perf_tool *tool, process_auxtrace_t fn, 503 size_t snapshot_size); 504 505 int auxtrace_queues__init(struct auxtrace_queues *queues); 506 int auxtrace_queues__add_event(struct auxtrace_queues *queues, 507 struct perf_session *session, 508 union perf_event *event, off_t data_offset, 509 struct auxtrace_buffer **buffer_ptr); 510 struct auxtrace_queue * 511 auxtrace_queues__sample_queue(struct auxtrace_queues *queues, 512 struct perf_sample *sample, 513 struct perf_session *session); 514 int auxtrace_queues__add_sample(struct auxtrace_queues *queues, 515 struct perf_session *session, 516 struct perf_sample *sample, u64 data_offset, 517 u64 reference); 518 void auxtrace_queues__free(struct auxtrace_queues *queues); 519 int auxtrace_queues__process_index(struct auxtrace_queues *queues, 520 struct perf_session *session); 521 int auxtrace_queue_data(struct perf_session *session, bool samples, 522 bool events); 523 struct auxtrace_buffer *auxtrace_buffer__next(struct auxtrace_queue *queue, 524 struct auxtrace_buffer *buffer); 525 void *auxtrace_buffer__get_data_rw(struct auxtrace_buffer *buffer, int fd, bool rw); 526 static inline void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd) 527 { 528 return auxtrace_buffer__get_data_rw(buffer, fd, false); 529 } 530 void auxtrace_buffer__put_data(struct auxtrace_buffer *buffer); 531 void auxtrace_buffer__drop_data(struct auxtrace_buffer *buffer); 532 void auxtrace_buffer__free(struct auxtrace_buffer *buffer); 533 534 int auxtrace_heap__add(struct auxtrace_heap *heap, unsigned int queue_nr, 535 u64 ordinal); 536 void auxtrace_heap__pop(struct auxtrace_heap *heap); 537 void auxtrace_heap__free(struct auxtrace_heap *heap); 538 539 struct auxtrace_cache_entry { 540 struct hlist_node hash; 541 u32 key; 542 }; 543 544 struct auxtrace_cache *auxtrace_cache__new(unsigned int bits, size_t entry_size, 545 unsigned int limit_percent); 546 void auxtrace_cache__free(struct auxtrace_cache *auxtrace_cache); 547 void *auxtrace_cache__alloc_entry(struct auxtrace_cache *c); 548 void auxtrace_cache__free_entry(struct auxtrace_cache *c, void *entry); 549 int auxtrace_cache__add(struct auxtrace_cache *c, u32 key, 550 struct auxtrace_cache_entry *entry); 551 void auxtrace_cache__remove(struct auxtrace_cache *c, u32 key); 552 void *auxtrace_cache__lookup(struct auxtrace_cache *c, u32 key); 553 554 struct auxtrace_record *auxtrace_record__init(struct evlist *evlist, 555 int *err); 556 557 int auxtrace_parse_snapshot_options(struct auxtrace_record *itr, 558 struct record_opts *opts, 559 const char *str); 560 int auxtrace_parse_sample_options(struct auxtrace_record *itr, 561 struct evlist *evlist, 562 struct record_opts *opts, const char *str); 563 void auxtrace_regroup_aux_output(struct evlist *evlist); 564 int auxtrace_record__options(struct auxtrace_record *itr, 565 struct evlist *evlist, 566 struct record_opts *opts); 567 size_t auxtrace_record__info_priv_size(struct auxtrace_record *itr, 568 struct evlist *evlist); 569 int auxtrace_record__info_fill(struct auxtrace_record *itr, 570 struct perf_session *session, 571 struct perf_record_auxtrace_info *auxtrace_info, 572 size_t priv_size); 573 void auxtrace_record__free(struct auxtrace_record *itr); 574 int auxtrace_record__snapshot_start(struct auxtrace_record *itr); 575 int auxtrace_record__snapshot_finish(struct auxtrace_record *itr, bool on_exit); 576 int auxtrace_record__find_snapshot(struct auxtrace_record *itr, int idx, 577 struct auxtrace_mmap *mm, 578 unsigned char *data, u64 *head, u64 *old); 579 u64 auxtrace_record__reference(struct auxtrace_record *itr); 580 int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx); 581 582 int auxtrace_index__auxtrace_event(struct list_head *head, union perf_event *event, 583 off_t file_offset); 584 int auxtrace_index__write(int fd, struct list_head *head); 585 int auxtrace_index__process(int fd, u64 size, struct perf_session *session, 586 bool needs_swap); 587 void auxtrace_index__free(struct list_head *head); 588 589 void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int type, 590 int code, int cpu, pid_t pid, pid_t tid, u64 ip, 591 const char *msg, u64 timestamp); 592 593 int perf_event__process_auxtrace_info(struct perf_session *session, 594 union perf_event *event); 595 s64 perf_event__process_auxtrace(struct perf_session *session, 596 union perf_event *event); 597 int perf_event__process_auxtrace_error(struct perf_session *session, 598 union perf_event *event); 599 int itrace_do_parse_synth_opts(struct itrace_synth_opts *synth_opts, 600 const char *str, int unset); 601 int itrace_parse_synth_opts(const struct option *opt, const char *str, 602 int unset); 603 void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts, 604 bool no_sample); 605 606 size_t perf_event__fprintf_auxtrace_error(union perf_event *event, FILE *fp); 607 void perf_session__auxtrace_error_inc(struct perf_session *session, 608 union perf_event *event); 609 void events_stats__auxtrace_error_warn(const struct events_stats *stats); 610 611 void addr_filters__init(struct addr_filters *filts); 612 void addr_filters__exit(struct addr_filters *filts); 613 int addr_filters__parse_bare_filter(struct addr_filters *filts, 614 const char *filter); 615 int auxtrace_parse_filters(struct evlist *evlist); 616 617 int auxtrace__process_event(struct perf_session *session, union perf_event *event, 618 struct perf_sample *sample, struct perf_tool *tool); 619 void auxtrace__dump_auxtrace_sample(struct perf_session *session, 620 struct perf_sample *sample); 621 int auxtrace__flush_events(struct perf_session *session, struct perf_tool *tool); 622 void auxtrace__free_events(struct perf_session *session); 623 void auxtrace__free(struct perf_session *session); 624 bool auxtrace__evsel_is_auxtrace(struct perf_session *session, 625 struct evsel *evsel); 626 627 #define ITRACE_HELP \ 628 " i[period]: synthesize instructions events\n" \ 629 " b: synthesize branches events (branch misses for Arm SPE)\n" \ 630 " c: synthesize branches events (calls only)\n" \ 631 " r: synthesize branches events (returns only)\n" \ 632 " x: synthesize transactions events\n" \ 633 " w: synthesize ptwrite events\n" \ 634 " p: synthesize power events\n" \ 635 " o: synthesize other events recorded due to the use\n" \ 636 " of aux-output (refer to perf record)\n" \ 637 " e[flags]: synthesize error events\n" \ 638 " each flag must be preceded by + or -\n" \ 639 " error flags are: o (overflow)\n" \ 640 " l (data lost)\n" \ 641 " d[flags]: create a debug log\n" \ 642 " each flag must be preceded by + or -\n" \ 643 " log flags are: a (all perf events)\n" \ 644 " f: synthesize first level cache events\n" \ 645 " m: synthesize last level cache events\n" \ 646 " t: synthesize TLB events\n" \ 647 " a: synthesize remote access events\n" \ 648 " g[len]: synthesize a call chain (use with i or x)\n" \ 649 " G[len]: synthesize a call chain on existing event records\n" \ 650 " l[len]: synthesize last branch entries (use with i or x)\n" \ 651 " L[len]: synthesize last branch entries on existing event records\n" \ 652 " sNUMBER: skip initial number of events\n" \ 653 " q: quicker (less detailed) decoding\n" \ 654 " A: approximate IPC\n" \ 655 " Z: prefer to ignore timestamps (so-called \"timeless\" decoding)\n" \ 656 " PERIOD[ns|us|ms|i|t]: specify period to sample stream\n" \ 657 " concatenate multiple options. Default is ibxwpe or cewp\n" 658 659 static inline 660 void itrace_synth_opts__set_time_range(struct itrace_synth_opts *opts, 661 struct perf_time_interval *ptime_range, 662 int range_num) 663 { 664 opts->ptime_range = ptime_range; 665 opts->range_num = range_num; 666 } 667 668 static inline 669 void itrace_synth_opts__clear_time_range(struct itrace_synth_opts *opts) 670 { 671 opts->ptime_range = NULL; 672 opts->range_num = 0; 673 } 674 675 #else 676 #include "debug.h" 677 678 static inline struct auxtrace_record * 679 auxtrace_record__init(struct evlist *evlist __maybe_unused, 680 int *err) 681 { 682 *err = 0; 683 return NULL; 684 } 685 686 static inline 687 void auxtrace_record__free(struct auxtrace_record *itr __maybe_unused) 688 { 689 } 690 691 static inline 692 int auxtrace_record__options(struct auxtrace_record *itr __maybe_unused, 693 struct evlist *evlist __maybe_unused, 694 struct record_opts *opts __maybe_unused) 695 { 696 return 0; 697 } 698 699 static inline 700 int perf_event__process_auxtrace_info(struct perf_session *session __maybe_unused, 701 union perf_event *event __maybe_unused) 702 { 703 return 0; 704 } 705 706 static inline 707 s64 perf_event__process_auxtrace(struct perf_session *session __maybe_unused, 708 union perf_event *event __maybe_unused) 709 { 710 return 0; 711 } 712 713 static inline 714 int perf_event__process_auxtrace_error(struct perf_session *session __maybe_unused, 715 union perf_event *event __maybe_unused) 716 { 717 return 0; 718 } 719 720 static inline 721 void perf_session__auxtrace_error_inc(struct perf_session *session 722 __maybe_unused, 723 union perf_event *event 724 __maybe_unused) 725 { 726 } 727 728 static inline 729 void events_stats__auxtrace_error_warn(const struct events_stats *stats 730 __maybe_unused) 731 { 732 } 733 734 static inline 735 int itrace_do_parse_synth_opts(struct itrace_synth_opts *synth_opts __maybe_unused, 736 const char *str __maybe_unused, int unset __maybe_unused) 737 { 738 pr_err("AUX area tracing not supported\n"); 739 return -EINVAL; 740 } 741 742 static inline 743 int itrace_parse_synth_opts(const struct option *opt __maybe_unused, 744 const char *str __maybe_unused, 745 int unset __maybe_unused) 746 { 747 pr_err("AUX area tracing not supported\n"); 748 return -EINVAL; 749 } 750 751 static inline 752 int auxtrace_parse_snapshot_options(struct auxtrace_record *itr __maybe_unused, 753 struct record_opts *opts __maybe_unused, 754 const char *str) 755 { 756 if (!str) 757 return 0; 758 pr_err("AUX area tracing not supported\n"); 759 return -EINVAL; 760 } 761 762 static inline 763 int auxtrace_parse_sample_options(struct auxtrace_record *itr __maybe_unused, 764 struct evlist *evlist __maybe_unused, 765 struct record_opts *opts __maybe_unused, 766 const char *str) 767 { 768 if (!str) 769 return 0; 770 pr_err("AUX area tracing not supported\n"); 771 return -EINVAL; 772 } 773 774 static inline 775 void auxtrace_regroup_aux_output(struct evlist *evlist __maybe_unused) 776 { 777 } 778 779 static inline 780 int auxtrace__process_event(struct perf_session *session __maybe_unused, 781 union perf_event *event __maybe_unused, 782 struct perf_sample *sample __maybe_unused, 783 struct perf_tool *tool __maybe_unused) 784 { 785 return 0; 786 } 787 788 static inline 789 void auxtrace__dump_auxtrace_sample(struct perf_session *session __maybe_unused, 790 struct perf_sample *sample __maybe_unused) 791 { 792 } 793 794 static inline 795 int auxtrace__flush_events(struct perf_session *session __maybe_unused, 796 struct perf_tool *tool __maybe_unused) 797 { 798 return 0; 799 } 800 801 static inline 802 void auxtrace__free_events(struct perf_session *session __maybe_unused) 803 { 804 } 805 806 static inline 807 void auxtrace_cache__free(struct auxtrace_cache *auxtrace_cache __maybe_unused) 808 { 809 } 810 811 static inline 812 void auxtrace__free(struct perf_session *session __maybe_unused) 813 { 814 } 815 816 static inline 817 int auxtrace_index__write(int fd __maybe_unused, 818 struct list_head *head __maybe_unused) 819 { 820 return -EINVAL; 821 } 822 823 static inline 824 int auxtrace_index__process(int fd __maybe_unused, 825 u64 size __maybe_unused, 826 struct perf_session *session __maybe_unused, 827 bool needs_swap __maybe_unused) 828 { 829 return -EINVAL; 830 } 831 832 static inline 833 void auxtrace_index__free(struct list_head *head __maybe_unused) 834 { 835 } 836 837 static inline 838 bool auxtrace__evsel_is_auxtrace(struct perf_session *session __maybe_unused, 839 struct evsel *evsel __maybe_unused) 840 { 841 return false; 842 } 843 844 static inline 845 int auxtrace_parse_filters(struct evlist *evlist __maybe_unused) 846 { 847 return 0; 848 } 849 850 int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, 851 struct auxtrace_mmap_params *mp, 852 void *userpg, int fd); 853 void auxtrace_mmap__munmap(struct auxtrace_mmap *mm); 854 void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp, 855 off_t auxtrace_offset, 856 unsigned int auxtrace_pages, 857 bool auxtrace_overwrite); 858 void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, 859 struct evlist *evlist, int idx, 860 bool per_cpu); 861 862 #define ITRACE_HELP "" 863 864 static inline 865 void itrace_synth_opts__set_time_range(struct itrace_synth_opts *opts 866 __maybe_unused, 867 struct perf_time_interval *ptime_range 868 __maybe_unused, 869 int range_num __maybe_unused) 870 { 871 } 872 873 static inline 874 void itrace_synth_opts__clear_time_range(struct itrace_synth_opts *opts 875 __maybe_unused) 876 { 877 } 878 879 #endif 880 881 #endif 882