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;
9 * <type2> <item2>[<len>];
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
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.
31 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
32 DECLARE_EVENT_CLASS(name, \
38 DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));
42 #define __field(type, item) type item;
45 #define __field_ext(type, item, filter_type) type item;
48 #define __array(type, item, len) type item[len];
50 #undef __dynamic_array
51 #define __dynamic_array(type, item, len) u32 __data_loc_##item;
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; \
67 #define DEFINE_EVENT(template, name, proto, args) \
68 static struct ftrace_event_call event_##name
70 #undef DEFINE_EVENT_PRINT
71 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
72 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
75 #define __cpparg(arg...) arg
77 /* Callbacks are meaningless to ftrace. */
79 #define TRACE_EVENT_FN(name, proto, args, tstruct, \
80 assign, print, reg, unreg) \
81 TRACE_EVENT(name, __cpparg(proto), __cpparg(args), \
82 __cpparg(tstruct), __cpparg(assign), __cpparg(print)) \
84 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
88 * Stage 2 of the trace events.
90 * Include the following:
92 * struct ftrace_data_offsets_<call> {
98 * The __dynamic_array() macro will create each u32 <item>, this is
99 * to keep the offset of each array from the beginning of the event.
100 * The size of an array is also encoded, in the higher 16 bits of <item>.
104 #define __field(type, item)
107 #define __field_ext(type, item, filter_type)
110 #define __array(type, item, len)
112 #undef __dynamic_array
113 #define __dynamic_array(type, item, len) u32 item;
116 #define __string(item, src) __dynamic_array(char, item, -1)
118 #undef DECLARE_EVENT_CLASS
119 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
120 struct ftrace_data_offsets_##call { \
125 #define DEFINE_EVENT(template, name, proto, args)
127 #undef DEFINE_EVENT_PRINT
128 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
129 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
131 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
134 * Setup the showing format of trace point.
137 * ftrace_format_##call(struct trace_seq *s)
139 * struct ftrace_raw_##call field;
142 * ret = trace_seq_printf(s, #type " " #item ";"
143 * " offset:%u; size:%u;\n",
144 * offsetof(struct ftrace_raw_##call, item),
145 * sizeof(field.type));
150 #undef TP_STRUCT__entry
151 #define TP_STRUCT__entry(args...) args
154 #define __field(type, item) \
155 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
156 "offset:%u;\tsize:%u;\tsigned:%u;\n", \
157 (unsigned int)offsetof(typeof(field), item), \
158 (unsigned int)sizeof(field.item), \
159 (unsigned int)is_signed_type(type)); \
164 #define __field_ext(type, item, filter_type) __field(type, item)
167 #define __array(type, item, len) \
168 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
169 "offset:%u;\tsize:%u;\tsigned:%u;\n", \
170 (unsigned int)offsetof(typeof(field), item), \
171 (unsigned int)sizeof(field.item), \
172 (unsigned int)is_signed_type(type)); \
176 #undef __dynamic_array
177 #define __dynamic_array(type, item, len) \
178 ret = trace_seq_printf(s, "\tfield:__data_loc " #type "[] " #item ";\t"\
179 "offset:%u;\tsize:%u;\tsigned:%u;\n", \
180 (unsigned int)offsetof(typeof(field), \
181 __data_loc_##item), \
182 (unsigned int)sizeof(field.__data_loc_##item), \
183 (unsigned int)is_signed_type(type)); \
188 #define __string(item, src) __dynamic_array(char, item, -1)
193 #undef __print_symbolic
194 #undef __get_dynamic_array
198 #define TP_printk(fmt, args...) "\"%s\", %s\n", fmt, __stringify(args)
200 #undef TP_fast_assign
201 #define TP_fast_assign(args...) args
203 #undef TP_perf_assign
204 #define TP_perf_assign(args...)
206 #undef DECLARE_EVENT_CLASS
207 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
209 ftrace_format_setup_##call(struct ftrace_event_call *unused, \
210 struct trace_seq *s) \
212 struct ftrace_raw_##call field __attribute__((unused)); \
221 ftrace_format_##call(struct ftrace_event_call *unused, \
222 struct trace_seq *s) \
226 ret = ftrace_format_setup_##call(unused, s); \
230 ret = trace_seq_printf(s, "\nprint fmt: " print); \
236 #define DEFINE_EVENT(template, name, proto, args)
238 #undef DEFINE_EVENT_PRINT
239 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
241 ftrace_format_##name(struct ftrace_event_call *unused, \
242 struct trace_seq *s) \
246 ret = ftrace_format_setup_##template(unused, s); \
250 trace_seq_printf(s, "\nprint fmt: " print); \
255 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
258 * Stage 3 of the trace events.
260 * Override the macros in <trace/trace_events.h> to include the following:
263 * ftrace_raw_output_<call>(struct trace_iterator *iter, int flags)
265 * struct trace_seq *s = &iter->seq;
266 * struct ftrace_raw_<call> *field; <-- defined in stage 1
267 * struct trace_entry *entry;
268 * struct trace_seq *p;
273 * if (entry->type != event_<call>.id) {
275 * return TRACE_TYPE_UNHANDLED;
278 * field = (typeof(field))entry;
280 * p = get_cpu_var(ftrace_event_seq);
282 * ret = trace_seq_printf(s, <TP_printk> "\n");
285 * return TRACE_TYPE_PARTIAL_LINE;
287 * return TRACE_TYPE_HANDLED;
290 * This is the method used to print the raw event to the trace
291 * output format. Note, this is not needed if the data is read
296 #define __entry field
299 #define TP_printk(fmt, args...) fmt "\n", args
301 #undef __get_dynamic_array
302 #define __get_dynamic_array(field) \
303 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
306 #define __get_str(field) (char *)__get_dynamic_array(field)
309 #define __print_flags(flag, delim, flag_array...) \
311 static const struct trace_print_flags __flags[] = \
312 { flag_array, { -1, NULL }}; \
313 ftrace_print_flags_seq(p, delim, flag, __flags); \
316 #undef __print_symbolic
317 #define __print_symbolic(value, symbol_array...) \
319 static const struct trace_print_flags symbols[] = \
320 { symbol_array, { -1, NULL }}; \
321 ftrace_print_symbols_seq(p, value, symbols); \
324 #undef DECLARE_EVENT_CLASS
325 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
326 static enum print_line_t \
327 ftrace_raw_output_id_##call(int event_id, const char *name, \
328 struct trace_iterator *iter, int flags) \
330 struct trace_seq *s = &iter->seq; \
331 struct ftrace_raw_##call *field; \
332 struct trace_entry *entry; \
333 struct trace_seq *p; \
338 if (entry->type != event_id) { \
340 return TRACE_TYPE_UNHANDLED; \
343 field = (typeof(field))entry; \
345 p = &get_cpu_var(ftrace_event_seq); \
347 ret = trace_seq_printf(s, "%s: ", name); \
349 ret = trace_seq_printf(s, print); \
352 return TRACE_TYPE_PARTIAL_LINE; \
354 return TRACE_TYPE_HANDLED; \
358 #define DEFINE_EVENT(template, name, proto, args) \
359 static enum print_line_t \
360 ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \
362 return ftrace_raw_output_id_##template(event_##name.id, \
363 #name, iter, flags); \
366 #undef DEFINE_EVENT_PRINT
367 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
368 static enum print_line_t \
369 ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
371 struct trace_seq *s = &iter->seq; \
372 struct ftrace_raw_##template *field; \
373 struct trace_entry *entry; \
374 struct trace_seq *p; \
379 if (entry->type != event_##call.id) { \
381 return TRACE_TYPE_UNHANDLED; \
384 field = (typeof(field))entry; \
386 p = &get_cpu_var(ftrace_event_seq); \
388 ret = trace_seq_printf(s, "%s: ", #call); \
390 ret = trace_seq_printf(s, print); \
393 return TRACE_TYPE_PARTIAL_LINE; \
395 return TRACE_TYPE_HANDLED; \
398 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
401 #define __field_ext(type, item, filter_type) \
402 ret = trace_define_field(event_call, #type, #item, \
403 offsetof(typeof(field), item), \
404 sizeof(field.item), \
405 is_signed_type(type), filter_type); \
410 #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
413 #define __array(type, item, len) \
414 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
415 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
416 offsetof(typeof(field), item), \
417 sizeof(field.item), 0, FILTER_OTHER); \
421 #undef __dynamic_array
422 #define __dynamic_array(type, item, len) \
423 ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \
424 offsetof(typeof(field), __data_loc_##item), \
425 sizeof(field.__data_loc_##item), 0, \
429 #define __string(item, src) __dynamic_array(char, item, -1)
431 #undef DECLARE_EVENT_CLASS
432 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
434 ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
436 struct ftrace_raw_##call field; \
439 ret = trace_define_common_fields(event_call); \
449 #define DEFINE_EVENT(template, name, proto, args)
451 #undef DEFINE_EVENT_PRINT
452 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
453 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
455 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
458 * remember the offset of each array from the beginning of the event.
462 #define __entry entry
465 #define __field(type, item)
468 #define __field_ext(type, item, filter_type)
471 #define __array(type, item, len)
473 #undef __dynamic_array
474 #define __dynamic_array(type, item, len) \
475 __data_offsets->item = __data_size + \
476 offsetof(typeof(*entry), __data); \
477 __data_offsets->item |= (len * sizeof(type)) << 16; \
478 __data_size += (len) * sizeof(type);
481 #define __string(item, src) __dynamic_array(char, item, strlen(src) + 1)
483 #undef DECLARE_EVENT_CLASS
484 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
485 static inline int ftrace_get_offsets_##call( \
486 struct ftrace_data_offsets_##call *__data_offsets, proto) \
488 int __data_size = 0; \
489 struct ftrace_raw_##call __maybe_unused *entry; \
493 return __data_size; \
497 #define DEFINE_EVENT(template, name, proto, args)
499 #undef DEFINE_EVENT_PRINT
500 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
501 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
503 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
505 #ifdef CONFIG_EVENT_PROFILE
508 * Generate the functions needed for tracepoint perf_event support.
510 * NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later
512 * static int ftrace_profile_enable_<call>(void)
514 * return register_trace_<call>(ftrace_profile_<call>);
517 * static void ftrace_profile_disable_<call>(void)
519 * unregister_trace_<call>(ftrace_profile_<call>);
524 #undef DECLARE_EVENT_CLASS
525 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)
528 #define DEFINE_EVENT(template, name, proto, args) \
530 static void ftrace_profile_##name(proto); \
532 static int ftrace_profile_enable_##name(struct ftrace_event_call *unused)\
534 return register_trace_##name(ftrace_profile_##name); \
537 static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\
539 unregister_trace_##name(ftrace_profile_##name); \
542 #undef DEFINE_EVENT_PRINT
543 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
544 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
546 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
551 * Stage 4 of the trace events.
553 * Override the macros in <trace/trace_events.h> to include the following:
555 * static void ftrace_event_<call>(proto)
557 * event_trace_printk(_RET_IP_, "<call>: " <fmt>);
560 * static int ftrace_reg_event_<call>(struct ftrace_event_call *unused)
564 * ret = register_trace_<call>(ftrace_event_<call>);
566 * pr_info("event trace: Could not activate trace point "
567 * "probe to <call>");
571 * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
573 * unregister_trace_<call>(ftrace_event_<call>);
577 * For those macros defined with TRACE_EVENT:
579 * static struct ftrace_event_call event_<call>;
581 * static void ftrace_raw_event_<call>(proto)
583 * struct ring_buffer_event *event;
584 * struct ftrace_raw_<call> *entry; <-- defined in stage 1
585 * struct ring_buffer *buffer;
586 * unsigned long irq_flags;
589 * local_save_flags(irq_flags);
590 * pc = preempt_count();
592 * event = trace_current_buffer_lock_reserve(&buffer,
594 * sizeof(struct ftrace_raw_<call>),
598 * entry = ring_buffer_event_data(event);
600 * <assign>; <-- Here we assign the entries by the __field and
603 * trace_current_buffer_unlock_commit(buffer, event, irq_flags, pc);
606 * static int ftrace_raw_reg_event_<call>(struct ftrace_event_call *unused)
610 * ret = register_trace_<call>(ftrace_raw_event_<call>);
612 * pr_info("event trace: Could not activate trace point "
613 * "probe to <call>");
617 * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
619 * unregister_trace_<call>(ftrace_raw_event_<call>);
622 * static struct trace_event ftrace_event_type_<call> = {
623 * .trace = ftrace_raw_output_<call>, <-- stage 2
626 * static int ftrace_raw_init_event_<call>(struct ftrace_event_call *unused)
630 * id = register_ftrace_event(&ftrace_event_type_<call>);
633 * event_<call>.id = id;
637 * static struct ftrace_event_call __used
638 * __attribute__((__aligned__(4)))
639 * __attribute__((section("_ftrace_events"))) event_<call> = {
641 * .system = "<system>",
642 * .raw_init = ftrace_raw_init_event_<call>,
643 * .regfunc = ftrace_reg_event_<call>,
644 * .unregfunc = ftrace_unreg_event_<call>,
645 * .show_format = ftrace_format_<call>,
651 #define TP_FMT(fmt, args...) fmt "\n", ##args
653 #ifdef CONFIG_EVENT_PROFILE
655 #define _TRACE_PROFILE_INIT(call) \
656 .profile_count = ATOMIC_INIT(-1), \
657 .profile_enable = ftrace_profile_enable_##call, \
658 .profile_disable = ftrace_profile_disable_##call,
661 #define _TRACE_PROFILE_INIT(call)
665 #define __entry entry
668 #define __field(type, item)
671 #define __array(type, item, len)
673 #undef __dynamic_array
674 #define __dynamic_array(type, item, len) \
675 __entry->__data_loc_##item = __data_offsets.item;
678 #define __string(item, src) __dynamic_array(char, item, -1) \
681 #define __assign_str(dst, src) \
682 strcpy(__get_str(dst), src);
684 #undef DECLARE_EVENT_CLASS
685 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
687 static void ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \
690 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
691 struct ring_buffer_event *event; \
692 struct ftrace_raw_##call *entry; \
693 struct ring_buffer *buffer; \
694 unsigned long irq_flags; \
698 local_save_flags(irq_flags); \
699 pc = preempt_count(); \
701 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
703 event = trace_current_buffer_lock_reserve(&buffer, \
705 sizeof(*entry) + __data_size, \
709 entry = ring_buffer_event_data(event); \
716 if (!filter_current_check_discard(buffer, event_call, entry, event)) \
717 trace_nowake_buffer_unlock_commit(buffer, \
718 event, irq_flags, pc); \
722 #define DEFINE_EVENT(template, call, proto, args) \
724 static void ftrace_raw_event_##call(proto) \
726 ftrace_raw_event_id_##template(&event_##call, args); \
729 static int ftrace_raw_reg_event_##call(struct ftrace_event_call *unused)\
733 ret = register_trace_##call(ftrace_raw_event_##call); \
735 pr_info("event trace: Could not activate trace point " \
736 "probe to " #call "\n"); \
740 static void ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused)\
742 unregister_trace_##call(ftrace_raw_event_##call); \
745 static struct trace_event ftrace_event_type_##call = { \
746 .trace = ftrace_raw_output_##call, \
749 static int ftrace_raw_init_event_##call(struct ftrace_event_call *unused)\
753 id = register_ftrace_event(&ftrace_event_type_##call); \
756 event_##call.id = id; \
757 INIT_LIST_HEAD(&event_##call.fields); \
761 #undef DEFINE_EVENT_PRINT
762 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
763 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
765 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
767 #undef DECLARE_EVENT_CLASS
768 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)
771 #define DEFINE_EVENT(template, call, proto, args) \
773 static struct ftrace_event_call __used \
774 __attribute__((__aligned__(4))) \
775 __attribute__((section("_ftrace_events"))) event_##call = { \
777 .system = __stringify(TRACE_SYSTEM), \
778 .event = &ftrace_event_type_##call, \
779 .raw_init = ftrace_raw_init_event_##call, \
780 .regfunc = ftrace_raw_reg_event_##call, \
781 .unregfunc = ftrace_raw_unreg_event_##call, \
782 .show_format = ftrace_format_##template, \
783 .define_fields = ftrace_define_fields_##template, \
784 _TRACE_PROFILE_INIT(call) \
787 #undef DEFINE_EVENT_PRINT
788 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
790 static struct ftrace_event_call __used \
791 __attribute__((__aligned__(4))) \
792 __attribute__((section("_ftrace_events"))) event_##call = { \
794 .system = __stringify(TRACE_SYSTEM), \
795 .event = &ftrace_event_type_##call, \
796 .raw_init = ftrace_raw_init_event_##call, \
797 .regfunc = ftrace_raw_reg_event_##call, \
798 .unregfunc = ftrace_raw_unreg_event_##call, \
799 .show_format = ftrace_format_##call, \
800 .define_fields = ftrace_define_fields_##template, \
801 _TRACE_PROFILE_INIT(call) \
804 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
807 * Define the insertion callback to profile events
809 * The job is very similar to ftrace_raw_event_<call> except that we don't
810 * insert in the ring buffer but in a perf counter.
812 * static void ftrace_profile_<call>(proto)
814 * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
815 * struct ftrace_event_call *event_call = &event_<call>;
816 * extern void perf_tp_event(int, u64, u64, void *, int);
817 * struct ftrace_raw_##call *entry;
818 * struct perf_trace_buf *trace_buf;
819 * u64 __addr = 0, __count = 1;
820 * unsigned long irq_flags;
821 * struct trace_entry *ent;
827 * pc = preempt_count();
829 * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
831 * // Below we want to get the aligned size by taking into account
832 * // the u32 field that will later store the buffer size
833 * __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),
835 * __entry_size -= sizeof(u32);
837 * // Protect the non nmi buffer
838 * // This also protects the rcu read side
839 * local_irq_save(irq_flags);
840 * __cpu = smp_processor_id();
843 * trace_buf = rcu_dereference(perf_trace_buf_nmi);
845 * trace_buf = rcu_dereference(perf_trace_buf);
850 * trace_buf = per_cpu_ptr(trace_buf, __cpu);
852 * // Avoid recursion from perf that could mess up the buffer
853 * if (trace_buf->recursion++)
854 * goto end_recursion;
856 * raw_data = trace_buf->buf;
858 * // Make recursion update visible before entering perf_tp_event
859 * // so that we protect from perf recursions.
863 * //zero dead bytes from alignment to avoid stack leak to userspace:
864 * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL;
865 * entry = (struct ftrace_raw_<call> *)raw_data;
867 * tracing_generic_entry_update(ent, irq_flags, pc);
868 * ent->type = event_call->id;
870 * <tstruct> <- do some jobs with dynamic arrays
872 * <assign> <- affect our values
874 * perf_tp_event(event_call->id, __addr, __count, entry,
875 * __entry_size); <- submit them to perf counter
880 #ifdef CONFIG_EVENT_PROFILE
883 #define __perf_addr(a) __addr = (a)
886 #define __perf_count(c) __count = (c)
888 #undef DECLARE_EVENT_CLASS
889 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
891 ftrace_profile_templ_##call(struct ftrace_event_call *event_call, \
894 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
895 extern int perf_swevent_get_recursion_context(void); \
896 extern void perf_swevent_put_recursion_context(int rctx); \
897 extern void perf_tp_event(int, u64, u64, void *, int); \
898 struct ftrace_raw_##call *entry; \
899 u64 __addr = 0, __count = 1; \
900 unsigned long irq_flags; \
901 struct trace_entry *ent; \
910 pc = preempt_count(); \
912 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
913 __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
915 __entry_size -= sizeof(u32); \
917 if (WARN_ONCE(__entry_size > FTRACE_MAX_PROFILE_SIZE, \
918 "profile buffer not large enough")) \
921 local_irq_save(irq_flags); \
923 rctx = perf_swevent_get_recursion_context(); \
925 goto end_recursion; \
927 __cpu = smp_processor_id(); \
930 trace_buf = rcu_dereference(perf_trace_buf_nmi); \
932 trace_buf = rcu_dereference(perf_trace_buf); \
937 raw_data = per_cpu_ptr(trace_buf, __cpu); \
939 *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; \
940 entry = (struct ftrace_raw_##call *)raw_data; \
942 tracing_generic_entry_update(ent, irq_flags, pc); \
943 ent->type = event_call->id; \
949 perf_tp_event(event_call->id, __addr, __count, entry, \
953 perf_swevent_put_recursion_context(rctx); \
955 local_irq_restore(irq_flags); \
960 #define DEFINE_EVENT(template, call, proto, args) \
961 static void ftrace_profile_##call(proto) \
963 struct ftrace_event_call *event_call = &event_##call; \
965 ftrace_profile_templ_##template(event_call, args); \
968 #undef DEFINE_EVENT_PRINT
969 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
970 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
972 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
973 #endif /* CONFIG_EVENT_PROFILE */
975 #undef _TRACE_PROFILE_INIT