^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Stage 1 of the trace events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Override the macros in the event tracepoint header <trace/events/XXX.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * to include the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * struct trace_event_raw_<call> {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * struct trace_entry ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * <type> <item>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * <type2> <item2>[<len>];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * [...]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * The <type> <item> is created by the __field(type, item) macro or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * the __array(type2, item2, len) macro.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * We simply do "type item;", and that will create the fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * in the structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/trace_events.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #ifndef TRACE_SYSTEM_VAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define TRACE_SYSTEM_VAR TRACE_SYSTEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define __app__(x, y) str__##x##y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define __app(x, y) __app__(x, y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define TRACE_SYSTEM_STRING __app(TRACE_SYSTEM_VAR,__trace_system_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define TRACE_MAKE_SYSTEM_STR() \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static const char TRACE_SYSTEM_STRING[] = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __stringify(TRACE_SYSTEM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) TRACE_MAKE_SYSTEM_STR();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #undef TRACE_DEFINE_ENUM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define TRACE_DEFINE_ENUM(a) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static struct trace_eval_map __used __initdata \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) __##TRACE_SYSTEM##_##a = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) .system = TRACE_SYSTEM_STRING, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) .eval_string = #a, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) .eval_value = a \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static struct trace_eval_map __used \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) __section("_ftrace_eval_map") \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #undef TRACE_DEFINE_SIZEOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define TRACE_DEFINE_SIZEOF(a) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) static struct trace_eval_map __used __initdata \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) __##TRACE_SYSTEM##_##a = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) .system = TRACE_SYSTEM_STRING, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) .eval_string = "sizeof(" #a ")", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) .eval_value = sizeof(a) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static struct trace_eval_map __used \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) __section("_ftrace_eval_map") \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * DECLARE_EVENT_CLASS can be used to add a generic function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * handlers for events. That is, if all events have the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * parameters and just have distinct trace points.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * Each tracepoint can be defined with DEFINE_EVENT and that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * will map the DECLARE_EVENT_CLASS to the tracepoint.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * TRACE_EVENT is a one to one mapping between tracepoint and template.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #undef TRACE_EVENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) DECLARE_EVENT_CLASS(name, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) PARAMS(proto), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) PARAMS(args), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) PARAMS(tstruct), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) PARAMS(assign), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) PARAMS(print)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #undef __field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define __field(type, item) type item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #undef __field_ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define __field_ext(type, item, filter_type) type item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #undef __field_struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define __field_struct(type, item) type item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #undef __field_struct_ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define __field_struct_ext(type, item, filter_type) type item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #undef __array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define __array(type, item, len) type item[len];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #undef __dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define __dynamic_array(type, item, len) u32 __data_loc_##item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #undef __string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define __string(item, src) __dynamic_array(char, item, -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #undef __bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #undef TP_STRUCT__entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define TP_STRUCT__entry(args...) args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #undef DECLARE_EVENT_CLASS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct trace_event_raw_##name { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct trace_entry ent; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) tstruct \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) char __data[0]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static struct trace_event_class event_class_##name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #undef DEFINE_EVENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define DEFINE_EVENT(template, name, proto, args) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static struct trace_event_call __used \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) __attribute__((__aligned__(4))) event_##name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #undef DEFINE_EVENT_FN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #undef DEFINE_EVENT_PRINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* Callbacks are meaningless to ftrace. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #undef TRACE_EVENT_FN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define TRACE_EVENT_FN(name, proto, args, tstruct, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) assign, print, reg, unreg) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #undef TRACE_EVENT_FN_COND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #define TRACE_EVENT_FN_COND(name, proto, args, cond, tstruct, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) assign, print, reg, unreg) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) TRACE_EVENT_CONDITION(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #undef TRACE_EVENT_FLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define TRACE_EVENT_FLAGS(name, value) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) __TRACE_EVENT_FLAGS(name, value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #undef TRACE_EVENT_PERF_PERM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define TRACE_EVENT_PERF_PERM(name, expr...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) __TRACE_EVENT_PERF_PERM(name, expr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * Stage 2 of the trace events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * Include the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * struct trace_event_data_offsets_<call> {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * u32 <item1>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * u32 <item2>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * [...]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * The __dynamic_array() macro will create each u32 <item>, this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * to keep the offset of each array from the beginning of the event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * The size of an array is also encoded, in the higher 16 bits of <item>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #undef TRACE_DEFINE_ENUM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) #define TRACE_DEFINE_ENUM(a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) #undef TRACE_DEFINE_SIZEOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #define TRACE_DEFINE_SIZEOF(a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #undef __field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #define __field(type, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #undef __field_ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #define __field_ext(type, item, filter_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) #undef __field_struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #define __field_struct(type, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #undef __field_struct_ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #define __field_struct_ext(type, item, filter_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #undef __array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) #define __array(type, item, len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #undef __dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #define __dynamic_array(type, item, len) u32 item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #undef __string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #define __string(item, src) __dynamic_array(char, item, -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #undef __bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) #undef DECLARE_EVENT_CLASS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct trace_event_data_offsets_##call { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) tstruct; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) #undef DEFINE_EVENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #define DEFINE_EVENT(template, name, proto, args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) #undef DEFINE_EVENT_PRINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #define DEFINE_EVENT_PRINT(template, name, proto, args, print)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #undef TRACE_EVENT_FLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #define TRACE_EVENT_FLAGS(event, flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) #undef TRACE_EVENT_PERF_PERM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) #define TRACE_EVENT_PERF_PERM(event, expr...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * Stage 3 of the trace events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * Override the macros in the event tracepoint header <trace/events/XXX.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * to include the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * enum print_line_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * trace_raw_output_<call>(struct trace_iterator *iter, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * struct trace_event_raw_<call> *field; <-- defined in stage 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) * struct trace_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * struct trace_seq *p = &iter->tmp_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * entry = iter->ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) * if (entry->type != event_<call>->event.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * return TRACE_TYPE_UNHANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * field = (typeof(field))entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * trace_seq_init(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * ret = trace_seq_printf(s, "%s: ", <call>);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * ret = trace_seq_printf(s, <TP_printk> "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * return TRACE_TYPE_PARTIAL_LINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * return TRACE_TYPE_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * This is the method used to print the raw event to the trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * output format. Note, this is not needed if the data is read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * in binary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) #undef __entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) #define __entry field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) #undef TP_printk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) #define TP_printk(fmt, args...) fmt "\n", args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) #undef __get_dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) #define __get_dynamic_array(field) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) ((void *)__entry + (__entry->__data_loc_##field & 0xffff))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #undef __get_dynamic_array_len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) #define __get_dynamic_array_len(field) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) ((__entry->__data_loc_##field >> 16) & 0xffff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #undef __get_str
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) #define __get_str(field) ((char *)__get_dynamic_array(field))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) #undef __get_bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) #define __get_bitmask(field) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) void *__bitmask = __get_dynamic_array(field); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) unsigned int __bitmask_size; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) __bitmask_size = __get_dynamic_array_len(field); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) #undef __print_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) #define __print_flags(flag, delim, flag_array...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) static const struct trace_print_flags __flags[] = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) { flag_array, { -1, NULL }}; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) trace_print_flags_seq(p, delim, flag, __flags); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) #undef __print_symbolic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) #define __print_symbolic(value, symbol_array...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) static const struct trace_print_flags symbols[] = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) { symbol_array, { -1, NULL }}; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) trace_print_symbols_seq(p, value, symbols); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) #undef __print_flags_u64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) #undef __print_symbolic_u64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) #if BITS_PER_LONG == 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) #define __print_flags_u64(flag, delim, flag_array...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) static const struct trace_print_flags_u64 __flags[] = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) { flag_array, { -1, NULL } }; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) trace_print_flags_seq_u64(p, delim, flag, __flags); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) #define __print_symbolic_u64(value, symbol_array...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) static const struct trace_print_flags_u64 symbols[] = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) { symbol_array, { -1, NULL } }; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) trace_print_symbols_seq_u64(p, value, symbols); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) #define __print_flags_u64(flag, delim, flag_array...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) __print_flags(flag, delim, flag_array)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) #define __print_symbolic_u64(value, symbol_array...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) __print_symbolic(value, symbol_array)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) #undef __print_hex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) #define __print_hex(buf, buf_len) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) trace_print_hex_seq(p, buf, buf_len, false)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) #undef __print_hex_str
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) #define __print_hex_str(buf, buf_len) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) trace_print_hex_seq(p, buf, buf_len, true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) #undef __print_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) #define __print_array(array, count, el_size) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) BUILD_BUG_ON(el_size != 1 && el_size != 2 && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) el_size != 4 && el_size != 8); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) trace_print_array_seq(p, array, count, el_size); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) #undef __print_hex_dump
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) #define __print_hex_dump(prefix_str, prefix_type, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) rowsize, groupsize, buf, len, ascii) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) trace_print_hex_dump_seq(p, prefix_str, prefix_type, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) rowsize, groupsize, buf, len, ascii)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) #undef DECLARE_EVENT_CLASS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) static notrace enum print_line_t \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) trace_raw_output_##call(struct trace_iterator *iter, int flags, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) struct trace_event *trace_event) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) struct trace_seq *s = &iter->seq; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) struct trace_seq __maybe_unused *p = &iter->tmp_seq; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) struct trace_event_raw_##call *field; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) int ret; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) field = (typeof(field))iter->ent; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) ret = trace_raw_output_prep(iter, trace_event); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) if (ret != TRACE_TYPE_HANDLED) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) return ret; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) trace_seq_printf(s, print); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) return trace_handle_return(s); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) static struct trace_event_functions trace_event_type_funcs_##call = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) .trace = trace_raw_output_##call, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) #undef DEFINE_EVENT_PRINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) static notrace enum print_line_t \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) trace_raw_output_##call(struct trace_iterator *iter, int flags, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) struct trace_event *event) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) struct trace_event_raw_##template *field; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) struct trace_entry *entry; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) struct trace_seq *p = &iter->tmp_seq; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) entry = iter->ent; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) if (entry->type != event_##call.event.type) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) WARN_ON_ONCE(1); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) return TRACE_TYPE_UNHANDLED; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) field = (typeof(field))entry; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) trace_seq_init(p); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) return trace_output_call(iter, #call, print); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) static struct trace_event_functions trace_event_type_funcs_##call = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) .trace = trace_raw_output_##call, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) #undef __field_ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) #define __field_ext(_type, _item, _filter_type) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) .type = #_type, .name = #_item, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) .size = sizeof(_type), .align = __alignof__(_type), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) .is_signed = is_signed_type(_type), .filter_type = _filter_type },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) #undef __field_struct_ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) #define __field_struct_ext(_type, _item, _filter_type) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) .type = #_type, .name = #_item, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) .size = sizeof(_type), .align = __alignof__(_type), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 0, .filter_type = _filter_type },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) #undef __field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) #undef __field_struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) #define __field_struct(type, item) __field_struct_ext(type, item, FILTER_OTHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) #undef __array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) #define __array(_type, _item, _len) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) .type = #_type"["__stringify(_len)"]", .name = #_item, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) .size = sizeof(_type[_len]), .align = __alignof__(_type), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) #undef __dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) #define __dynamic_array(_type, _item, _len) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) .type = "__data_loc " #_type "[]", .name = #_item, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) .size = 4, .align = 4, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) #undef __string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) #define __string(item, src) __dynamic_array(char, item, -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) #undef __bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) #undef DECLARE_EVENT_CLASS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) static struct trace_event_fields trace_event_fields_##call[] = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) tstruct \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) {} };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) #undef DEFINE_EVENT_PRINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) #define DEFINE_EVENT_PRINT(template, name, proto, args, print)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) * remember the offset of each array from the beginning of the event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) #undef __entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) #define __entry entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) #undef __field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) #define __field(type, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) #undef __field_ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) #define __field_ext(type, item, filter_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) #undef __field_struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) #define __field_struct(type, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) #undef __field_struct_ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) #define __field_struct_ext(type, item, filter_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) #undef __array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) #define __array(type, item, len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) #undef __dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) #define __dynamic_array(type, item, len) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) __item_length = (len) * sizeof(type); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) __data_offsets->item = __data_size + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) offsetof(typeof(*entry), __data); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) __data_offsets->item |= __item_length << 16; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) __data_size += __item_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) #undef __string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) #define __string(item, src) __dynamic_array(char, item, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) strlen((src) ? (const char *)(src) : "(null)") + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) * __bitmask_size_in_bytes_raw is the number of bytes needed to hold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) * num_possible_cpus().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) #define __bitmask_size_in_bytes_raw(nr_bits) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) (((nr_bits) + 7) / 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) #define __bitmask_size_in_longs(nr_bits) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) ((__bitmask_size_in_bytes_raw(nr_bits) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) ((BITS_PER_LONG / 8) - 1)) / (BITS_PER_LONG / 8))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * __bitmask_size_in_bytes is the number of bytes needed to hold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) * num_possible_cpus() padded out to the nearest long. This is what
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) * is saved in the buffer, just to be consistent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) #define __bitmask_size_in_bytes(nr_bits) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) (__bitmask_size_in_longs(nr_bits) * (BITS_PER_LONG / 8))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) #undef __bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) __bitmask_size_in_longs(nr_bits))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) #undef DECLARE_EVENT_CLASS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) static inline notrace int trace_event_get_offsets_##call( \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) struct trace_event_data_offsets_##call *__data_offsets, proto) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) int __data_size = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) int __maybe_unused __item_length; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) struct trace_event_raw_##call __maybe_unused *entry; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) tstruct; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) return __data_size; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) * Stage 4 of the trace events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) * Override the macros in the event tracepoint header <trace/events/XXX.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) * to include the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) * For those macros defined with TRACE_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) * static struct trace_event_call event_<call>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) * static void trace_event_raw_event_<call>(void *__data, proto)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) * {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) * struct trace_event_file *trace_file = __data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) * struct trace_event_call *event_call = trace_file->event_call;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) * struct trace_event_data_offsets_<call> __maybe_unused __data_offsets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) * unsigned long eflags = trace_file->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) * enum event_trigger_type __tt = ETT_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) * struct ring_buffer_event *event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * struct trace_event_raw_<call> *entry; <-- defined in stage 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) * struct trace_buffer *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) * unsigned long irq_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * int __data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * int pc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) * if (!(eflags & EVENT_FILE_FL_TRIGGER_COND)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * if (eflags & EVENT_FILE_FL_TRIGGER_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * event_triggers_call(trace_file, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) * if (eflags & EVENT_FILE_FL_SOFT_DISABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) * return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) * }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) * local_save_flags(irq_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) * pc = preempt_count();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) * __data_size = trace_event_get_offsets_<call>(&__data_offsets, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) * event = trace_event_buffer_lock_reserve(&buffer, trace_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) * event_<call>->event.type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) * sizeof(*entry) + __data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) * irq_flags, pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) * if (!event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) * return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) * entry = ring_buffer_event_data(event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) * { <assign>; } <-- Here we assign the entries by the __field and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) * __array macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) * if (eflags & EVENT_FILE_FL_TRIGGER_COND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) * __tt = event_triggers_call(trace_file, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) * if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) * &trace_file->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) * ring_buffer_discard_commit(buffer, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) * else if (!filter_check_discard(trace_file, entry, buffer, event))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) * trace_buffer_unlock_commit(buffer, event, irq_flags, pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) * if (__tt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) * event_triggers_post_call(trace_file, __tt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) * }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) * static struct trace_event ftrace_event_type_<call> = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) * .trace = trace_raw_output_<call>, <-- stage 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) * static char print_fmt_<call>[] = <TP_printk>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) * static struct trace_event_class __used event_class_<template> = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) * .system = "<system>",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) * .fields_array = trace_event_fields_<call>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) * .fields = LIST_HEAD_INIT(event_class_##call.fields),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) * .raw_init = trace_event_raw_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) * .probe = trace_event_raw_event_##call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) * .reg = trace_event_reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) * static struct trace_event_call event_<call> = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) * .class = event_class_<template>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) * {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) * .tp = &__tracepoint_<call>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) * },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) * .event = &ftrace_event_type_<call>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) * .print_fmt = print_fmt_<call>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) * .flags = TRACE_EVENT_FL_TRACEPOINT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) * // its only safe to use pointers when doing linker tricks to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) * // create an array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) * static struct trace_event_call __used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) * __section("_ftrace_events") *__event_<call> = &event_<call>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) #ifdef CONFIG_PERF_EVENTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) #define _TRACE_PERF_PROTO(call, proto) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) static notrace void \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) perf_trace_##call(void *__data, proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) #define _TRACE_PERF_INIT(call) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) .perf_probe = perf_trace_##call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) #define _TRACE_PERF_PROTO(call, proto)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) #define _TRACE_PERF_INIT(call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) #endif /* CONFIG_PERF_EVENTS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) #undef __entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) #define __entry entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) #undef __field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) #define __field(type, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) #undef __field_struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) #define __field_struct(type, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) #undef __array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) #define __array(type, item, len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) #undef __dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) #define __dynamic_array(type, item, len) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) __entry->__data_loc_##item = __data_offsets.item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) #undef __string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) #define __string(item, src) __dynamic_array(char, item, -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) #undef __assign_str
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) #define __assign_str(dst, src) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) #undef __bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) #undef __get_bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) #define __get_bitmask(field) (char *)__get_dynamic_array(field)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) #undef __assign_bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) #define __assign_bitmask(dst, src, nr_bits) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) #undef TP_fast_assign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) #define TP_fast_assign(args...) args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) #undef __perf_count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) #define __perf_count(c) (c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) #undef __perf_task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) #define __perf_task(t) (t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) #undef DECLARE_EVENT_CLASS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) static notrace void \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) trace_event_raw_event_##call(void *__data, proto) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) struct trace_event_file *trace_file = __data; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) struct trace_event_buffer fbuffer; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) struct trace_event_raw_##call *entry; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) int __data_size; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) if (trace_trigger_soft_disabled(trace_file)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) return; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) entry = trace_event_buffer_reserve(&fbuffer, trace_file, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) sizeof(*entry) + __data_size); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) if (!entry) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) return; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) tstruct \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) { assign; } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) trace_event_buffer_commit(&fbuffer); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) * The ftrace_test_probe is compiled out, it is only here as a build time check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) * to make sure that if the tracepoint handling changes, the ftrace probe will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) * fail to compile unless it too is updated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) #undef DEFINE_EVENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) #define DEFINE_EVENT(template, call, proto, args) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) static inline void ftrace_test_probe_##call(void) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) check_trace_callback_type_##call(trace_event_raw_event_##template); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) #undef __entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) #define __entry REC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) #undef __print_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) #undef __print_symbolic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) #undef __print_hex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) #undef __print_hex_str
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) #undef __get_dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) #undef __get_dynamic_array_len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) #undef __get_str
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) #undef __get_bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) #undef __print_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) #undef __print_hex_dump
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) #undef TP_printk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) #undef DECLARE_EVENT_CLASS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) _TRACE_PERF_PROTO(call, PARAMS(proto)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) static char print_fmt_##call[] = print; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) static struct trace_event_class __used __refdata event_class_##call = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) .system = TRACE_SYSTEM_STRING, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) .fields_array = trace_event_fields_##call, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) .fields = LIST_HEAD_INIT(event_class_##call.fields),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) .raw_init = trace_event_raw_init, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) .probe = trace_event_raw_event_##call, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) .reg = trace_event_reg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) _TRACE_PERF_INIT(call) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) #undef DEFINE_EVENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) #define DEFINE_EVENT(template, call, proto, args) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) static struct trace_event_call __used event_##call = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) .class = &event_class_##template, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) .tp = &__tracepoint_##call, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) .event.funcs = &trace_event_type_funcs_##template, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) .print_fmt = print_fmt_##template, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) .flags = TRACE_EVENT_FL_TRACEPOINT, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) }; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) static struct trace_event_call __used \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) __section("_ftrace_events") *__event_##call = &event_##call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) #undef DEFINE_EVENT_PRINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) static char print_fmt_##call[] = print; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) static struct trace_event_call __used event_##call = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) .class = &event_class_##template, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) .tp = &__tracepoint_##call, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) .event.funcs = &trace_event_type_funcs_##call, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) .print_fmt = print_fmt_##call, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) .flags = TRACE_EVENT_FL_TRACEPOINT, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) }; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) static struct trace_event_call __used \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) __section("_ftrace_events") *__event_##call = &event_##call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)