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