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