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