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