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