61fac2fec8ff618cecd409cea610d016218fcfc6
2 #include <lttng-types.h>
5 * Macros mapping tp_assign() to "=", tp_memcpy() to memcpy() and tp_strcpy() to
9 #define tp_assign(dest, src) \
10 lib_ring_buffer_align_ctx(config, &ctx, sizeof(src)); \
11 lib_ring_buffer_write(config, &ctx, &src, sizeof(src));
14 #define tp_memcpy(dest, src, len) \
15 lib_ring_buffer_align_ctx(config, &ctx, sizeof(*(src))); \
16 lib_ring_buffer_write(config, &ctx, &src, len);
20 #define tp_strcpy(dest, src) __assign_str(dest, src);
22 struct lttng_event_field
{
24 const struct lttng_type type
;
27 struct lttng_event_desc
{
28 const struct lttng_event_field
*fields
;
32 * Stage 1 of the trace events.
34 * Create event field type metadata section.
35 * Each event produce an array of fields.
39 * DECLARE_EVENT_CLASS can be used to add a generic function
40 * handlers for events. That is, if all events have the same
41 * parameters and just have distinct trace points.
42 * Each tracepoint can be defined with DEFINE_EVENT and that
43 * will map the DECLARE_EVENT_CLASS to the tracepoint.
45 * TRACE_EVENT is a one to one mapping between tracepoint and template.
48 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
49 DECLARE_EVENT_CLASS(name, \
55 DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args))
57 /* Named field types must be defined in lttng-types.h */
60 #define __field(_type, _item) \
61 { .name = #_item, .type = { .atype = atype_integer, .name = #_type} },
64 #define __field_ext(_type, _item, _filter_type) \
65 { .name = #_item, .type = { .atype = atype_integer, .name = #_type} },
68 #define __array(_type, _item, _length) \
72 .atype = atype_array, \
74 .u.array.elem_type = #_type, \
75 .u.array.length = _length, \
79 #undef __dynamic_array
80 #define __dynamic_array(_type, _item, _length) \
84 .atype = atype_sequence, \
86 .u.sequence.elem_type = #_type, \
87 .u.sequence.length_type = "u32", \
92 #define __string(_item, _src) \
96 .atype = atype_string, \
98 .u.string.encoding = lttng_encode_UTF8, \
103 #define TP_PROTO(args...)
106 #define TP_ARGS(args...)
108 #undef TP_STRUCT__entry
109 #define TP_STRUCT__entry(args...) args /* Only one used in this phase */
111 #undef TP_fast_assign
112 #define TP_fast_assign(args...)
115 #define TP_printk(args...)
117 #undef DECLARE_EVENT_CLASS
118 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \
119 static const struct lttng_event_field __event_fields___##name[] = { \
124 #define DEFINE_EVENT(template, name, proto, args)
126 #undef DEFINE_EVENT_PRINT
127 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
128 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
130 /* Callbacks are meaningless to LTTng. */
131 #undef TRACE_EVENT_FN
132 #define TRACE_EVENT_FN(name, proto, args, tstruct, \
133 assign, print, reg, unreg) \
134 TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \
135 PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \
137 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
140 * Stage 2 of the trace events.
142 * Create an array of events.
146 * DECLARE_EVENT_CLASS can be used to add a generic function
147 * handlers for events. That is, if all events have the same
148 * parameters and just have distinct trace points.
149 * Each tracepoint can be defined with DEFINE_EVENT and that
150 * will map the DECLARE_EVENT_CLASS to the tracepoint.
152 * TRACE_EVENT is a one to one mapping between tracepoint and template.
155 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
156 DECLARE_EVENT_CLASS(name, \
162 DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args))
164 /* Named field types must be defined in lttng-types.h */
167 #define __field(_type, _item)
170 #define __field_ext(_type, _item, _filter_type)
173 #define __array(_type, _item, _length)
175 #undef __dynamic_array
176 #define __dynamic_array(_type, _item, _length)
179 #define __string(_item, _src)
182 #define TP_PROTO(args...)
185 #define TP_ARGS(args...)
187 #undef TP_STRUCT__entry
188 #define TP_STRUCT__entry(args...)
190 #undef TP_fast_assign
191 #define TP_fast_assign(args...)
194 #define TP_printk(args...)
196 #undef DECLARE_EVENT_CLASS
197 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \
198 { .fields = __event_fields___##name },
201 #define DEFINE_EVENT(template, name, proto, args)
203 #undef DEFINE_EVENT_PRINT
204 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
205 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
207 /* Callbacks are meaningless to LTTng. */
208 #undef TRACE_EVENT_FN
209 #define TRACE_EVENT_FN(name, proto, args, tstruct, \
210 assign, print, reg, unreg) \
211 TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \
212 PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \
214 #define TRACE_EVENT_DESC_1(_system) __event_desc___##_system
215 #define TRACE_EVENT_DESC(_system) TRACE_EVENT_DESC_1(_system)
217 static const struct lttng_event_desc
TRACE_EVENT_DESC(TRACE_SYSTEM
)[] = {
218 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
221 #undef TRACE_EVENT_DESC_1
222 #undef TRACE_EVENT_DESC
227 * Stage 3 of the trace events.
229 * Create static inline function that calculates event size.
234 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
237 * Stage 4 of the trace events.
239 * Create the probe function : call even size calculation and write event data
245 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
250 #include <linux/ftrace_event.h>
253 * DECLARE_EVENT_CLASS can be used to add a generic function
254 * handlers for events. That is, if all events have the same
255 * parameters and just have distinct trace points.
256 * Each tracepoint can be defined with DEFINE_EVENT and that
257 * will map the DECLARE_EVENT_CLASS to the tracepoint.
259 * TRACE_EVENT is a one to one mapping between tracepoint and template.
262 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
263 DECLARE_EVENT_CLASS(name, \
269 DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));
273 #define __field(type, item) type item;
276 #define __field_ext(type, item, filter_type) type item;
279 #define __array(type, item, len) type item[len];
281 #undef __dynamic_array
282 #define __dynamic_array(type, item, len) u32 __data_loc_##item;
285 #define __string(item, src) __dynamic_array(char, item, -1)
287 #undef TP_STRUCT__entry
288 #define TP_STRUCT__entry(args...) args
290 #undef DECLARE_EVENT_CLASS
291 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \
292 struct ftrace_raw_##name { \
293 struct trace_entry ent; \
298 static struct ftrace_event_class event_class_##name;
301 #define DEFINE_EVENT(template, name, proto, args) \
302 static struct ftrace_event_call __used \
303 __attribute__((__aligned__(4))) event_##name
305 #undef DEFINE_EVENT_PRINT
306 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
307 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
309 /* Callbacks are meaningless to ftrace. */
310 #undef TRACE_EVENT_FN
311 #define TRACE_EVENT_FN(name, proto, args, tstruct, \
312 assign, print, reg, unreg) \
313 TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \
314 PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \
316 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
320 * Stage 2 of the trace events.
322 * Create static inline function that calculates event size.
326 #define __field(type, item)
329 #define __field_ext(type, item, filter_type)
332 #define __array(type, item, len)
334 #undef __dynamic_array
335 #define __dynamic_array(type, item, len) u32 item;
338 #define __string(item, src) __dynamic_array(char, item, -1)
340 #undef DECLARE_EVENT_CLASS
341 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
342 struct ftrace_data_offsets_##call { \
347 #define DEFINE_EVENT(template, name, proto, args)
349 #undef DEFINE_EVENT_PRINT
350 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
351 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
353 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
356 * Stage 3 of the trace events.
358 * Create the probe function : call even size calculation and write event data
363 #define __entry field
366 #define TP_printk(fmt, args...) fmt "\n", args
368 #undef __get_dynamic_array
369 #define __get_dynamic_array(field) \
370 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
373 #define __get_str(field) (char *)__get_dynamic_array(field)
376 #define __print_flags(flag, delim, flag_array...) \
378 static const struct trace_print_flags __flags[] = \
379 { flag_array, { -1, NULL }}; \
380 ftrace_print_flags_seq(p, delim, flag, __flags); \
383 #undef __print_symbolic
384 #define __print_symbolic(value, symbol_array...) \
386 static const struct trace_print_flags symbols[] = \
387 { symbol_array, { -1, NULL }}; \
388 ftrace_print_symbols_seq(p, value, symbols); \
392 #define __print_hex(buf, buf_len) ftrace_print_hex_seq(p, buf, buf_len)
394 #undef DECLARE_EVENT_CLASS
395 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
396 static notrace enum print_line_t \
397 ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \
398 struct trace_event *trace_event) \
400 struct ftrace_event_call *event; \
401 struct trace_seq *s = &iter->seq; \
402 struct ftrace_raw_##call *field; \
403 struct trace_entry *entry; \
404 struct trace_seq *p = &iter->tmp_seq; \
407 event = container_of(trace_event, struct ftrace_event_call, \
412 if (entry->type != event->event.type) { \
414 return TRACE_TYPE_UNHANDLED; \
417 field = (typeof(field))entry; \
420 ret = trace_seq_printf(s, "%s: ", event->name); \
422 ret = trace_seq_printf(s, print); \
424 return TRACE_TYPE_PARTIAL_LINE; \
426 return TRACE_TYPE_HANDLED; \
428 static struct trace_event_functions ftrace_event_type_funcs_##call = { \
429 .trace = ftrace_raw_output_##call, \
432 #undef DEFINE_EVENT_PRINT
433 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
434 static notrace enum print_line_t \
435 ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \
436 struct trace_event *event) \
438 struct trace_seq *s = &iter->seq; \
439 struct ftrace_raw_##template *field; \
440 struct trace_entry *entry; \
441 struct trace_seq *p = &iter->tmp_seq; \
446 if (entry->type != event_##call.event.type) { \
448 return TRACE_TYPE_UNHANDLED; \
451 field = (typeof(field))entry; \
454 ret = trace_seq_printf(s, "%s: ", #call); \
456 ret = trace_seq_printf(s, print); \
458 return TRACE_TYPE_PARTIAL_LINE; \
460 return TRACE_TYPE_HANDLED; \
462 static struct trace_event_functions ftrace_event_type_funcs_##call = { \
463 .trace = ftrace_raw_output_##call, \
466 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
469 #define __field_ext(type, item, filter_type) \
470 ret = trace_define_field(event_call, #type, #item, \
471 offsetof(typeof(field), item), \
472 sizeof(field.item), \
473 is_signed_type(type), filter_type); \
478 #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
481 #define __array(type, item, len) \
482 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
483 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
484 offsetof(typeof(field), item), \
485 sizeof(field.item), \
486 is_signed_type(type), FILTER_OTHER); \
490 #undef __dynamic_array
491 #define __dynamic_array(type, item, len) \
492 ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \
493 offsetof(typeof(field), __data_loc_##item), \
494 sizeof(field.__data_loc_##item), \
495 is_signed_type(type), FILTER_OTHER);
498 #define __string(item, src) __dynamic_array(char, item, -1)
500 #undef DECLARE_EVENT_CLASS
501 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
503 ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
505 struct ftrace_raw_##call field; \
514 #define DEFINE_EVENT(template, name, proto, args)
516 #undef DEFINE_EVENT_PRINT
517 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
518 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
520 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
523 * remember the offset of each array from the beginning of the event.
527 #define __entry entry
530 #define __field(type, item)
533 #define __field_ext(type, item, filter_type)
536 #define __array(type, item, len)
538 #undef __dynamic_array
539 #define __dynamic_array(type, item, len) \
540 __data_offsets->item = __data_size + \
541 offsetof(typeof(*entry), __data); \
542 __data_offsets->item |= (len * sizeof(type)) << 16; \
543 __data_size += (len) * sizeof(type);
546 #define __string(item, src) __dynamic_array(char, item, strlen(src) + 1)
548 #undef DECLARE_EVENT_CLASS
549 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
550 static inline notrace int ftrace_get_offsets_##call( \
551 struct ftrace_data_offsets_##call *__data_offsets, proto) \
553 int __data_size = 0; \
554 struct ftrace_raw_##call __maybe_unused *entry; \
558 return __data_size; \
562 #define DEFINE_EVENT(template, name, proto, args)
564 #undef DEFINE_EVENT_PRINT
565 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
566 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
568 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
571 * Stage 4 of the trace events.
573 * Override the macros in <trace/trace_events.h> to include the following:
575 * For those macros defined with TRACE_EVENT:
577 * static struct ftrace_event_call event_<call>;
579 * static void ftrace_raw_event_<call>(void *__data, proto)
581 * struct ftrace_event_call *event_call = __data;
582 * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
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;
590 * local_save_flags(irq_flags);
591 * pc = preempt_count();
593 * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
595 * event = trace_current_buffer_lock_reserve(&buffer,
596 * event_<call>->event.type,
597 * sizeof(*entry) + __data_size,
601 * entry = ring_buffer_event_data(event);
603 * { <assign>; } <-- Here we assign the entries by the __field and
606 * if (!filter_current_check_discard(buffer, event_call, entry, event))
607 * trace_current_buffer_unlock_commit(buffer,
608 * event, irq_flags, pc);
611 * static struct trace_event ftrace_event_type_<call> = {
612 * .trace = ftrace_raw_output_<call>, <-- stage 2
615 * static const char print_fmt_<call>[] = <TP_printk>;
617 * static struct ftrace_event_class __used event_class_<template> = {
618 * .system = "<system>",
619 * .define_fields = ftrace_define_fields_<call>,
620 * .fields = LIST_HEAD_INIT(event_class_##call.fields),
621 * .raw_init = trace_event_raw_init,
622 * .probe = ftrace_raw_event_##call,
623 * .reg = ftrace_event_reg,
626 * static struct ftrace_event_call __used
627 * __attribute__((__aligned__(4)))
628 * __attribute__((section("_ftrace_events"))) event_<call> = {
630 * .class = event_class_<template>,
631 * .event = &ftrace_event_type_<call>,
632 * .print_fmt = print_fmt_<call>,
637 #ifdef CONFIG_PERF_EVENTS
639 #define _TRACE_PERF_PROTO(call, proto) \
640 static notrace void \
641 perf_trace_##call(void *__data, proto);
643 #define _TRACE_PERF_INIT(call) \
644 .perf_probe = perf_trace_##call,
647 #define _TRACE_PERF_PROTO(call, proto)
648 #define _TRACE_PERF_INIT(call)
649 #endif /* CONFIG_PERF_EVENTS */
652 #define __entry entry
655 #define __field(type, item)
658 #define __array(type, item, len)
660 #undef __dynamic_array
661 #define __dynamic_array(type, item, len) \
662 __entry->__data_loc_##item = __data_offsets.item;
665 #define __string(item, src) __dynamic_array(char, item, -1) \
668 #define __assign_str(dst, src) \
669 strcpy(__get_str(dst), src);
671 #undef TP_fast_assign
672 #define TP_fast_assign(args...) args
674 #undef TP_perf_assign
675 #define TP_perf_assign(args...)
677 #undef DECLARE_EVENT_CLASS
678 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
680 static notrace void \
681 ftrace_raw_event_##call(void *__data, proto) \
683 struct ftrace_event_call *event_call = __data; \
684 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
685 struct ring_buffer_event *event; \
686 struct ftrace_raw_##call *entry; \
687 struct ring_buffer *buffer; \
688 unsigned long irq_flags; \
692 local_save_flags(irq_flags); \
693 pc = preempt_count(); \
695 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
697 event = trace_current_buffer_lock_reserve(&buffer, \
698 event_call->event.type, \
699 sizeof(*entry) + __data_size, \
703 entry = ring_buffer_event_data(event); \
709 if (!filter_current_check_discard(buffer, event_call, entry, event)) \
710 trace_nowake_buffer_unlock_commit(buffer, \
711 event, irq_flags, pc); \
714 * The ftrace_test_probe is compiled out, it is only here as a build time check
715 * to make sure that if the tracepoint handling changes, the ftrace probe will
716 * fail to compile unless it too is updated.
720 #define DEFINE_EVENT(template, call, proto, args) \
721 static inline void ftrace_test_probe_##call(void) \
723 check_trace_callback_type_##call(ftrace_raw_event_##template); \
726 #undef DEFINE_EVENT_PRINT
727 #define DEFINE_EVENT_PRINT(template, name, proto, args, print)
729 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
735 #undef __print_symbolic
736 #undef __get_dynamic_array
740 #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args)
742 #undef DECLARE_EVENT_CLASS
743 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
744 _TRACE_PERF_PROTO(call, PARAMS(proto)); \
745 static const char print_fmt_##call[] = print; \
746 static struct ftrace_event_class __used event_class_##call = { \
747 .system = __stringify(TRACE_SYSTEM), \
748 .define_fields = ftrace_define_fields_##call, \
749 .fields = LIST_HEAD_INIT(event_class_##call.fields),\
750 .raw_init = trace_event_raw_init, \
751 .probe = ftrace_raw_event_##call, \
752 .reg = ftrace_event_reg, \
753 _TRACE_PERF_INIT(call) \
757 #define DEFINE_EVENT(template, call, proto, args) \
759 static struct ftrace_event_call __used \
760 __attribute__((__aligned__(4))) \
761 __attribute__((section("_ftrace_events"))) event_##call = { \
763 .class = &event_class_##template, \
764 .event.funcs = &ftrace_event_type_funcs_##template, \
765 .print_fmt = print_fmt_##template, \
768 #undef DEFINE_EVENT_PRINT
769 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
771 static const char print_fmt_##call[] = print; \
773 static struct ftrace_event_call __used \
774 __attribute__((__aligned__(4))) \
775 __attribute__((section("_ftrace_events"))) event_##call = { \
777 .class = &event_class_##template, \
778 .event.funcs = &ftrace_event_type_funcs_##call, \
779 .print_fmt = print_fmt_##call, \
782 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
785 * Define the insertion callback to perf events
787 * The job is very similar to ftrace_raw_event_<call> except that we don't
788 * insert in the ring buffer but in a perf counter.
790 * static void ftrace_perf_<call>(proto)
792 * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
793 * struct ftrace_event_call *event_call = &event_<call>;
794 * extern void perf_tp_event(int, u64, u64, void *, int);
795 * struct ftrace_raw_##call *entry;
796 * struct perf_trace_buf *trace_buf;
797 * u64 __addr = 0, __count = 1;
798 * unsigned long irq_flags;
799 * struct trace_entry *ent;
805 * pc = preempt_count();
807 * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
809 * // Below we want to get the aligned size by taking into account
810 * // the u32 field that will later store the buffer size
811 * __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),
813 * __entry_size -= sizeof(u32);
815 * // Protect the non nmi buffer
816 * // This also protects the rcu read side
817 * local_irq_save(irq_flags);
818 * __cpu = smp_processor_id();
821 * trace_buf = rcu_dereference_sched(perf_trace_buf_nmi);
823 * trace_buf = rcu_dereference_sched(perf_trace_buf);
828 * trace_buf = per_cpu_ptr(trace_buf, __cpu);
830 * // Avoid recursion from perf that could mess up the buffer
831 * if (trace_buf->recursion++)
832 * goto end_recursion;
834 * raw_data = trace_buf->buf;
836 * // Make recursion update visible before entering perf_tp_event
837 * // so that we protect from perf recursions.
841 * //zero dead bytes from alignment to avoid stack leak to userspace:
842 * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL;
843 * entry = (struct ftrace_raw_<call> *)raw_data;
845 * tracing_generic_entry_update(ent, irq_flags, pc);
846 * ent->type = event_call->id;
848 * <tstruct> <- do some jobs with dynamic arrays
850 * <assign> <- affect our values
852 * perf_tp_event(event_call->id, __addr, __count, entry,
853 * __entry_size); <- submit them to perf counter
858 #ifdef CONFIG_PERF_EVENTS
861 #define __entry entry
863 #undef __get_dynamic_array
864 #define __get_dynamic_array(field) \
865 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
868 #define __get_str(field) (char *)__get_dynamic_array(field)
871 #define __perf_addr(a) __addr = (a)
874 #define __perf_count(c) __count = (c)
876 #undef DECLARE_EVENT_CLASS
877 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
878 static notrace void \
879 perf_trace_##call(void *__data, proto) \
881 struct ftrace_event_call *event_call = __data; \
882 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
883 struct ftrace_raw_##call *entry; \
884 struct pt_regs __regs; \
885 u64 __addr = 0, __count = 1; \
886 struct hlist_head *head; \
891 perf_fetch_caller_regs(&__regs); \
893 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
894 __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
896 __entry_size -= sizeof(u32); \
898 if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE, \
899 "profile buffer not large enough")) \
902 entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \
903 __entry_size, event_call->event.type, &__regs, &rctx); \
911 head = this_cpu_ptr(event_call->perf_events); \
912 perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \
913 __count, &__regs, head); \
917 * This part is compiled out, it is only here as a build time check
918 * to make sure that if the tracepoint handling changes, the
919 * perf probe will fail to compile unless it too is updated.
922 #define DEFINE_EVENT(template, call, proto, args) \
923 static inline void perf_test_probe_##call(void) \
925 check_trace_callback_type_##call(perf_trace_##template); \
929 #undef DEFINE_EVENT_PRINT
930 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
931 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
933 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
934 #endif /* CONFIG_PERF_EVENTS */
936 #undef _TRACE_PROFILE_INIT
This page took 0.061773 seconds and 4 git commands to generate.