Blame view

kernel/trace/trace_entries.h 7.4 KB
0a1c49db8   Steven Rostedt   tracing: use macr...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  /*
   * This file defines the trace event structures that go into the ring
   * buffer directly. They are created via macros so that changes for them
   * appear in the format file. Using macros will automate this process.
   *
   * The macro used to create a ftrace data structure is:
   *
   * FTRACE_ENTRY( name, struct_name, id, structure, print )
   *
   * @name: the name used the event name, as well as the name of
   *   the directory that holds the format file.
   *
   * @struct_name: the name of the structure that is created.
   *
   * @id: The event identifier that is used to detect what event
   *    this is from the ring buffer.
   *
   * @structure: the structure layout
   *
   *  - __field(	type,	item	)
   *	  This is equivalent to declaring
   *		type	item;
   *	  in the structure.
   *  - __array(	type,	item,	size	)
   *	  This is equivalent to declaring
   *		type	item[size];
   *	  in the structure.
   *
d73150943   Steven Rostedt   tracing: show det...
29
   *   * for structures within structures, the format of the internal
25985edce   Lucas De Marchi   Fix common misspe...
30
   *	structure is laid out. This allows the internal structure
d73150943   Steven Rostedt   tracing: show det...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
   *	to be deciphered for the format file. Although these macros
   *	may become out of sync with the internal structure, they
   *	will create a compile error if it happens. Since the
   *	internel structures are just tracing helpers, this is not
   *	an issue.
   *
   *	When an internal structure is used, it should use:
   *
   *	__field_struct(	type,	item	)
   *
   *	instead of __field. This will prevent it from being shown in
   *	the output file. The fields in the structure should use.
   *
   *	__field_desc(	type,	container,	item		)
   *	__array_desc(	type,	container,	item,	len	)
   *
   *	type, item and len are the same as __field and __array, but
   *	container is added. This is the name of the item in
   *	__field_struct that this is describing.
   *
   *
0a1c49db8   Steven Rostedt   tracing: use macr...
52
53
54
55
   * @print: the print format shown to users in the format file.
   */
  
  /*
b595076a1   Uwe Kleine-König   tree-wide: fix co...
56
   * Function trace entry - function address and parent function address:
0a1c49db8   Steven Rostedt   tracing: use macr...
57
   */
ced39002f   Jiri Olsa   ftrace, perf: Add...
58
  FTRACE_ENTRY_REG(function, ftrace_entry,
0a1c49db8   Steven Rostedt   tracing: use macr...
59
60
61
62
63
64
65
  
  	TRACE_FN,
  
  	F_STRUCT(
  		__field(	unsigned long,	ip		)
  		__field(	unsigned long,	parent_ip	)
  	),
ced39002f   Jiri Olsa   ftrace, perf: Add...
66
  	F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip),
02aa3162e   Jiri Olsa   ftrace: Allow to ...
67
  	FILTER_TRACE_FN,
ced39002f   Jiri Olsa   ftrace, perf: Add...
68
  	perf_ftrace_event_register
0a1c49db8   Steven Rostedt   tracing: use macr...
69
70
71
72
73
74
75
76
  );
  
  /* Function call entry */
  FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
  
  	TRACE_GRAPH_ENT,
  
  	F_STRUCT(
d73150943   Steven Rostedt   tracing: show det...
77
78
79
  		__field_struct(	struct ftrace_graph_ent,	graph_ent	)
  		__field_desc(	unsigned long,	graph_ent,	func		)
  		__field_desc(	int,		graph_ent,	depth		)
0a1c49db8   Steven Rostedt   tracing: use macr...
80
  	),
02aa3162e   Jiri Olsa   ftrace: Allow to ...
81
82
83
  	F_printk("--> %lx (%d)", __entry->func, __entry->depth),
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
84
85
86
87
88
89
90
91
  );
  
  /* Function return entry */
  FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry,
  
  	TRACE_GRAPH_RET,
  
  	F_STRUCT(
d73150943   Steven Rostedt   tracing: show det...
92
93
94
95
96
97
  		__field_struct(	struct ftrace_graph_ret,	ret	)
  		__field_desc(	unsigned long,	ret,		func	)
  		__field_desc(	unsigned long long, ret,	calltime)
  		__field_desc(	unsigned long long, ret,	rettime	)
  		__field_desc(	unsigned long,	ret,		overrun	)
  		__field_desc(	int,		ret,		depth	)
0a1c49db8   Steven Rostedt   tracing: use macr...
98
99
100
101
  	),
  
  	F_printk("<-- %lx (%d) (start: %llx  end: %llx) over: %d",
  		 __entry->func, __entry->depth,
c16de8fd7   Li Zefan   tracing: fix F_pr...
102
  		 __entry->calltime, __entry->rettime,
02aa3162e   Jiri Olsa   ftrace: Allow to ...
103
104
105
  		 __entry->depth),
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
106
107
108
109
110
111
112
113
114
115
  );
  
  /*
   * Context switch trace entry - which task (and prio) we switched from/to:
   *
   * This is used for both wakeup and context switches. We only want
   * to create one structure, but we need two outputs for it.
   */
  #define FTRACE_CTX_FIELDS					\
  	__field(	unsigned int,	prev_pid	)	\
140e4f2d1   David Sharp   tracing: Fix even...
116
117
  	__field(	unsigned int,	next_pid	)	\
  	__field(	unsigned int,	next_cpu	)       \
0a1c49db8   Steven Rostedt   tracing: use macr...
118
119
  	__field(	unsigned char,	prev_prio	)	\
  	__field(	unsigned char,	prev_state	)	\
0a1c49db8   Steven Rostedt   tracing: use macr...
120
  	__field(	unsigned char,	next_prio	)	\
140e4f2d1   David Sharp   tracing: Fix even...
121
  	__field(	unsigned char,	next_state	)
0a1c49db8   Steven Rostedt   tracing: use macr...
122

0a1c49db8   Steven Rostedt   tracing: use macr...
123
124
125
126
127
128
129
  FTRACE_ENTRY(context_switch, ctx_switch_entry,
  
  	TRACE_CTX,
  
  	F_STRUCT(
  		FTRACE_CTX_FIELDS
  	),
c16de8fd7   Li Zefan   tracing: fix F_pr...
130
  	F_printk("%u:%u:%u  ==> %u:%u:%u [%03u]",
0a1c49db8   Steven Rostedt   tracing: use macr...
131
132
  		 __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
  		 __entry->next_pid, __entry->next_prio, __entry->next_state,
02aa3162e   Jiri Olsa   ftrace: Allow to ...
133
134
135
  		 __entry->next_cpu),
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
  );
  
  /*
   * FTRACE_ENTRY_DUP only creates the format file, it will not
   *  create another structure.
   */
  FTRACE_ENTRY_DUP(wakeup, ctx_switch_entry,
  
  	TRACE_WAKE,
  
  	F_STRUCT(
  		FTRACE_CTX_FIELDS
  	),
  
  	F_printk("%u:%u:%u  ==+ %u:%u:%u [%03u]",
  		 __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
  		 __entry->next_pid, __entry->next_prio, __entry->next_state,
02aa3162e   Jiri Olsa   ftrace: Allow to ...
153
154
155
  		 __entry->next_cpu),
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
156
157
158
  );
  
  /*
0a1c49db8   Steven Rostedt   tracing: use macr...
159
160
161
162
   * Stack-trace entry:
   */
  
  #define FTRACE_STACK_ENTRIES	8
01de982ab   Wolfgang Mauerer   tracing: Fix ftra...
163
164
165
166
167
  #ifndef CONFIG_64BIT
  # define IP_FMT "%08lx"
  #else
  # define IP_FMT "%016lx"
  #endif
0a1c49db8   Steven Rostedt   tracing: use macr...
168
169
170
171
172
  FTRACE_ENTRY(kernel_stack, stack_entry,
  
  	TRACE_STACK,
  
  	F_STRUCT(
4a9bd3f13   Steven Rostedt   tracing: Have dyn...
173
174
  		__field(	int,		size	)
  		__dynamic_array(unsigned long,	caller	)
0a1c49db8   Steven Rostedt   tracing: use macr...
175
  	),
01de982ab   Wolfgang Mauerer   tracing: Fix ftra...
176
177
178
179
180
181
182
183
184
185
186
  	F_printk("\t=> (" IP_FMT ")
  \t=> (" IP_FMT ")
  \t=> (" IP_FMT ")
  "
  		 "\t=> (" IP_FMT ")
  \t=> (" IP_FMT ")
  \t=> (" IP_FMT ")
  "
  		 "\t=> (" IP_FMT ")
  \t=> (" IP_FMT ")
  ",
0a1c49db8   Steven Rostedt   tracing: use macr...
187
188
  		 __entry->caller[0], __entry->caller[1], __entry->caller[2],
  		 __entry->caller[3], __entry->caller[4], __entry->caller[5],
02aa3162e   Jiri Olsa   ftrace: Allow to ...
189
190
191
  		 __entry->caller[6], __entry->caller[7]),
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
192
193
194
195
196
197
198
199
200
201
  );
  
  FTRACE_ENTRY(user_stack, userstack_entry,
  
  	TRACE_USER_STACK,
  
  	F_STRUCT(
  		__field(	unsigned int,	tgid	)
  		__array(	unsigned long,	caller, FTRACE_STACK_ENTRIES	)
  	),
01de982ab   Wolfgang Mauerer   tracing: Fix ftra...
202
203
204
205
206
207
208
209
210
211
212
  	F_printk("\t=> (" IP_FMT ")
  \t=> (" IP_FMT ")
  \t=> (" IP_FMT ")
  "
  		 "\t=> (" IP_FMT ")
  \t=> (" IP_FMT ")
  \t=> (" IP_FMT ")
  "
  		 "\t=> (" IP_FMT ")
  \t=> (" IP_FMT ")
  ",
0a1c49db8   Steven Rostedt   tracing: use macr...
213
214
  		 __entry->caller[0], __entry->caller[1], __entry->caller[2],
  		 __entry->caller[3], __entry->caller[4], __entry->caller[5],
02aa3162e   Jiri Olsa   ftrace: Allow to ...
215
216
217
  		 __entry->caller[6], __entry->caller[7]),
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
218
219
220
221
222
223
224
225
226
227
228
229
230
231
  );
  
  /*
   * trace_printk entry:
   */
  FTRACE_ENTRY(bprint, bprint_entry,
  
  	TRACE_BPRINT,
  
  	F_STRUCT(
  		__field(	unsigned long,	ip	)
  		__field(	const char *,	fmt	)
  		__dynamic_array(	u32,	buf	)
  	),
09ae72348   Steven Rostedt (Red Hat)   tracing: Add trac...
232
233
  	F_printk("%pf: %s",
  		 (void *)__entry->ip, __entry->fmt),
02aa3162e   Jiri Olsa   ftrace: Allow to ...
234
235
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
236
237
238
239
240
241
242
243
244
245
  );
  
  FTRACE_ENTRY(print, print_entry,
  
  	TRACE_PRINT,
  
  	F_STRUCT(
  		__field(	unsigned long,	ip	)
  		__dynamic_array(	char,	buf	)
  	),
09ae72348   Steven Rostedt (Red Hat)   tracing: Add trac...
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
  	F_printk("%pf: %s",
  		 (void *)__entry->ip, __entry->buf),
  
  	FILTER_OTHER
  );
  
  FTRACE_ENTRY(bputs, bputs_entry,
  
  	TRACE_BPUTS,
  
  	F_STRUCT(
  		__field(	unsigned long,	ip	)
  		__field(	const char *,	str	)
  	),
  
  	F_printk("%pf: %s",
  		 (void *)__entry->ip, __entry->str),
02aa3162e   Jiri Olsa   ftrace: Allow to ...
263
264
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
265
266
267
268
269
270
271
  );
  
  FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw,
  
  	TRACE_MMIO_RW,
  
  	F_STRUCT(
d73150943   Steven Rostedt   tracing: show det...
272
273
274
275
276
277
278
  		__field_struct(	struct mmiotrace_rw,	rw	)
  		__field_desc(	resource_size_t, rw,	phys	)
  		__field_desc(	unsigned long,	rw,	value	)
  		__field_desc(	unsigned long,	rw,	pc	)
  		__field_desc(	int, 		rw,	map_id	)
  		__field_desc(	unsigned char,	rw,	opcode	)
  		__field_desc(	unsigned char,	rw,	width	)
0a1c49db8   Steven Rostedt   tracing: use macr...
279
  	),
c16de8fd7   Li Zefan   tracing: fix F_pr...
280
281
  	F_printk("%lx %lx %lx %d %x %x",
  		 (unsigned long)__entry->phys, __entry->value, __entry->pc,
02aa3162e   Jiri Olsa   ftrace: Allow to ...
282
283
284
  		 __entry->map_id, __entry->opcode, __entry->width),
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
285
286
287
288
289
290
291
  );
  
  FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map,
  
  	TRACE_MMIO_MAP,
  
  	F_STRUCT(
d73150943   Steven Rostedt   tracing: show det...
292
293
294
295
296
297
  		__field_struct(	struct mmiotrace_map,	map	)
  		__field_desc(	resource_size_t, map,	phys	)
  		__field_desc(	unsigned long,	map,	virt	)
  		__field_desc(	unsigned long,	map,	len	)
  		__field_desc(	int, 		map,	map_id	)
  		__field_desc(	unsigned char,	map,	opcode	)
0a1c49db8   Steven Rostedt   tracing: use macr...
298
  	),
c16de8fd7   Li Zefan   tracing: fix F_pr...
299
300
  	F_printk("%lx %lx %lx %d %x",
  		 (unsigned long)__entry->phys, __entry->virt, __entry->len,
02aa3162e   Jiri Olsa   ftrace: Allow to ...
301
302
303
  		 __entry->map_id, __entry->opcode),
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
304
  );
0a1c49db8   Steven Rostedt   tracing: use macr...
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
  
  #define TRACE_FUNC_SIZE 30
  #define TRACE_FILE_SIZE 20
  
  FTRACE_ENTRY(branch, trace_branch,
  
  	TRACE_BRANCH,
  
  	F_STRUCT(
  		__field(	unsigned int,	line				)
  		__array(	char,		func,	TRACE_FUNC_SIZE+1	)
  		__array(	char,		file,	TRACE_FILE_SIZE+1	)
  		__field(	char,		correct				)
  	),
  
  	F_printk("%u:%s:%s (%u)",
  		 __entry->line,
02aa3162e   Jiri Olsa   ftrace: Allow to ...
322
323
324
  		 __entry->func, __entry->file, __entry->correct),
  
  	FILTER_OTHER
0a1c49db8   Steven Rostedt   tracing: use macr...
325
  );