1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Stage 1 of the trace events.
5 * Override the macros in the event tracepoint header <trace/events/XXX.h>
6 * to include the following:
8 * struct trace_event_raw_<call> {
9 * struct trace_entry ent;
11 * <type2> <item2>[<len>];
15 * The <type> <item> is created by the __field(type, item) macro or
16 * the __array(type2, item2, len) macro.
17 * We simply do "type item;", and that will create the fields
21 #include <linux/trace_events.h>
23 #ifndef TRACE_SYSTEM_VAR
24 #define TRACE_SYSTEM_VAR TRACE_SYSTEM
27 #define __app__(x, y) str__##x##y
28 #define __app(x, y) __app__(x, y)
30 #define TRACE_SYSTEM_STRING __app(TRACE_SYSTEM_VAR,__trace_system_name)
32 #define TRACE_MAKE_SYSTEM_STR() \
33 static const char TRACE_SYSTEM_STRING[] = \
34 __stringify(TRACE_SYSTEM)
36 TRACE_MAKE_SYSTEM_STR();
38 #undef TRACE_DEFINE_ENUM
39 #define TRACE_DEFINE_ENUM(a) \
40 static struct trace_eval_map __used __initdata \
41 __##TRACE_SYSTEM##_##a = \
43 .system = TRACE_SYSTEM_STRING, \
47 static struct trace_eval_map __used \
48 __section("_ftrace_eval_map") \
49 *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
51 #undef TRACE_DEFINE_SIZEOF
52 #define TRACE_DEFINE_SIZEOF(a) \
53 static struct trace_eval_map __used __initdata \
54 __##TRACE_SYSTEM##_##a = \
56 .system = TRACE_SYSTEM_STRING, \
57 .eval_string = "sizeof(" #a ")", \
58 .eval_value = sizeof(a) \
60 static struct trace_eval_map __used \
61 __section("_ftrace_eval_map") \
62 *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
65 * DECLARE_EVENT_CLASS can be used to add a generic function
66 * handlers for events. That is, if all events have the same
67 * parameters and just have distinct trace points.
68 * Each tracepoint can be defined with DEFINE_EVENT and that
69 * will map the DECLARE_EVENT_CLASS to the tracepoint.
71 * TRACE_EVENT is a one to one mapping between tracepoint and template.
74 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
75 DECLARE_EVENT_CLASS(name, \
81 DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));
85 #define __field(type, item) type item;
88 #define __field_ext(type, item, filter_type) type item;
91 #define __field_struct(type, item) type item;
93 #undef __field_struct_ext
94 #define __field_struct_ext(type, item, filter_type) type item;
97 #define __array(type, item, len) type item[len];
99 #undef __dynamic_array
100 #define __dynamic_array(type, item, len) u32 __data_loc_##item;
103 #define __string(item, src) __dynamic_array(char, item, -1)
106 #define __string_len(item, src, len) __dynamic_array(char, item, -1)
109 #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1)
111 #undef __rel_dynamic_array
112 #define __rel_dynamic_array(type, item, len) u32 __rel_loc_##item;
115 #define __rel_string(item, src) __rel_dynamic_array(char, item, -1)
117 #undef __rel_string_len
118 #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, -1)
121 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1)
123 #undef TP_STRUCT__entry
124 #define TP_STRUCT__entry(args...) args
126 #undef DECLARE_EVENT_CLASS
127 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \
128 struct trace_event_raw_##name { \
129 struct trace_entry ent; \
134 static struct trace_event_class event_class_##name;
137 #define DEFINE_EVENT(template, name, proto, args) \
138 static struct trace_event_call __used \
139 __attribute__((__aligned__(4))) event_##name
141 #undef DEFINE_EVENT_FN
142 #define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg) \
143 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
145 #undef DEFINE_EVENT_PRINT
146 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
147 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
149 /* Callbacks are meaningless to ftrace. */
150 #undef TRACE_EVENT_FN
151 #define TRACE_EVENT_FN(name, proto, args, tstruct, \
152 assign, print, reg, unreg) \
153 TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \
154 PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \
156 #undef TRACE_EVENT_FN_COND
157 #define TRACE_EVENT_FN_COND(name, proto, args, cond, tstruct, \
158 assign, print, reg, unreg) \
159 TRACE_EVENT_CONDITION(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
160 PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \
162 #undef TRACE_EVENT_FLAGS
163 #define TRACE_EVENT_FLAGS(name, value) \
164 __TRACE_EVENT_FLAGS(name, value)
166 #undef TRACE_EVENT_PERF_PERM
167 #define TRACE_EVENT_PERF_PERM(name, expr...) \
168 __TRACE_EVENT_PERF_PERM(name, expr)
170 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
173 * Stage 2 of the trace events.
175 * Include the following:
177 * struct trace_event_data_offsets_<call> {
183 * The __dynamic_array() macro will create each u32 <item>, this is
184 * to keep the offset of each array from the beginning of the event.
185 * The size of an array is also encoded, in the higher 16 bits of <item>.
188 #undef TRACE_DEFINE_ENUM
189 #define TRACE_DEFINE_ENUM(a)
191 #undef TRACE_DEFINE_SIZEOF
192 #define TRACE_DEFINE_SIZEOF(a)
195 #define __field(type, item)
198 #define __field_ext(type, item, filter_type)
200 #undef __field_struct
201 #define __field_struct(type, item)
203 #undef __field_struct_ext
204 #define __field_struct_ext(type, item, filter_type)
207 #define __array(type, item, len)
209 #undef __dynamic_array
210 #define __dynamic_array(type, item, len) u32 item;
213 #define __string(item, src) __dynamic_array(char, item, -1)
216 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
219 #define __string_len(item, src, len) __dynamic_array(char, item, -1)
221 #undef __rel_dynamic_array
222 #define __rel_dynamic_array(type, item, len) u32 item;
225 #define __rel_string(item, src) __rel_dynamic_array(char, item, -1)
227 #undef __rel_string_len
228 #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, -1)
231 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
233 #undef DECLARE_EVENT_CLASS
234 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
235 struct trace_event_data_offsets_##call { \
240 #define DEFINE_EVENT(template, name, proto, args)
242 #undef DEFINE_EVENT_PRINT
243 #define DEFINE_EVENT_PRINT(template, name, proto, args, print)
245 #undef TRACE_EVENT_FLAGS
246 #define TRACE_EVENT_FLAGS(event, flag)
248 #undef TRACE_EVENT_PERF_PERM
249 #define TRACE_EVENT_PERF_PERM(event, expr...)
251 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
254 * Stage 3 of the trace events.
256 * Override the macros in the event tracepoint header <trace/events/XXX.h>
257 * to include the following:
260 * trace_raw_output_<call>(struct trace_iterator *iter, int flags)
262 * struct trace_seq *s = &iter->seq;
263 * struct trace_event_raw_<call> *field; <-- defined in stage 1
264 * struct trace_seq *p = &iter->tmp_seq;
266 * -------(for event)-------
268 * struct trace_entry *entry;
272 * if (entry->type != event_<call>->event.type) {
274 * return TRACE_TYPE_UNHANDLED;
277 * field = (typeof(field))entry;
280 * return trace_output_call(iter, <call>, <TP_printk> "\n");
282 * ------(or, for event class)------
286 * field = (typeof(field))iter->ent;
288 * ret = trace_raw_output_prep(iter, trace_event);
289 * if (ret != TRACE_TYPE_HANDLED)
292 * trace_event_printf(iter, <TP_printk> "\n");
294 * return trace_handle_return(s);
298 * This is the method used to print the raw event to the trace
299 * output format. Note, this is not needed if the data is read
304 #define __entry field
307 #define TP_printk(fmt, args...) fmt "\n", args
309 #undef __get_dynamic_array
310 #define __get_dynamic_array(field) \
311 ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
313 #undef __get_dynamic_array_len
314 #define __get_dynamic_array_len(field) \
315 ((__entry->__data_loc_##field >> 16) & 0xffff)
318 #define __get_str(field) ((char *)__get_dynamic_array(field))
320 #undef __get_rel_dynamic_array
321 #define __get_rel_dynamic_array(field) \
323 offsetof(typeof(*__entry), __rel_loc_##field) + \
324 sizeof(__entry->__rel_loc_##field) + \
325 (__entry->__rel_loc_##field & 0xffff))
327 #undef __get_rel_dynamic_array_len
328 #define __get_rel_dynamic_array_len(field) \
329 ((__entry->__rel_loc_##field >> 16) & 0xffff)
332 #define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field))
335 #define __get_bitmask(field) \
337 void *__bitmask = __get_dynamic_array(field); \
338 unsigned int __bitmask_size; \
339 __bitmask_size = __get_dynamic_array_len(field); \
340 trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \
343 #undef __get_rel_bitmask
344 #define __get_rel_bitmask(field) \
346 void *__bitmask = __get_rel_dynamic_array(field); \
347 unsigned int __bitmask_size; \
348 __bitmask_size = __get_rel_dynamic_array_len(field); \
349 trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \
353 #define __print_flags(flag, delim, flag_array...) \
355 static const struct trace_print_flags __flags[] = \
356 { flag_array, { -1, NULL }}; \
357 trace_print_flags_seq(p, delim, flag, __flags); \
360 #undef __print_symbolic
361 #define __print_symbolic(value, symbol_array...) \
363 static const struct trace_print_flags symbols[] = \
364 { symbol_array, { -1, NULL }}; \
365 trace_print_symbols_seq(p, value, symbols); \
368 #undef __print_flags_u64
369 #undef __print_symbolic_u64
370 #if BITS_PER_LONG == 32
371 #define __print_flags_u64(flag, delim, flag_array...) \
373 static const struct trace_print_flags_u64 __flags[] = \
374 { flag_array, { -1, NULL } }; \
375 trace_print_flags_seq_u64(p, delim, flag, __flags); \
378 #define __print_symbolic_u64(value, symbol_array...) \
380 static const struct trace_print_flags_u64 symbols[] = \
381 { symbol_array, { -1, NULL } }; \
382 trace_print_symbols_seq_u64(p, value, symbols); \
385 #define __print_flags_u64(flag, delim, flag_array...) \
386 __print_flags(flag, delim, flag_array)
388 #define __print_symbolic_u64(value, symbol_array...) \
389 __print_symbolic(value, symbol_array)
393 #define __print_hex(buf, buf_len) \
394 trace_print_hex_seq(p, buf, buf_len, false)
396 #undef __print_hex_str
397 #define __print_hex_str(buf, buf_len) \
398 trace_print_hex_seq(p, buf, buf_len, true)
401 #define __print_array(array, count, el_size) \
403 BUILD_BUG_ON(el_size != 1 && el_size != 2 && \
404 el_size != 4 && el_size != 8); \
405 trace_print_array_seq(p, array, count, el_size); \
408 #undef __print_hex_dump
409 #define __print_hex_dump(prefix_str, prefix_type, \
410 rowsize, groupsize, buf, len, ascii) \
411 trace_print_hex_dump_seq(p, prefix_str, prefix_type, \
412 rowsize, groupsize, buf, len, ascii)
414 #undef __print_ns_to_secs
415 #define __print_ns_to_secs(value) \
417 u64 ____val = (u64)(value); \
418 do_div(____val, NSEC_PER_SEC); \
422 #undef __print_ns_without_secs
423 #define __print_ns_without_secs(value) \
425 u64 ____val = (u64)(value); \
426 (u32) do_div(____val, NSEC_PER_SEC); \
429 #undef DECLARE_EVENT_CLASS
430 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
431 static notrace enum print_line_t \
432 trace_raw_output_##call(struct trace_iterator *iter, int flags, \
433 struct trace_event *trace_event) \
435 struct trace_seq *s = &iter->seq; \
436 struct trace_seq __maybe_unused *p = &iter->tmp_seq; \
437 struct trace_event_raw_##call *field; \
440 field = (typeof(field))iter->ent; \
442 ret = trace_raw_output_prep(iter, trace_event); \
443 if (ret != TRACE_TYPE_HANDLED) \
446 trace_event_printf(iter, print); \
448 return trace_handle_return(s); \
450 static struct trace_event_functions trace_event_type_funcs_##call = { \
451 .trace = trace_raw_output_##call, \
454 #undef DEFINE_EVENT_PRINT
455 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
456 static notrace enum print_line_t \
457 trace_raw_output_##call(struct trace_iterator *iter, int flags, \
458 struct trace_event *event) \
460 struct trace_event_raw_##template *field; \
461 struct trace_entry *entry; \
462 struct trace_seq *p = &iter->tmp_seq; \
466 if (entry->type != event_##call.event.type) { \
468 return TRACE_TYPE_UNHANDLED; \
471 field = (typeof(field))entry; \
474 return trace_output_call(iter, #call, print); \
476 static struct trace_event_functions trace_event_type_funcs_##call = { \
477 .trace = trace_raw_output_##call, \
480 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
483 #define __field_ext(_type, _item, _filter_type) { \
484 .type = #_type, .name = #_item, \
485 .size = sizeof(_type), .align = __alignof__(_type), \
486 .is_signed = is_signed_type(_type), .filter_type = _filter_type },
488 #undef __field_struct_ext
489 #define __field_struct_ext(_type, _item, _filter_type) { \
490 .type = #_type, .name = #_item, \
491 .size = sizeof(_type), .align = __alignof__(_type), \
492 0, .filter_type = _filter_type },
495 #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
497 #undef __field_struct
498 #define __field_struct(type, item) __field_struct_ext(type, item, FILTER_OTHER)
501 #define __array(_type, _item, _len) { \
502 .type = #_type"["__stringify(_len)"]", .name = #_item, \
503 .size = sizeof(_type[_len]), .align = __alignof__(_type), \
504 .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER },
506 #undef __dynamic_array
507 #define __dynamic_array(_type, _item, _len) { \
508 .type = "__data_loc " #_type "[]", .name = #_item, \
509 .size = 4, .align = 4, \
510 .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER },
513 #define __string(item, src) __dynamic_array(char, item, -1)
516 #define __string_len(item, src, len) __dynamic_array(char, item, -1)
519 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
521 #undef __rel_dynamic_array
522 #define __rel_dynamic_array(_type, _item, _len) { \
523 .type = "__rel_loc " #_type "[]", .name = #_item, \
524 .size = 4, .align = 4, \
525 .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER },
528 #define __rel_string(item, src) __rel_dynamic_array(char, item, -1)
530 #undef __rel_string_len
531 #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, -1)
534 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
536 #undef DECLARE_EVENT_CLASS
537 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
538 static struct trace_event_fields trace_event_fields_##call[] = { \
542 #undef DEFINE_EVENT_PRINT
543 #define DEFINE_EVENT_PRINT(template, name, proto, args, print)
545 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
548 * remember the offset of each array from the beginning of the event.
552 #define __entry entry
555 #define __field(type, item)
558 #define __field_ext(type, item, filter_type)
560 #undef __field_struct
561 #define __field_struct(type, item)
563 #undef __field_struct_ext
564 #define __field_struct_ext(type, item, filter_type)
567 #define __array(type, item, len)
569 #undef __dynamic_array
570 #define __dynamic_array(type, item, len) \
571 __item_length = (len) * sizeof(type); \
572 __data_offsets->item = __data_size + \
573 offsetof(typeof(*entry), __data); \
574 __data_offsets->item |= __item_length << 16; \
575 __data_size += __item_length;
578 #define __string(item, src) __dynamic_array(char, item, \
579 strlen((src) ? (const char *)(src) : "(null)") + 1)
582 #define __string_len(item, src, len) __dynamic_array(char, item, (len) + 1)
584 #undef __rel_dynamic_array
585 #define __rel_dynamic_array(type, item, len) \
586 __item_length = (len) * sizeof(type); \
587 __data_offsets->item = __data_size + \
588 offsetof(typeof(*entry), __data) - \
589 offsetof(typeof(*entry), __rel_loc_##item) - \
591 __data_offsets->item |= __item_length << 16; \
592 __data_size += __item_length;
595 #define __rel_string(item, src) __rel_dynamic_array(char, item, \
596 strlen((src) ? (const char *)(src) : "(null)") + 1)
598 #undef __rel_string_len
599 #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, (len) + 1)
601 * __bitmask_size_in_bytes_raw is the number of bytes needed to hold
602 * num_possible_cpus().
604 #define __bitmask_size_in_bytes_raw(nr_bits) \
605 (((nr_bits) + 7) / 8)
607 #define __bitmask_size_in_longs(nr_bits) \
608 ((__bitmask_size_in_bytes_raw(nr_bits) + \
609 ((BITS_PER_LONG / 8) - 1)) / (BITS_PER_LONG / 8))
612 * __bitmask_size_in_bytes is the number of bytes needed to hold
613 * num_possible_cpus() padded out to the nearest long. This is what
614 * is saved in the buffer, just to be consistent.
616 #define __bitmask_size_in_bytes(nr_bits) \
617 (__bitmask_size_in_longs(nr_bits) * (BITS_PER_LONG / 8))
620 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, \
621 __bitmask_size_in_longs(nr_bits))
624 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \
625 __bitmask_size_in_longs(nr_bits))
627 #undef DECLARE_EVENT_CLASS
628 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
629 static inline notrace int trace_event_get_offsets_##call( \
630 struct trace_event_data_offsets_##call *__data_offsets, proto) \
632 int __data_size = 0; \
633 int __maybe_unused __item_length; \
634 struct trace_event_raw_##call __maybe_unused *entry; \
638 return __data_size; \
641 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
644 * Stage 4 of the trace events.
646 * Override the macros in the event tracepoint header <trace/events/XXX.h>
647 * to include the following:
649 * For those macros defined with TRACE_EVENT:
651 * static struct trace_event_call event_<call>;
653 * static void trace_event_raw_event_<call>(void *__data, proto)
655 * struct trace_event_file *trace_file = __data;
656 * struct trace_event_call *event_call = trace_file->event_call;
657 * struct trace_event_data_offsets_<call> __maybe_unused __data_offsets;
658 * unsigned long eflags = trace_file->flags;
659 * enum event_trigger_type __tt = ETT_NONE;
660 * struct ring_buffer_event *event;
661 * struct trace_event_raw_<call> *entry; <-- defined in stage 1
662 * struct trace_buffer *buffer;
663 * unsigned long irq_flags;
667 * if (!(eflags & EVENT_FILE_FL_TRIGGER_COND)) {
668 * if (eflags & EVENT_FILE_FL_TRIGGER_MODE)
669 * event_triggers_call(trace_file, NULL);
670 * if (eflags & EVENT_FILE_FL_SOFT_DISABLED)
674 * local_save_flags(irq_flags);
675 * pc = preempt_count();
677 * __data_size = trace_event_get_offsets_<call>(&__data_offsets, args);
679 * event = trace_event_buffer_lock_reserve(&buffer, trace_file,
680 * event_<call>->event.type,
681 * sizeof(*entry) + __data_size,
685 * entry = ring_buffer_event_data(event);
687 * { <assign>; } <-- Here we assign the entries by the __field and
690 * if (eflags & EVENT_FILE_FL_TRIGGER_COND)
691 * __tt = event_triggers_call(trace_file, entry);
693 * if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT,
694 * &trace_file->flags))
695 * ring_buffer_discard_commit(buffer, event);
696 * else if (!filter_check_discard(trace_file, entry, buffer, event))
697 * trace_buffer_unlock_commit(buffer, event, irq_flags, pc);
700 * event_triggers_post_call(trace_file, __tt);
703 * static struct trace_event ftrace_event_type_<call> = {
704 * .trace = trace_raw_output_<call>, <-- stage 2
707 * static char print_fmt_<call>[] = <TP_printk>;
709 * static struct trace_event_class __used event_class_<template> = {
710 * .system = "<system>",
711 * .fields_array = trace_event_fields_<call>,
712 * .fields = LIST_HEAD_INIT(event_class_##call.fields),
713 * .raw_init = trace_event_raw_init,
714 * .probe = trace_event_raw_event_##call,
715 * .reg = trace_event_reg,
718 * static struct trace_event_call event_<call> = {
719 * .class = event_class_<template>,
721 * .tp = &__tracepoint_<call>,
723 * .event = &ftrace_event_type_<call>,
724 * .print_fmt = print_fmt_<call>,
725 * .flags = TRACE_EVENT_FL_TRACEPOINT,
727 * // its only safe to use pointers when doing linker tricks to
728 * // create an array.
729 * static struct trace_event_call __used
730 * __section("_ftrace_events") *__event_<call> = &event_<call>;
734 #ifdef CONFIG_PERF_EVENTS
736 #define _TRACE_PERF_PROTO(call, proto) \
737 static notrace void \
738 perf_trace_##call(void *__data, proto);
740 #define _TRACE_PERF_INIT(call) \
741 .perf_probe = perf_trace_##call,
744 #define _TRACE_PERF_PROTO(call, proto)
745 #define _TRACE_PERF_INIT(call)
746 #endif /* CONFIG_PERF_EVENTS */
749 #define __entry entry
752 #define __field(type, item)
754 #undef __field_struct
755 #define __field_struct(type, item)
758 #define __array(type, item, len)
760 #undef __dynamic_array
761 #define __dynamic_array(type, item, len) \
762 __entry->__data_loc_##item = __data_offsets.item;
765 #define __string(item, src) __dynamic_array(char, item, -1)
768 #define __string_len(item, src, len) __dynamic_array(char, item, -1)
771 #define __assign_str(dst, src) \
772 strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)");
774 #undef __assign_str_len
775 #define __assign_str_len(dst, src, len) \
777 memcpy(__get_str(dst), (src), (len)); \
778 __get_str(dst)[len] = '\0'; \
782 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
785 #define __get_bitmask(field) (char *)__get_dynamic_array(field)
787 #undef __assign_bitmask
788 #define __assign_bitmask(dst, src, nr_bits) \
789 memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits))
791 #undef __rel_dynamic_array
792 #define __rel_dynamic_array(type, item, len) \
793 __entry->__rel_loc_##item = __data_offsets.item;
796 #define __rel_string(item, src) __rel_dynamic_array(char, item, -1)
798 #undef __rel_string_len
799 #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, -1)
801 #undef __assign_rel_str
802 #define __assign_rel_str(dst, src) \
803 strcpy(__get_rel_str(dst), (src) ? (const char *)(src) : "(null)");
805 #undef __assign_rel_str_len
806 #define __assign_rel_str_len(dst, src, len) \
808 memcpy(__get_rel_str(dst), (src), (len)); \
809 __get_rel_str(dst)[len] = '\0'; \
813 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
815 #undef __get_rel_bitmask
816 #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
818 #undef __assign_rel_bitmask
819 #define __assign_rel_bitmask(dst, src, nr_bits) \
820 memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits))
822 #undef TP_fast_assign
823 #define TP_fast_assign(args...) args
826 #define __perf_count(c) (c)
829 #define __perf_task(t) (t)
831 #undef DECLARE_EVENT_CLASS
832 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
834 static notrace void \
835 trace_event_raw_event_##call(void *__data, proto) \
837 struct trace_event_file *trace_file = __data; \
838 struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
839 struct trace_event_buffer fbuffer; \
840 struct trace_event_raw_##call *entry; \
843 if (trace_trigger_soft_disabled(trace_file)) \
846 __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
848 entry = trace_event_buffer_reserve(&fbuffer, trace_file, \
849 sizeof(*entry) + __data_size); \
858 trace_event_buffer_commit(&fbuffer); \
861 * The ftrace_test_probe is compiled out, it is only here as a build time check
862 * to make sure that if the tracepoint handling changes, the ftrace probe will
863 * fail to compile unless it too is updated.
867 #define DEFINE_EVENT(template, call, proto, args) \
868 static inline void ftrace_test_probe_##call(void) \
870 check_trace_callback_type_##call(trace_event_raw_event_##template); \
873 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
879 #undef __print_symbolic
881 #undef __print_hex_str
882 #undef __get_dynamic_array
883 #undef __get_dynamic_array_len
886 #undef __get_rel_dynamic_array
887 #undef __get_rel_dynamic_array_len
889 #undef __get_rel_bitmask
891 #undef __print_hex_dump
894 * The below is not executed in the kernel. It is only what is
895 * displayed in the print format for userspace to parse.
897 #undef __print_ns_to_secs
898 #define __print_ns_to_secs(val) (val) / 1000000000UL
900 #undef __print_ns_without_secs
901 #define __print_ns_without_secs(val) (val) % 1000000000UL
904 #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args)
906 #undef DECLARE_EVENT_CLASS
907 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
908 _TRACE_PERF_PROTO(call, PARAMS(proto)); \
909 static char print_fmt_##call[] = print; \
910 static struct trace_event_class __used __refdata event_class_##call = { \
911 .system = TRACE_SYSTEM_STRING, \
912 .fields_array = trace_event_fields_##call, \
913 .fields = LIST_HEAD_INIT(event_class_##call.fields),\
914 .raw_init = trace_event_raw_init, \
915 .probe = trace_event_raw_event_##call, \
916 .reg = trace_event_reg, \
917 _TRACE_PERF_INIT(call) \
921 #define DEFINE_EVENT(template, call, proto, args) \
923 static struct trace_event_call __used event_##call = { \
924 .class = &event_class_##template, \
926 .tp = &__tracepoint_##call, \
928 .event.funcs = &trace_event_type_funcs_##template, \
929 .print_fmt = print_fmt_##template, \
930 .flags = TRACE_EVENT_FL_TRACEPOINT, \
932 static struct trace_event_call __used \
933 __section("_ftrace_events") *__event_##call = &event_##call
935 #undef DEFINE_EVENT_PRINT
936 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
938 static char print_fmt_##call[] = print; \
940 static struct trace_event_call __used event_##call = { \
941 .class = &event_class_##template, \
943 .tp = &__tracepoint_##call, \
945 .event.funcs = &trace_event_type_funcs_##call, \
946 .print_fmt = print_fmt_##call, \
947 .flags = TRACE_EVENT_FL_TRACEPOINT, \
949 static struct trace_event_call __used \
950 __section("_ftrace_events") *__event_##call = &event_##call
952 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)