Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux...
[deliverable/linux.git] / include / trace / ftrace.h
1 /*
2 * Stage 1 of the trace events.
3 *
4 * Override the macros in <trace/trace_events.h> to include the following:
5 *
6 * struct ftrace_raw_<call> {
7 * struct trace_entry ent;
8 * <type> <item>;
9 * <type2> <item2>[<len>];
10 * [...]
11 * };
12 *
13 * The <type> <item> is created by the __field(type, item) macro or
14 * the __array(type2, item2, len) macro.
15 * We simply do "type item;", and that will create the fields
16 * in the structure.
17 */
18
19 #include <linux/ftrace_event.h>
20
21 /*
22 * DECLARE_EVENT_CLASS can be used to add a generic function
23 * handlers for events. That is, if all events have the same
24 * parameters and just have distinct trace points.
25 * Each tracepoint can be defined with DEFINE_EVENT and that
26 * will map the DECLARE_EVENT_CLASS to the tracepoint.
27 *
28 * TRACE_EVENT is a one to one mapping between tracepoint and template.
29 */
30 #undef TRACE_EVENT
31 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
32 DECLARE_EVENT_CLASS(name, \
33 PARAMS(proto), \
34 PARAMS(args), \
35 PARAMS(tstruct), \
36 PARAMS(assign), \
37 PARAMS(print)); \
38 DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));
39
40
41 #undef __field
42 #define __field(type, item) type item;
43
44 #undef __field_ext
45 #define __field_ext(type, item, filter_type) type item;
46
47 #undef __array
48 #define __array(type, item, len) type item[len];
49
50 #undef __dynamic_array
51 #define __dynamic_array(type, item, len) u32 __data_loc_##item;
52
53 #undef __string
54 #define __string(item, src) __dynamic_array(char, item, -1)
55
56 #undef TP_STRUCT__entry
57 #define TP_STRUCT__entry(args...) args
58
59 #undef DECLARE_EVENT_CLASS
60 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \
61 struct ftrace_raw_##name { \
62 struct trace_entry ent; \
63 tstruct \
64 char __data[0]; \
65 }; \
66 \
67 static struct ftrace_event_class event_class_##name;
68
69 #undef DEFINE_EVENT
70 #define DEFINE_EVENT(template, name, proto, args) \
71 static struct ftrace_event_call \
72 __attribute__((__aligned__(4))) event_##name
73
74 #undef DEFINE_EVENT_PRINT
75 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
76 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
77
78 #undef __cpparg
79 #define __cpparg(arg...) arg
80
81 /* Callbacks are meaningless to ftrace. */
82 #undef TRACE_EVENT_FN
83 #define TRACE_EVENT_FN(name, proto, args, tstruct, \
84 assign, print, reg, unreg) \
85 TRACE_EVENT(name, __cpparg(proto), __cpparg(args), \
86 __cpparg(tstruct), __cpparg(assign), __cpparg(print)) \
87
88 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
89
90
91 /*
92 * Stage 2 of the trace events.
93 *
94 * Include the following:
95 *
96 * struct ftrace_data_offsets_<call> {
97 * u32 <item1>;
98 * u32 <item2>;
99 * [...]
100 * };
101 *
102 * The __dynamic_array() macro will create each u32 <item>, this is
103 * to keep the offset of each array from the beginning of the event.
104 * The size of an array is also encoded, in the higher 16 bits of <item>.
105 */
106
107 #undef __field
108 #define __field(type, item)
109
110 #undef __field_ext
111 #define __field_ext(type, item, filter_type)
112
113 #undef __array
114 #define __array(type, item, len)
115
116 #undef __dynamic_array
117 #define __dynamic_array(type, item, len) u32 item;
118
119 #undef __string
120 #define __string(item, src) __dynamic_array(char, item, -1)
121
122 #undef DECLARE_EVENT_CLASS
123 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
124 struct ftrace_data_offsets_##call { \
125 tstruct; \
126 };
127
128 #undef DEFINE_EVENT
129 #define DEFINE_EVENT(template, name, proto, args)
130
131 #undef DEFINE_EVENT_PRINT
132 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
133 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
134
135 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
136
137 /*
138 * Stage 3 of the trace events.
139 *
140 * Override the macros in <trace/trace_events.h> to include the following:
141 *
142 * enum print_line_t
143 * ftrace_raw_output_<call>(struct trace_iterator *iter, int flags)
144 * {
145 * struct trace_seq *s = &iter->seq;
146 * struct ftrace_raw_<call> *field; <-- defined in stage 1
147 * struct trace_entry *entry;
148 * struct trace_seq *p;
149 * int ret;
150 *
151 * entry = iter->ent;
152 *
153 * if (entry->type != event_<call>->event.type) {
154 * WARN_ON_ONCE(1);
155 * return TRACE_TYPE_UNHANDLED;
156 * }
157 *
158 * field = (typeof(field))entry;
159 *
160 * p = &get_cpu_var(ftrace_event_seq);
161 * trace_seq_init(p);
162 * ret = trace_seq_printf(s, "%s: ", <call>);
163 * if (ret)
164 * ret = trace_seq_printf(s, <TP_printk> "\n");
165 * put_cpu();
166 * if (!ret)
167 * return TRACE_TYPE_PARTIAL_LINE;
168 *
169 * return TRACE_TYPE_HANDLED;
170 * }
171 *
172 * This is the method used to print the raw event to the trace
173 * output format. Note, this is not needed if the data is read
174 * in binary.
175 */
176
177 #undef __entry
178 #define __entry field
179
180 #undef TP_printk
181 #define TP_printk(fmt, args...) fmt "\n", args
182
183 #undef __get_dynamic_array
184 #define __get_dynamic_array(field) \
185 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
186
187 #undef __get_str
188 #define __get_str(field) (char *)__get_dynamic_array(field)
189
190 #undef __print_flags
191 #define __print_flags(flag, delim, flag_array...) \
192 ({ \
193 static const struct trace_print_flags __flags[] = \
194 { flag_array, { -1, NULL }}; \
195 ftrace_print_flags_seq(p, delim, flag, __flags); \
196 })
197
198 #undef __print_symbolic
199 #define __print_symbolic(value, symbol_array...) \
200 ({ \
201 static const struct trace_print_flags symbols[] = \
202 { symbol_array, { -1, NULL }}; \
203 ftrace_print_symbols_seq(p, value, symbols); \
204 })
205
206 #undef DECLARE_EVENT_CLASS
207 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
208 static notrace enum print_line_t \
209 ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \
210 struct trace_event *trace_event) \
211 { \
212 struct ftrace_event_call *event; \
213 struct trace_seq *s = &iter->seq; \
214 struct ftrace_raw_##call *field; \
215 struct trace_entry *entry; \
216 struct trace_seq *p; \
217 int ret; \
218 \
219 event = container_of(trace_event, struct ftrace_event_call, \
220 event); \
221 \
222 entry = iter->ent; \
223 \
224 if (entry->type != event->event.type) { \
225 WARN_ON_ONCE(1); \
226 return TRACE_TYPE_UNHANDLED; \
227 } \
228 \
229 field = (typeof(field))entry; \
230 \
231 p = &get_cpu_var(ftrace_event_seq); \
232 trace_seq_init(p); \
233 ret = trace_seq_printf(s, "%s: ", event->name); \
234 if (ret) \
235 ret = trace_seq_printf(s, print); \
236 put_cpu(); \
237 if (!ret) \
238 return TRACE_TYPE_PARTIAL_LINE; \
239 \
240 return TRACE_TYPE_HANDLED; \
241 } \
242 static struct trace_event_functions ftrace_event_type_funcs_##call = { \
243 .trace = ftrace_raw_output_##call, \
244 };
245
246 #undef DEFINE_EVENT_PRINT
247 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
248 static notrace enum print_line_t \
249 ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \
250 struct trace_event *event) \
251 { \
252 struct trace_seq *s = &iter->seq; \
253 struct ftrace_raw_##template *field; \
254 struct trace_entry *entry; \
255 struct trace_seq *p; \
256 int ret; \
257 \
258 entry = iter->ent; \
259 \
260 if (entry->type != event_##call.event.type) { \
261 WARN_ON_ONCE(1); \
262 return TRACE_TYPE_UNHANDLED; \
263 } \
264 \
265 field = (typeof(field))entry; \
266 \
267 p = &get_cpu_var(ftrace_event_seq); \
268 trace_seq_init(p); \
269 ret = trace_seq_printf(s, "%s: ", #call); \
270 if (ret) \
271 ret = trace_seq_printf(s, print); \
272 put_cpu(); \
273 if (!ret) \
274 return TRACE_TYPE_PARTIAL_LINE; \
275 \
276 return TRACE_TYPE_HANDLED; \
277 } \
278 static struct trace_event_functions ftrace_event_type_funcs_##call = { \
279 .trace = ftrace_raw_output_##call, \
280 };
281
282 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
283
284 #undef __field_ext
285 #define __field_ext(type, item, filter_type) \
286 ret = trace_define_field(event_call, #type, #item, \
287 offsetof(typeof(field), item), \
288 sizeof(field.item), \
289 is_signed_type(type), filter_type); \
290 if (ret) \
291 return ret;
292
293 #undef __field
294 #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
295
296 #undef __array
297 #define __array(type, item, len) \
298 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
299 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
300 offsetof(typeof(field), item), \
301 sizeof(field.item), \
302 is_signed_type(type), FILTER_OTHER); \
303 if (ret) \
304 return ret;
305
306 #undef __dynamic_array
307 #define __dynamic_array(type, item, len) \
308 ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \
309 offsetof(typeof(field), __data_loc_##item), \
310 sizeof(field.__data_loc_##item), \
311 is_signed_type(type), FILTER_OTHER);
312
313 #undef __string
314 #define __string(item, src) __dynamic_array(char, item, -1)
315
316 #undef DECLARE_EVENT_CLASS
317 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
318 static int notrace \
319 ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
320 { \
321 struct ftrace_raw_##call field; \
322 int ret; \
323 \
324 tstruct; \
325 \
326 return ret; \
327 }
328
329 #undef DEFINE_EVENT
330 #define DEFINE_EVENT(template, name, proto, args)
331
332 #undef DEFINE_EVENT_PRINT
333 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
334 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
335
336 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
337
338 /*
339 * remember the offset of each array from the beginning of the event.
340 */
341
342 #undef __entry
343 #define __entry entry
344
345 #undef __field
346 #define __field(type, item)
347
348 #undef __field_ext
349 #define __field_ext(type, item, filter_type)
350
351 #undef __array
352 #define __array(type, item, len)
353
354 #undef __dynamic_array
355 #define __dynamic_array(type, item, len) \
356 __data_offsets->item = __data_size + \
357 offsetof(typeof(*entry), __data); \
358 __data_offsets->item |= (len * sizeof(type)) << 16; \
359 __data_size += (len) * sizeof(type);
360
361 #undef __string
362 #define __string(item, src) __dynamic_array(char, item, strlen(src) + 1)
363
364 #undef DECLARE_EVENT_CLASS
365 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
366 static inline notrace int ftrace_get_offsets_##call( \
367 struct ftrace_data_offsets_##call *__data_offsets, proto) \
368 { \
369 int __data_size = 0; \
370 struct ftrace_raw_##call __maybe_unused *entry; \
371 \
372 tstruct; \
373 \
374 return __data_size; \
375 }
376
377 #undef DEFINE_EVENT
378 #define DEFINE_EVENT(template, name, proto, args)
379
380 #undef DEFINE_EVENT_PRINT
381 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
382 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
383
384 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
385
386 /*
387 * Stage 4 of the trace events.
388 *
389 * Override the macros in <trace/trace_events.h> to include the following:
390 *
391 * For those macros defined with TRACE_EVENT:
392 *
393 * static struct ftrace_event_call event_<call>;
394 *
395 * static void ftrace_raw_event_<call>(void *__data, proto)
396 * {
397 * struct ftrace_event_call *event_call = __data;
398 * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
399 * struct ring_buffer_event *event;
400 * struct ftrace_raw_<call> *entry; <-- defined in stage 1
401 * struct ring_buffer *buffer;
402 * unsigned long irq_flags;
403 * int __data_size;
404 * int pc;
405 *
406 * local_save_flags(irq_flags);
407 * pc = preempt_count();
408 *
409 * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
410 *
411 * event = trace_current_buffer_lock_reserve(&buffer,
412 * event_<call>->event.type,
413 * sizeof(*entry) + __data_size,
414 * irq_flags, pc);
415 * if (!event)
416 * return;
417 * entry = ring_buffer_event_data(event);
418 *
419 * { <assign>; } <-- Here we assign the entries by the __field and
420 * __array macros.
421 *
422 * if (!filter_current_check_discard(buffer, event_call, entry, event))
423 * trace_current_buffer_unlock_commit(buffer,
424 * event, irq_flags, pc);
425 * }
426 *
427 * static struct trace_event ftrace_event_type_<call> = {
428 * .trace = ftrace_raw_output_<call>, <-- stage 2
429 * };
430 *
431 * static const char print_fmt_<call>[] = <TP_printk>;
432 *
433 * static struct ftrace_event_class __used event_class_<template> = {
434 * .system = "<system>",
435 * .define_fields = ftrace_define_fields_<call>,
436 * .fields = LIST_HEAD_INIT(event_class_##call.fields),
437 * .raw_init = trace_event_raw_init,
438 * .probe = ftrace_raw_event_##call,
439 * };
440 *
441 * static struct ftrace_event_call __used
442 * __attribute__((__aligned__(4)))
443 * __attribute__((section("_ftrace_events"))) event_<call> = {
444 * .name = "<call>",
445 * .class = event_class_<template>,
446 * .event = &ftrace_event_type_<call>,
447 * .print_fmt = print_fmt_<call>,
448 * };
449 *
450 */
451
452 #ifdef CONFIG_PERF_EVENTS
453
454 #define _TRACE_PERF_PROTO(call, proto) \
455 static notrace void \
456 perf_trace_##call(void *__data, proto);
457
458 #define _TRACE_PERF_INIT(call) \
459 .perf_probe = perf_trace_##call,
460
461 #else
462 #define _TRACE_PERF_PROTO(call, proto)
463 #define _TRACE_PERF_INIT(call)
464 #endif /* CONFIG_PERF_EVENTS */
465
466 #undef __entry
467 #define __entry entry
468
469 #undef __field
470 #define __field(type, item)
471
472 #undef __array
473 #define __array(type, item, len)
474
475 #undef __dynamic_array
476 #define __dynamic_array(type, item, len) \
477 __entry->__data_loc_##item = __data_offsets.item;
478
479 #undef __string
480 #define __string(item, src) __dynamic_array(char, item, -1) \
481
482 #undef __assign_str
483 #define __assign_str(dst, src) \
484 strcpy(__get_str(dst), src);
485
486 #undef TP_fast_assign
487 #define TP_fast_assign(args...) args
488
489 #undef TP_perf_assign
490 #define TP_perf_assign(args...)
491
492 #undef DECLARE_EVENT_CLASS
493 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
494 \
495 static notrace void \
496 ftrace_raw_event_##call(void *__data, proto) \
497 { \
498 struct ftrace_event_call *event_call = __data; \
499 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
500 struct ring_buffer_event *event; \
501 struct ftrace_raw_##call *entry; \
502 struct ring_buffer *buffer; \
503 unsigned long irq_flags; \
504 int __data_size; \
505 int pc; \
506 \
507 local_save_flags(irq_flags); \
508 pc = preempt_count(); \
509 \
510 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
511 \
512 event = trace_current_buffer_lock_reserve(&buffer, \
513 event_call->event.type, \
514 sizeof(*entry) + __data_size, \
515 irq_flags, pc); \
516 if (!event) \
517 return; \
518 entry = ring_buffer_event_data(event); \
519 \
520 tstruct \
521 \
522 { assign; } \
523 \
524 if (!filter_current_check_discard(buffer, event_call, entry, event)) \
525 trace_nowake_buffer_unlock_commit(buffer, \
526 event, irq_flags, pc); \
527 }
528 /*
529 * The ftrace_test_probe is compiled out, it is only here as a build time check
530 * to make sure that if the tracepoint handling changes, the ftrace probe will
531 * fail to compile unless it too is updated.
532 */
533
534 #undef DEFINE_EVENT
535 #define DEFINE_EVENT(template, call, proto, args) \
536 static inline void ftrace_test_probe_##call(void) \
537 { \
538 check_trace_callback_type_##call(ftrace_raw_event_##template); \
539 }
540
541 #undef DEFINE_EVENT_PRINT
542 #define DEFINE_EVENT_PRINT(template, name, proto, args, print)
543
544 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
545
546 #undef __entry
547 #define __entry REC
548
549 #undef __print_flags
550 #undef __print_symbolic
551 #undef __get_dynamic_array
552 #undef __get_str
553
554 #undef TP_printk
555 #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args)
556
557 #undef DECLARE_EVENT_CLASS
558 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
559 _TRACE_PERF_PROTO(call, PARAMS(proto)); \
560 static const char print_fmt_##call[] = print; \
561 static struct ftrace_event_class __used event_class_##call = { \
562 .system = __stringify(TRACE_SYSTEM), \
563 .define_fields = ftrace_define_fields_##call, \
564 .fields = LIST_HEAD_INIT(event_class_##call.fields),\
565 .raw_init = trace_event_raw_init, \
566 .probe = ftrace_raw_event_##call, \
567 _TRACE_PERF_INIT(call) \
568 };
569
570 #undef DEFINE_EVENT
571 #define DEFINE_EVENT(template, call, proto, args) \
572 \
573 static struct ftrace_event_call __used \
574 __attribute__((__aligned__(4))) \
575 __attribute__((section("_ftrace_events"))) event_##call = { \
576 .name = #call, \
577 .class = &event_class_##template, \
578 .event.funcs = &ftrace_event_type_funcs_##template, \
579 .print_fmt = print_fmt_##template, \
580 };
581
582 #undef DEFINE_EVENT_PRINT
583 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
584 \
585 static const char print_fmt_##call[] = print; \
586 \
587 static struct ftrace_event_call __used \
588 __attribute__((__aligned__(4))) \
589 __attribute__((section("_ftrace_events"))) event_##call = { \
590 .name = #call, \
591 .class = &event_class_##template, \
592 .event.funcs = &ftrace_event_type_funcs_##call, \
593 .print_fmt = print_fmt_##call, \
594 }
595
596 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
597
598 /*
599 * Define the insertion callback to perf events
600 *
601 * The job is very similar to ftrace_raw_event_<call> except that we don't
602 * insert in the ring buffer but in a perf counter.
603 *
604 * static void ftrace_perf_<call>(proto)
605 * {
606 * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
607 * struct ftrace_event_call *event_call = &event_<call>;
608 * extern void perf_tp_event(int, u64, u64, void *, int);
609 * struct ftrace_raw_##call *entry;
610 * struct perf_trace_buf *trace_buf;
611 * u64 __addr = 0, __count = 1;
612 * unsigned long irq_flags;
613 * struct trace_entry *ent;
614 * int __entry_size;
615 * int __data_size;
616 * int __cpu
617 * int pc;
618 *
619 * pc = preempt_count();
620 *
621 * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
622 *
623 * // Below we want to get the aligned size by taking into account
624 * // the u32 field that will later store the buffer size
625 * __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),
626 * sizeof(u64));
627 * __entry_size -= sizeof(u32);
628 *
629 * // Protect the non nmi buffer
630 * // This also protects the rcu read side
631 * local_irq_save(irq_flags);
632 * __cpu = smp_processor_id();
633 *
634 * if (in_nmi())
635 * trace_buf = rcu_dereference_sched(perf_trace_buf_nmi);
636 * else
637 * trace_buf = rcu_dereference_sched(perf_trace_buf);
638 *
639 * if (!trace_buf)
640 * goto end;
641 *
642 * trace_buf = per_cpu_ptr(trace_buf, __cpu);
643 *
644 * // Avoid recursion from perf that could mess up the buffer
645 * if (trace_buf->recursion++)
646 * goto end_recursion;
647 *
648 * raw_data = trace_buf->buf;
649 *
650 * // Make recursion update visible before entering perf_tp_event
651 * // so that we protect from perf recursions.
652 *
653 * barrier();
654 *
655 * //zero dead bytes from alignment to avoid stack leak to userspace:
656 * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL;
657 * entry = (struct ftrace_raw_<call> *)raw_data;
658 * ent = &entry->ent;
659 * tracing_generic_entry_update(ent, irq_flags, pc);
660 * ent->type = event_call->id;
661 *
662 * <tstruct> <- do some jobs with dynamic arrays
663 *
664 * <assign> <- affect our values
665 *
666 * perf_tp_event(event_call->id, __addr, __count, entry,
667 * __entry_size); <- submit them to perf counter
668 *
669 * }
670 */
671
672 #ifdef CONFIG_PERF_EVENTS
673
674 #undef __entry
675 #define __entry entry
676
677 #undef __get_dynamic_array
678 #define __get_dynamic_array(field) \
679 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
680
681 #undef __get_str
682 #define __get_str(field) (char *)__get_dynamic_array(field)
683
684 #undef __perf_addr
685 #define __perf_addr(a) __addr = (a)
686
687 #undef __perf_count
688 #define __perf_count(c) __count = (c)
689
690 #undef DECLARE_EVENT_CLASS
691 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
692 static notrace void \
693 perf_trace_##call(void *__data, proto) \
694 { \
695 struct ftrace_event_call *event_call = __data; \
696 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
697 struct ftrace_raw_##call *entry; \
698 struct pt_regs *__regs = &get_cpu_var(perf_trace_regs); \
699 u64 __addr = 0, __count = 1; \
700 unsigned long irq_flags; \
701 int __entry_size; \
702 int __data_size; \
703 int rctx; \
704 \
705 perf_fetch_caller_regs(__regs, 1); \
706 \
707 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
708 __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
709 sizeof(u64)); \
710 __entry_size -= sizeof(u32); \
711 \
712 if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE, \
713 "profile buffer not large enough")) \
714 goto out; \
715 entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \
716 __entry_size, event_call->event.type, &rctx, &irq_flags); \
717 if (!entry) \
718 goto out; \
719 tstruct \
720 \
721 { assign; } \
722 \
723 perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \
724 __count, irq_flags, __regs); \
725 out: \
726 put_cpu_var(perf_trace_regs); \
727 }
728
729 /*
730 * This part is compiled out, it is only here as a build time check
731 * to make sure that if the tracepoint handling changes, the
732 * perf probe will fail to compile unless it too is updated.
733 */
734 #undef DEFINE_EVENT
735 #define DEFINE_EVENT(template, call, proto, args) \
736 static inline void perf_test_probe_##call(void) \
737 { \
738 check_trace_callback_type_##call(perf_trace_##template); \
739 \
740 }
741
742
743 #undef DEFINE_EVENT_PRINT
744 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
745 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
746
747 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
748 #endif /* CONFIG_PERF_EVENTS */
749
750 #undef _TRACE_PROFILE_INIT
751
This page took 0.047242 seconds and 5 git commands to generate.