code style scripts/checkpatch.pl (linux-3.9-rc1) formatting
[linux-2.6.34.14-moxart.git] / include / trace / ftrace.h
blobea6f9d4a20e9c849cbfdf99c4bf9e532a0058b70
1 /*
2 * Stage 1 of the trace events.
4 * Override the macros in <trace/trace_events.h> to include the following:
6 * struct ftrace_raw_<call> {
7 * struct trace_entry ent;
8 * <type> <item>;
9 * <type2> <item2>[<len>];
10 * [...]
11 * };
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.
19 #include <linux/ftrace_event.h>
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.
28 * TRACE_EVENT is a one to one mapping between tracepoint and template.
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));
41 #undef __field
42 #define __field(type, item) type item;
44 #undef __field_ext
45 #define __field_ext(type, item, filter_type) type item;
47 #undef __array
48 #define __array(type, item, len) type item[len];
50 #undef __dynamic_array
51 #define __dynamic_array(type, item, len) u32 __data_loc_##item;
53 #undef __string
54 #define __string(item, src) __dynamic_array(char, item, -1)
56 #undef TP_STRUCT__entry
57 #define TP_STRUCT__entry(args...) args
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]; \
66 #undef DEFINE_EVENT
67 #define DEFINE_EVENT(template, name, proto, args) \
68 static struct ftrace_event_call \
69 __attribute__((__aligned__(4))) event_##name
71 #undef DEFINE_EVENT_PRINT
72 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
73 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
75 #undef __cpparg
76 #define __cpparg(arg...) arg
78 /* Callbacks are meaningless to ftrace. */
79 #undef TRACE_EVENT_FN
80 #define TRACE_EVENT_FN(name, proto, args, tstruct, \
81 assign, print, reg, unreg) \
82 TRACE_EVENT(name, __cpparg(proto), __cpparg(args), \
83 __cpparg(tstruct), __cpparg(assign), __cpparg(print)) \
85 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
89 * Stage 2 of the trace events.
91 * Include the following:
93 * struct ftrace_data_offsets_<call> {
94 * u32 <item1>;
95 * u32 <item2>;
96 * [...]
97 * };
99 * The __dynamic_array() macro will create each u32 <item>, this is
100 * to keep the offset of each array from the beginning of the event.
101 * The size of an array is also encoded, in the higher 16 bits of <item>.
104 #undef __field
105 #define __field(type, item)
107 #undef __field_ext
108 #define __field_ext(type, item, filter_type)
110 #undef __array
111 #define __array(type, item, len)
113 #undef __dynamic_array
114 #define __dynamic_array(type, item, len) u32 item;
116 #undef __string
117 #define __string(item, src) __dynamic_array(char, item, -1)
119 #undef DECLARE_EVENT_CLASS
120 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
121 struct ftrace_data_offsets_##call { \
122 tstruct; \
125 #undef DEFINE_EVENT
126 #define DEFINE_EVENT(template, name, proto, args)
128 #undef DEFINE_EVENT_PRINT
129 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
130 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
132 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
135 * Stage 3 of the trace events.
137 * Override the macros in <trace/trace_events.h> to include the following:
139 * enum print_line_t
140 * ftrace_raw_output_<call>(struct trace_iterator *iter, int flags)
142 * struct trace_seq *s = &iter->seq;
143 * struct ftrace_raw_<call> *field; <-- defined in stage 1
144 * struct trace_entry *entry;
145 * struct trace_seq *p;
146 * int ret;
148 * entry = iter->ent;
150 * if (entry->type != event_<call>.id) {
151 * WARN_ON_ONCE(1);
152 * return TRACE_TYPE_UNHANDLED;
155 * field = (typeof(field))entry;
157 * p = get_cpu_var(ftrace_event_seq);
158 * trace_seq_init(p);
159 * ret = trace_seq_printf(s, <TP_printk> "\n");
160 * put_cpu();
161 * if (!ret)
162 * return TRACE_TYPE_PARTIAL_LINE;
164 * return TRACE_TYPE_HANDLED;
167 * This is the method used to print the raw event to the trace
168 * output format. Note, this is not needed if the data is read
169 * in binary.
172 #undef __entry
173 #define __entry field
175 #undef TP_printk
176 #define TP_printk(fmt, args...) fmt "\n", args
178 #undef __get_dynamic_array
179 #define __get_dynamic_array(field) \
180 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
182 #undef __get_str
183 #define __get_str(field) (char *)__get_dynamic_array(field)
185 #undef __print_flags
186 #define __print_flags(flag, delim, flag_array...) \
187 ({ \
188 static const struct trace_print_flags __flags[] = \
189 { flag_array, { -1, NULL }}; \
190 ftrace_print_flags_seq(p, delim, flag, __flags); \
193 #undef __print_symbolic
194 #define __print_symbolic(value, symbol_array...) \
195 ({ \
196 static const struct trace_print_flags symbols[] = \
197 { symbol_array, { -1, NULL }}; \
198 ftrace_print_symbols_seq(p, value, symbols); \
201 #undef DECLARE_EVENT_CLASS
202 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
203 static notrace enum print_line_t \
204 ftrace_raw_output_id_##call(int event_id, const char *name, \
205 struct trace_iterator *iter, int flags) \
207 struct trace_seq *s = &iter->seq; \
208 struct ftrace_raw_##call *field; \
209 struct trace_entry *entry; \
210 struct trace_seq *p; \
211 int ret; \
213 entry = iter->ent; \
215 if (entry->type != event_id) { \
216 WARN_ON_ONCE(1); \
217 return TRACE_TYPE_UNHANDLED; \
220 field = (typeof(field))entry; \
222 p = &get_cpu_var(ftrace_event_seq); \
223 trace_seq_init(p); \
224 ret = trace_seq_printf(s, "%s: ", name); \
225 if (ret) \
226 ret = trace_seq_printf(s, print); \
227 put_cpu(); \
228 if (!ret) \
229 return TRACE_TYPE_PARTIAL_LINE; \
231 return TRACE_TYPE_HANDLED; \
234 #undef DEFINE_EVENT
235 #define DEFINE_EVENT(template, name, proto, args) \
236 static notrace enum print_line_t \
237 ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \
239 return ftrace_raw_output_id_##template(event_##name.id, \
240 #name, iter, flags); \
243 #undef DEFINE_EVENT_PRINT
244 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
245 static notrace enum print_line_t \
246 ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
248 struct trace_seq *s = &iter->seq; \
249 struct ftrace_raw_##template *field; \
250 struct trace_entry *entry; \
251 struct trace_seq *p; \
252 int ret; \
254 entry = iter->ent; \
256 if (entry->type != event_##call.id) { \
257 WARN_ON_ONCE(1); \
258 return TRACE_TYPE_UNHANDLED; \
261 field = (typeof(field))entry; \
263 p = &get_cpu_var(ftrace_event_seq); \
264 trace_seq_init(p); \
265 ret = trace_seq_printf(s, "%s: ", #call); \
266 if (ret) \
267 ret = trace_seq_printf(s, print); \
268 put_cpu(); \
269 if (!ret) \
270 return TRACE_TYPE_PARTIAL_LINE; \
272 return TRACE_TYPE_HANDLED; \
275 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
277 #undef __field_ext
278 #define __field_ext(type, item, filter_type) \
279 ret = trace_define_field(event_call, #type, #item, \
280 offsetof(typeof(field), item), \
281 sizeof(field.item), \
282 is_signed_type(type), filter_type); \
283 if (ret) \
284 return ret;
286 #undef __field
287 #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
289 #undef __array
290 #define __array(type, item, len) \
291 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
292 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
293 offsetof(typeof(field), item), \
294 sizeof(field.item), \
295 is_signed_type(type), FILTER_OTHER); \
296 if (ret) \
297 return ret;
299 #undef __dynamic_array
300 #define __dynamic_array(type, item, len) \
301 ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \
302 offsetof(typeof(field), __data_loc_##item), \
303 sizeof(field.__data_loc_##item), \
304 is_signed_type(type), FILTER_OTHER);
306 #undef __string
307 #define __string(item, src) __dynamic_array(char, item, -1)
309 #undef DECLARE_EVENT_CLASS
310 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
311 static int notrace \
312 ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
314 struct ftrace_raw_##call field; \
315 int ret; \
317 tstruct; \
319 return ret; \
322 #undef DEFINE_EVENT
323 #define DEFINE_EVENT(template, name, proto, args)
325 #undef DEFINE_EVENT_PRINT
326 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
327 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
329 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
332 * remember the offset of each array from the beginning of the event.
335 #undef __entry
336 #define __entry entry
338 #undef __field
339 #define __field(type, item)
341 #undef __field_ext
342 #define __field_ext(type, item, filter_type)
344 #undef __array
345 #define __array(type, item, len)
347 #undef __dynamic_array
348 #define __dynamic_array(type, item, len) \
349 __data_offsets->item = __data_size + \
350 offsetof(typeof(*entry), __data); \
351 __data_offsets->item |= (len * sizeof(type)) << 16; \
352 __data_size += (len) * sizeof(type);
354 #undef __string
355 #define __string(item, src) __dynamic_array(char, item, strlen(src) + 1)
357 #undef DECLARE_EVENT_CLASS
358 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
359 static inline notrace int ftrace_get_offsets_##call( \
360 struct ftrace_data_offsets_##call *__data_offsets, proto) \
362 int __data_size = 0; \
363 struct ftrace_raw_##call __maybe_unused *entry; \
365 tstruct; \
367 return __data_size; \
370 #undef DEFINE_EVENT
371 #define DEFINE_EVENT(template, name, proto, args)
373 #undef DEFINE_EVENT_PRINT
374 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
375 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
377 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
379 #ifdef CONFIG_PERF_EVENTS
382 * Generate the functions needed for tracepoint perf_event support.
384 * NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later
386 * static int ftrace_profile_enable_<call>(void)
388 * return register_trace_<call>(ftrace_profile_<call>);
391 * static void ftrace_profile_disable_<call>(void)
393 * unregister_trace_<call>(ftrace_profile_<call>);
398 #undef DECLARE_EVENT_CLASS
399 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)
401 #undef DEFINE_EVENT
402 #define DEFINE_EVENT(template, name, proto, args) \
404 static void perf_trace_##name(proto); \
406 static notrace int \
407 perf_trace_enable_##name(struct ftrace_event_call *unused) \
409 return register_trace_##name(perf_trace_##name); \
412 static notrace void \
413 perf_trace_disable_##name(struct ftrace_event_call *unused) \
415 unregister_trace_##name(perf_trace_##name); \
418 #undef DEFINE_EVENT_PRINT
419 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
420 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
422 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
424 #endif /* CONFIG_PERF_EVENTS */
427 * Stage 4 of the trace events.
429 * Override the macros in <trace/trace_events.h> to include the following:
431 * static void ftrace_event_<call>(proto)
433 * event_trace_printk(_RET_IP_, "<call>: " <fmt>);
436 * static int ftrace_reg_event_<call>(struct ftrace_event_call *unused)
438 * return register_trace_<call>(ftrace_event_<call>);
441 * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
443 * unregister_trace_<call>(ftrace_event_<call>);
447 * For those macros defined with TRACE_EVENT:
449 * static struct ftrace_event_call event_<call>;
451 * static void ftrace_raw_event_<call>(proto)
453 * struct ring_buffer_event *event;
454 * struct ftrace_raw_<call> *entry; <-- defined in stage 1
455 * struct ring_buffer *buffer;
456 * unsigned long irq_flags;
457 * int pc;
459 * local_save_flags(irq_flags);
460 * pc = preempt_count();
462 * event = trace_current_buffer_lock_reserve(&buffer,
463 * event_<call>.id,
464 * sizeof(struct ftrace_raw_<call>),
465 * irq_flags, pc);
466 * if (!event)
467 * return;
468 * entry = ring_buffer_event_data(event);
470 * <assign>; <-- Here we assign the entries by the __field and
471 * __array macros.
473 * trace_current_buffer_unlock_commit(buffer, event, irq_flags, pc);
476 * static int ftrace_raw_reg_event_<call>(struct ftrace_event_call *unused)
478 * int ret;
480 * ret = register_trace_<call>(ftrace_raw_event_<call>);
481 * if (!ret)
482 * pr_info("event trace: Could not activate trace point "
483 * "probe to <call>");
484 * return ret;
487 * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
489 * unregister_trace_<call>(ftrace_raw_event_<call>);
492 * static struct trace_event ftrace_event_type_<call> = {
493 * .trace = ftrace_raw_output_<call>, <-- stage 2
494 * };
496 * static struct ftrace_event_call __used
497 * __attribute__((__aligned__(4)))
498 * __attribute__((section("_ftrace_events"))) event_<call> = {
499 * .name = "<call>",
500 * .system = "<system>",
501 * .raw_init = trace_event_raw_init,
502 * .regfunc = ftrace_reg_event_<call>,
503 * .unregfunc = ftrace_unreg_event_<call>,
508 #ifdef CONFIG_PERF_EVENTS
510 #define _TRACE_PERF_INIT(call) \
511 .perf_event_enable = perf_trace_enable_##call, \
512 .perf_event_disable = perf_trace_disable_##call,
514 #else
515 #define _TRACE_PERF_INIT(call)
516 #endif /* CONFIG_PERF_EVENTS */
518 #undef __entry
519 #define __entry entry
521 #undef __field
522 #define __field(type, item)
524 #undef __array
525 #define __array(type, item, len)
527 #undef __dynamic_array
528 #define __dynamic_array(type, item, len) \
529 __entry->__data_loc_##item = __data_offsets.item;
531 #undef __string
532 #define __string(item, src) __dynamic_array(char, item, -1) \
534 #undef __assign_str
535 #define __assign_str(dst, src) \
536 strcpy(__get_str(dst), src);
538 #undef TP_fast_assign
539 #define TP_fast_assign(args...) args
541 #undef TP_perf_assign
542 #define TP_perf_assign(args...)
544 #undef DECLARE_EVENT_CLASS
545 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
547 static notrace void \
548 ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \
549 proto) \
551 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
552 struct ring_buffer_event *event; \
553 struct ftrace_raw_##call *entry; \
554 struct ring_buffer *buffer; \
555 unsigned long irq_flags; \
556 int __data_size; \
557 int pc; \
559 local_save_flags(irq_flags); \
560 pc = preempt_count(); \
562 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
564 event = trace_current_buffer_lock_reserve(&buffer, \
565 event_call->id, \
566 sizeof(*entry) + __data_size, \
567 irq_flags, pc); \
568 if (!event) \
569 return; \
570 entry = ring_buffer_event_data(event); \
573 tstruct \
575 { assign; } \
577 if (!filter_current_check_discard(buffer, event_call, entry, event)) \
578 trace_nowake_buffer_unlock_commit(buffer, \
579 event, irq_flags, pc); \
582 #undef DEFINE_EVENT
583 #define DEFINE_EVENT(template, call, proto, args) \
585 static notrace void ftrace_raw_event_##call(proto) \
587 ftrace_raw_event_id_##template(&event_##call, args); \
590 static notrace int \
591 ftrace_raw_reg_event_##call(struct ftrace_event_call *unused) \
593 return register_trace_##call(ftrace_raw_event_##call); \
596 static notrace void \
597 ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused) \
599 unregister_trace_##call(ftrace_raw_event_##call); \
602 static struct trace_event ftrace_event_type_##call = { \
603 .trace = ftrace_raw_output_##call, \
606 #undef DEFINE_EVENT_PRINT
607 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
608 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
610 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
612 #undef __entry
613 #define __entry REC
615 #undef __print_flags
616 #undef __print_symbolic
617 #undef __get_dynamic_array
618 #undef __get_str
620 #undef TP_printk
621 #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args)
623 #undef DECLARE_EVENT_CLASS
624 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
625 static const char print_fmt_##call[] = print;
627 #undef DEFINE_EVENT
628 #define DEFINE_EVENT(template, call, proto, args) \
630 static struct ftrace_event_call __used \
631 __attribute__((__aligned__(4))) \
632 __attribute__((section("_ftrace_events"))) event_##call = { \
633 .name = #call, \
634 .system = __stringify(TRACE_SYSTEM), \
635 .event = &ftrace_event_type_##call, \
636 .raw_init = trace_event_raw_init, \
637 .regfunc = ftrace_raw_reg_event_##call, \
638 .unregfunc = ftrace_raw_unreg_event_##call, \
639 .print_fmt = print_fmt_##template, \
640 .define_fields = ftrace_define_fields_##template, \
641 _TRACE_PERF_INIT(call) \
644 #undef DEFINE_EVENT_PRINT
645 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
647 static const char print_fmt_##call[] = print; \
649 static struct ftrace_event_call __used \
650 __attribute__((__aligned__(4))) \
651 __attribute__((section("_ftrace_events"))) event_##call = { \
652 .name = #call, \
653 .system = __stringify(TRACE_SYSTEM), \
654 .event = &ftrace_event_type_##call, \
655 .raw_init = trace_event_raw_init, \
656 .regfunc = ftrace_raw_reg_event_##call, \
657 .unregfunc = ftrace_raw_unreg_event_##call, \
658 .print_fmt = print_fmt_##call, \
659 .define_fields = ftrace_define_fields_##template, \
660 _TRACE_PERF_INIT(call) \
663 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
666 * Define the insertion callback to perf events
668 * The job is very similar to ftrace_raw_event_<call> except that we don't
669 * insert in the ring buffer but in a perf counter.
671 * static void ftrace_perf_<call>(proto)
673 * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
674 * struct ftrace_event_call *event_call = &event_<call>;
675 * extern void perf_tp_event(int, u64, u64, void *, int);
676 * struct ftrace_raw_##call *entry;
677 * struct perf_trace_buf *trace_buf;
678 * u64 __addr = 0, __count = 1;
679 * unsigned long irq_flags;
680 * struct trace_entry *ent;
681 * int __entry_size;
682 * int __data_size;
683 * int __cpu
684 * int pc;
686 * pc = preempt_count();
688 * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
690 * // Below we want to get the aligned size by taking into account
691 * // the u32 field that will later store the buffer size
692 * __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),
693 * sizeof(u64));
694 * __entry_size -= sizeof(u32);
696 * // Protect the non nmi buffer
697 * // This also protects the rcu read side
698 * local_irq_save(irq_flags);
699 * __cpu = smp_processor_id();
701 * if (in_nmi())
702 * trace_buf = rcu_dereference_sched(perf_trace_buf_nmi);
703 * else
704 * trace_buf = rcu_dereference_sched(perf_trace_buf);
706 * if (!trace_buf)
707 * goto end;
709 * trace_buf = per_cpu_ptr(trace_buf, __cpu);
711 * // Avoid recursion from perf that could mess up the buffer
712 * if (trace_buf->recursion++)
713 * goto end_recursion;
715 * raw_data = trace_buf->buf;
717 * // Make recursion update visible before entering perf_tp_event
718 * // so that we protect from perf recursions.
720 * barrier();
722 * //zero dead bytes from alignment to avoid stack leak to userspace:
723 * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL;
724 * entry = (struct ftrace_raw_<call> *)raw_data;
725 * ent = &entry->ent;
726 * tracing_generic_entry_update(ent, irq_flags, pc);
727 * ent->type = event_call->id;
729 * <tstruct> <- do some jobs with dynamic arrays
731 * <assign> <- affect our values
733 * perf_tp_event(event_call->id, __addr, __count, entry,
734 * __entry_size); <- submit them to perf counter
739 #ifdef CONFIG_PERF_EVENTS
741 #undef __entry
742 #define __entry entry
744 #undef __get_dynamic_array
745 #define __get_dynamic_array(field) \
746 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
748 #undef __get_str
749 #define __get_str(field) (char *)__get_dynamic_array(field)
751 #undef __perf_addr
752 #define __perf_addr(a) __addr = (a)
754 #undef __perf_count
755 #define __perf_count(c) __count = (c)
757 #undef DECLARE_EVENT_CLASS
758 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
759 static notrace void \
760 perf_trace_templ_##call(struct ftrace_event_call *event_call, \
761 proto) \
763 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
764 struct ftrace_raw_##call *entry; \
765 u64 __addr = 0, __count = 1; \
766 unsigned long irq_flags; \
767 struct pt_regs *__regs; \
768 int __entry_size; \
769 int __data_size; \
770 int rctx; \
772 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
773 __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
774 sizeof(u64)); \
775 __entry_size -= sizeof(u32); \
777 if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE, \
778 "profile buffer not large enough")) \
779 return; \
780 entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \
781 __entry_size, event_call->id, &rctx, &irq_flags); \
782 if (!entry) \
783 return; \
784 tstruct \
786 { assign; } \
788 __regs = &__get_cpu_var(perf_trace_regs); \
789 perf_fetch_caller_regs(__regs, 2); \
791 perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \
792 __count, irq_flags, __regs); \
795 #undef DEFINE_EVENT
796 #define DEFINE_EVENT(template, call, proto, args) \
797 static notrace void perf_trace_##call(proto) \
799 struct ftrace_event_call *event_call = &event_##call; \
801 perf_trace_templ_##template(event_call, args); \
804 #undef DEFINE_EVENT_PRINT
805 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
806 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
808 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
809 #endif /* CONFIG_PERF_EVENTS */
811 #undef _TRACE_PROFILE_INIT