diff options
| author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2015-04-29 13:11:00 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2015-05-13 14:05:10 -0400 |
| commit | ee53bbd172571c944bc2d01b4846fc7c49ebd353 (patch) | |
| tree | 7067012d69282475eb856edeecc01d242c403f52 /include/trace | |
| parent | 2167ae727215714d25fe44945cdbe6157f7ac481 (diff) | |
tracing: Move the perf code out of trace_event.h
The trace_event.h file is for the generic trace event code. Move
the perf related code into its own trace header file perf.h
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include/trace')
| -rw-r--r-- | include/trace/define_trace.h | 1 | ||||
| -rw-r--r-- | include/trace/perf.h | 350 | ||||
| -rw-r--r-- | include/trace/trace_events.h | 351 |
3 files changed, 351 insertions, 351 deletions
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h index b13ba2fc76f7..09b3880105a9 100644 --- a/include/trace/define_trace.h +++ b/include/trace/define_trace.h | |||
| @@ -88,6 +88,7 @@ | |||
| 88 | 88 | ||
| 89 | #ifdef CONFIG_EVENT_TRACING | 89 | #ifdef CONFIG_EVENT_TRACING |
| 90 | #include <trace/trace_events.h> | 90 | #include <trace/trace_events.h> |
| 91 | #include <trace/perf.h> | ||
| 91 | #endif | 92 | #endif |
| 92 | 93 | ||
| 93 | #undef TRACE_EVENT | 94 | #undef TRACE_EVENT |
diff --git a/include/trace/perf.h b/include/trace/perf.h new file mode 100644 index 000000000000..5e82add1647b --- /dev/null +++ b/include/trace/perf.h | |||
| @@ -0,0 +1,350 @@ | |||
| 1 | /* | ||
| 2 | * Stage 4 of the trace events. | ||
| 3 | * | ||
| 4 | * Override the macros in <trace/trace_events.h> to include the following: | ||
| 5 | * | ||
| 6 | * For those macros defined with TRACE_EVENT: | ||
| 7 | * | ||
| 8 | * static struct ftrace_event_call event_<call>; | ||
| 9 | * | ||
| 10 | * static void ftrace_raw_event_<call>(void *__data, proto) | ||
| 11 | * { | ||
| 12 | * struct ftrace_event_file *ftrace_file = __data; | ||
| 13 | * struct ftrace_event_call *event_call = ftrace_file->event_call; | ||
| 14 | * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets; | ||
| 15 | * unsigned long eflags = ftrace_file->flags; | ||
| 16 | * enum event_trigger_type __tt = ETT_NONE; | ||
| 17 | * struct ring_buffer_event *event; | ||
| 18 | * struct ftrace_raw_<call> *entry; <-- defined in stage 1 | ||
| 19 | * struct ring_buffer *buffer; | ||
| 20 | * unsigned long irq_flags; | ||
| 21 | * int __data_size; | ||
| 22 | * int pc; | ||
| 23 | * | ||
| 24 | * if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) { | ||
| 25 | * if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE) | ||
| 26 | * event_triggers_call(ftrace_file, NULL); | ||
| 27 | * if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED) | ||
| 28 | * return; | ||
| 29 | * } | ||
| 30 | * | ||
| 31 | * local_save_flags(irq_flags); | ||
| 32 | * pc = preempt_count(); | ||
| 33 | * | ||
| 34 | * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args); | ||
| 35 | * | ||
| 36 | * event = trace_event_buffer_lock_reserve(&buffer, ftrace_file, | ||
| 37 | * event_<call>->event.type, | ||
| 38 | * sizeof(*entry) + __data_size, | ||
| 39 | * irq_flags, pc); | ||
| 40 | * if (!event) | ||
| 41 | * return; | ||
| 42 | * entry = ring_buffer_event_data(event); | ||
| 43 | * | ||
| 44 | * { <assign>; } <-- Here we assign the entries by the __field and | ||
| 45 | * __array macros. | ||
| 46 | * | ||
| 47 | * if (eflags & FTRACE_EVENT_FL_TRIGGER_COND) | ||
| 48 | * __tt = event_triggers_call(ftrace_file, entry); | ||
| 49 | * | ||
| 50 | * if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, | ||
| 51 | * &ftrace_file->flags)) | ||
| 52 | * ring_buffer_discard_commit(buffer, event); | ||
| 53 | * else if (!filter_check_discard(ftrace_file, entry, buffer, event)) | ||
| 54 | * trace_buffer_unlock_commit(buffer, event, irq_flags, pc); | ||
| 55 | * | ||
| 56 | * if (__tt) | ||
| 57 | * event_triggers_post_call(ftrace_file, __tt); | ||
| 58 | * } | ||
| 59 | * | ||
| 60 | * static struct trace_event ftrace_event_type_<call> = { | ||
| 61 | * .trace = ftrace_raw_output_<call>, <-- stage 2 | ||
| 62 | * }; | ||
| 63 | * | ||
| 64 | * static char print_fmt_<call>[] = <TP_printk>; | ||
| 65 | * | ||
| 66 | * static struct ftrace_event_class __used event_class_<template> = { | ||
| 67 | * .system = "<system>", | ||
| 68 | * .define_fields = ftrace_define_fields_<call>, | ||
| 69 | * .fields = LIST_HEAD_INIT(event_class_##call.fields), | ||
| 70 | * .raw_init = trace_event_raw_init, | ||
| 71 | * .probe = ftrace_raw_event_##call, | ||
| 72 | * .reg = ftrace_event_reg, | ||
| 73 | * }; | ||
| 74 | * | ||
| 75 | * static struct ftrace_event_call event_<call> = { | ||
| 76 | * .class = event_class_<template>, | ||
| 77 | * { | ||
| 78 | * .tp = &__tracepoint_<call>, | ||
| 79 | * }, | ||
| 80 | * .event = &ftrace_event_type_<call>, | ||
| 81 | * .print_fmt = print_fmt_<call>, | ||
| 82 | * .flags = TRACE_EVENT_FL_TRACEPOINT, | ||
| 83 | * }; | ||
| 84 | * // its only safe to use pointers when doing linker tricks to | ||
| 85 | * // create an array. | ||
| 86 | * static struct ftrace_event_call __used | ||
| 87 | * __attribute__((section("_ftrace_events"))) *__event_<call> = &event_<call>; | ||
| 88 | * | ||
| 89 | */ | ||
| 90 | |||
| 91 | #ifdef CONFIG_PERF_EVENTS | ||
| 92 | |||
| 93 | #define _TRACE_PERF_PROTO(call, proto) \ | ||
| 94 | static notrace void \ | ||
| 95 | perf_trace_##call(void *__data, proto); | ||
| 96 | |||
| 97 | #define _TRACE_PERF_INIT(call) \ | ||
| 98 | .perf_probe = perf_trace_##call, | ||
| 99 | |||
| 100 | #else | ||
| 101 | #define _TRACE_PERF_PROTO(call, proto) | ||
| 102 | #define _TRACE_PERF_INIT(call) | ||
| 103 | #endif /* CONFIG_PERF_EVENTS */ | ||
| 104 | |||
| 105 | #undef __entry | ||
| 106 | #define __entry entry | ||
| 107 | |||
| 108 | #undef __field | ||
| 109 | #define __field(type, item) | ||
| 110 | |||
| 111 | #undef __field_struct | ||
| 112 | #define __field_struct(type, item) | ||
| 113 | |||
| 114 | #undef __array | ||
| 115 | #define __array(type, item, len) | ||
| 116 | |||
| 117 | #undef __dynamic_array | ||
| 118 | #define __dynamic_array(type, item, len) \ | ||
| 119 | __entry->__data_loc_##item = __data_offsets.item; | ||
| 120 | |||
| 121 | #undef __string | ||
| 122 | #define __string(item, src) __dynamic_array(char, item, -1) | ||
| 123 | |||
| 124 | #undef __assign_str | ||
| 125 | #define __assign_str(dst, src) \ | ||
| 126 | strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)"); | ||
| 127 | |||
| 128 | #undef __bitmask | ||
| 129 | #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) | ||
| 130 | |||
| 131 | #undef __get_bitmask | ||
| 132 | #define __get_bitmask(field) (char *)__get_dynamic_array(field) | ||
| 133 | |||
| 134 | #undef __assign_bitmask | ||
| 135 | #define __assign_bitmask(dst, src, nr_bits) \ | ||
| 136 | memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) | ||
| 137 | |||
| 138 | #undef TP_fast_assign | ||
| 139 | #define TP_fast_assign(args...) args | ||
| 140 | |||
| 141 | #undef __perf_addr | ||
| 142 | #define __perf_addr(a) (a) | ||
| 143 | |||
| 144 | #undef __perf_count | ||
| 145 | #define __perf_count(c) (c) | ||
| 146 | |||
| 147 | #undef __perf_task | ||
| 148 | #define __perf_task(t) (t) | ||
| 149 | |||
| 150 | #undef DECLARE_EVENT_CLASS | ||
| 151 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ | ||
| 152 | \ | ||
| 153 | static notrace void \ | ||
| 154 | ftrace_raw_event_##call(void *__data, proto) \ | ||
| 155 | { \ | ||
| 156 | struct ftrace_event_file *ftrace_file = __data; \ | ||
| 157 | struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\ | ||
| 158 | struct ftrace_event_buffer fbuffer; \ | ||
| 159 | struct ftrace_raw_##call *entry; \ | ||
| 160 | int __data_size; \ | ||
| 161 | \ | ||
| 162 | if (ftrace_trigger_soft_disabled(ftrace_file)) \ | ||
| 163 | return; \ | ||
| 164 | \ | ||
| 165 | __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \ | ||
| 166 | \ | ||
| 167 | entry = ftrace_event_buffer_reserve(&fbuffer, ftrace_file, \ | ||
| 168 | sizeof(*entry) + __data_size); \ | ||
| 169 | \ | ||
| 170 | if (!entry) \ | ||
| 171 | return; \ | ||
| 172 | \ | ||
| 173 | tstruct \ | ||
| 174 | \ | ||
| 175 | { assign; } \ | ||
| 176 | \ | ||
| 177 | ftrace_event_buffer_commit(&fbuffer); \ | ||
| 178 | } | ||
| 179 | /* | ||
| 180 | * The ftrace_test_probe is compiled out, it is only here as a build time check | ||
| 181 | * to make sure that if the tracepoint handling changes, the ftrace probe will | ||
| 182 | * fail to compile unless it too is updated. | ||
| 183 | */ | ||
| 184 | |||
| 185 | #undef DEFINE_EVENT | ||
| 186 | #define DEFINE_EVENT(template, call, proto, args) \ | ||
| 187 | static inline void ftrace_test_probe_##call(void) \ | ||
| 188 | { \ | ||
| 189 | check_trace_callback_type_##call(ftrace_raw_event_##template); \ | ||
| 190 | } | ||
| 191 | |||
| 192 | #undef DEFINE_EVENT_PRINT | ||
| 193 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) | ||
| 194 | |||
| 195 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | ||
| 196 | |||
| 197 | |||
