Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Stage 1 of the trace events. |
| 3 | * |
| 4 | * Override the macros in <trace/trace_events.h> to include the following: |
| 5 | * |
| 6 | * struct ftrace_raw_<call> { |
| 7 | * struct trace_entry ent; |
| 8 | * <type> <item>; |
| 9 | * <type2> <item2>[<len>]; |
| 10 | * [...] |
| 11 | * }; |
| 12 | * |
| 13 | * The <type> <item> is created by the __field(type, item) macro or |
| 14 | * the __array(type2, item2, len) macro. |
| 15 | * We simply do "type item;", and that will create the fields |
| 16 | * in the structure. |
| 17 | */ |
| 18 | |
| 19 | #include <linux/ftrace_event.h> |
| 20 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 21 | /* |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 22 | * DECLARE_EVENT_CLASS can be used to add a generic function |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 23 | * handlers for events. That is, if all events have the same |
| 24 | * parameters and just have distinct trace points. |
| 25 | * Each tracepoint can be defined with DEFINE_EVENT and that |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 26 | * will map the DECLARE_EVENT_CLASS to the tracepoint. |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 27 | * |
| 28 | * TRACE_EVENT is a one to one mapping between tracepoint and template. |
| 29 | */ |
| 30 | #undef TRACE_EVENT |
| 31 | #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 32 | DECLARE_EVENT_CLASS(name, \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 33 | PARAMS(proto), \ |
| 34 | PARAMS(args), \ |
| 35 | PARAMS(tstruct), \ |
| 36 | PARAMS(assign), \ |
| 37 | PARAMS(print)); \ |
| 38 | DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args)); |
| 39 | |
| 40 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 41 | #undef __field |
| 42 | #define __field(type, item) type item; |
| 43 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 44 | #undef __field_ext |
| 45 | #define __field_ext(type, item, filter_type) type item; |
| 46 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 47 | #undef __array |
| 48 | #define __array(type, item, len) type item[len]; |
| 49 | |
| 50 | #undef __dynamic_array |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 51 | #define __dynamic_array(type, item, len) u32 __data_loc_##item; |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 52 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 53 | #undef __string |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 54 | #define __string(item, src) __dynamic_array(char, item, -1) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 55 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 56 | #undef TP_STRUCT__entry |
| 57 | #define TP_STRUCT__entry(args...) args |
| 58 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 59 | #undef DECLARE_EVENT_CLASS |
| 60 | #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 61 | struct ftrace_raw_##name { \ |
| 62 | struct trace_entry ent; \ |
| 63 | tstruct \ |
| 64 | char __data[0]; \ |
| 65 | }; |
| 66 | #undef DEFINE_EVENT |
| 67 | #define DEFINE_EVENT(template, name, proto, args) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 68 | static struct ftrace_event_call event_##name |
| 69 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 70 | #undef DEFINE_EVENT_PRINT |
| 71 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 72 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 73 | |
Frederic Weisbecker | 0dd7b74 | 2009-08-28 00:50:06 +0200 | [diff] [blame] | 74 | #undef __cpparg |
| 75 | #define __cpparg(arg...) arg |
| 76 | |
Josh Stone | 9741987 | 2009-08-24 14:43:13 -0700 | [diff] [blame] | 77 | /* Callbacks are meaningless to ftrace. */ |
| 78 | #undef TRACE_EVENT_FN |
Frederic Weisbecker | 0dd7b74 | 2009-08-28 00:50:06 +0200 | [diff] [blame] | 79 | #define TRACE_EVENT_FN(name, proto, args, tstruct, \ |
| 80 | assign, print, reg, unreg) \ |
| 81 | TRACE_EVENT(name, __cpparg(proto), __cpparg(args), \ |
| 82 | __cpparg(tstruct), __cpparg(assign), __cpparg(print)) \ |
Josh Stone | 9741987 | 2009-08-24 14:43:13 -0700 | [diff] [blame] | 83 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 84 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 85 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 86 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 87 | /* |
| 88 | * Stage 2 of the trace events. |
| 89 | * |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 90 | * Include the following: |
| 91 | * |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 92 | * struct ftrace_data_offsets_<call> { |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 93 | * u32 <item1>; |
| 94 | * u32 <item2>; |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 95 | * [...] |
| 96 | * }; |
| 97 | * |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 98 | * The __dynamic_array() macro will create each u32 <item>, this is |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 99 | * to keep the offset of each array from the beginning of the event. |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 100 | * The size of an array is also encoded, in the higher 16 bits of <item>. |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 101 | */ |
| 102 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 103 | #undef __field |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 104 | #define __field(type, item) |
| 105 | |
| 106 | #undef __field_ext |
| 107 | #define __field_ext(type, item, filter_type) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 108 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 109 | #undef __array |
| 110 | #define __array(type, item, len) |
| 111 | |
| 112 | #undef __dynamic_array |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 113 | #define __dynamic_array(type, item, len) u32 item; |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 114 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 115 | #undef __string |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 116 | #define __string(item, src) __dynamic_array(char, item, -1) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 117 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 118 | #undef DECLARE_EVENT_CLASS |
| 119 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 120 | struct ftrace_data_offsets_##call { \ |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 121 | tstruct; \ |
| 122 | }; |
| 123 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 124 | #undef DEFINE_EVENT |
| 125 | #define DEFINE_EVENT(template, name, proto, args) |
| 126 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 127 | #undef DEFINE_EVENT_PRINT |
| 128 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 129 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 130 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 131 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 132 | |
| 133 | /* |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 134 | * Setup the showing format of trace point. |
| 135 | * |
| 136 | * int |
| 137 | * ftrace_format_##call(struct trace_seq *s) |
| 138 | * { |
| 139 | * struct ftrace_raw_##call field; |
| 140 | * int ret; |
| 141 | * |
| 142 | * ret = trace_seq_printf(s, #type " " #item ";" |
| 143 | * " offset:%u; size:%u;\n", |
| 144 | * offsetof(struct ftrace_raw_##call, item), |
| 145 | * sizeof(field.type)); |
| 146 | * |
| 147 | * } |
| 148 | */ |
| 149 | |
| 150 | #undef TP_STRUCT__entry |
| 151 | #define TP_STRUCT__entry(args...) args |
| 152 | |
| 153 | #undef __field |
| 154 | #define __field(type, item) \ |
| 155 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ |
Tom Zanussi | 26a5074 | 2009-10-06 01:09:50 -0500 | [diff] [blame] | 156 | "offset:%u;\tsize:%u;\tsigned:%u;\n", \ |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 157 | (unsigned int)offsetof(typeof(field), item), \ |
Tom Zanussi | 26a5074 | 2009-10-06 01:09:50 -0500 | [diff] [blame] | 158 | (unsigned int)sizeof(field.item), \ |
| 159 | (unsigned int)is_signed_type(type)); \ |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 160 | if (!ret) \ |
| 161 | return 0; |
| 162 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 163 | #undef __field_ext |
| 164 | #define __field_ext(type, item, filter_type) __field(type, item) |
| 165 | |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 166 | #undef __array |
| 167 | #define __array(type, item, len) \ |
| 168 | ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \ |
Tom Zanussi | 26a5074 | 2009-10-06 01:09:50 -0500 | [diff] [blame] | 169 | "offset:%u;\tsize:%u;\tsigned:%u;\n", \ |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 170 | (unsigned int)offsetof(typeof(field), item), \ |
Tom Zanussi | 26a5074 | 2009-10-06 01:09:50 -0500 | [diff] [blame] | 171 | (unsigned int)sizeof(field.item), \ |
| 172 | (unsigned int)is_signed_type(type)); \ |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 173 | if (!ret) \ |
| 174 | return 0; |
| 175 | |
| 176 | #undef __dynamic_array |
| 177 | #define __dynamic_array(type, item, len) \ |
Lai Jiangshan | 68fd60a | 2009-07-16 10:53:34 +0800 | [diff] [blame] | 178 | ret = trace_seq_printf(s, "\tfield:__data_loc " #type "[] " #item ";\t"\ |
Tom Zanussi | 26a5074 | 2009-10-06 01:09:50 -0500 | [diff] [blame] | 179 | "offset:%u;\tsize:%u;\tsigned:%u;\n", \ |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 180 | (unsigned int)offsetof(typeof(field), \ |
| 181 | __data_loc_##item), \ |
Tom Zanussi | 26a5074 | 2009-10-06 01:09:50 -0500 | [diff] [blame] | 182 | (unsigned int)sizeof(field.__data_loc_##item), \ |
| 183 | (unsigned int)is_signed_type(type)); \ |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 184 | if (!ret) \ |
| 185 | return 0; |
| 186 | |
| 187 | #undef __string |
| 188 | #define __string(item, src) __dynamic_array(char, item, -1) |
| 189 | |
| 190 | #undef __entry |
| 191 | #define __entry REC |
| 192 | |
| 193 | #undef __print_symbolic |
| 194 | #undef __get_dynamic_array |
| 195 | #undef __get_str |
| 196 | |
| 197 | #undef TP_printk |
Johannes Berg | 811cb50 | 2009-11-13 23:40:09 +0100 | [diff] [blame] | 198 | #define TP_printk(fmt, args...) "\"%s\", %s\n", fmt, __stringify(args) |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 199 | |
| 200 | #undef TP_fast_assign |
| 201 | #define TP_fast_assign(args...) args |
| 202 | |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 203 | #undef TP_perf_assign |
| 204 | #define TP_perf_assign(args...) |
| 205 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 206 | #undef DECLARE_EVENT_CLASS |
| 207 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \ |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 208 | static int \ |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 209 | ftrace_format_setup_##call(struct ftrace_event_call *unused, \ |
| 210 | struct trace_seq *s) \ |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 211 | { \ |
| 212 | struct ftrace_raw_##call field __attribute__((unused)); \ |
| 213 | int ret = 0; \ |
| 214 | \ |
| 215 | tstruct; \ |
| 216 | \ |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 217 | return ret; \ |
| 218 | } \ |
| 219 | \ |
| 220 | static int \ |
| 221 | ftrace_format_##call(struct ftrace_event_call *unused, \ |
| 222 | struct trace_seq *s) \ |
| 223 | { \ |
| 224 | int ret = 0; \ |
| 225 | \ |
| 226 | ret = ftrace_format_setup_##call(unused, s); \ |
| 227 | if (!ret) \ |
| 228 | return ret; \ |
| 229 | \ |
| 230 | ret = trace_seq_printf(s, "\nprint fmt: " print); \ |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 231 | \ |
| 232 | return ret; \ |
| 233 | } |
| 234 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 235 | #undef DEFINE_EVENT |
| 236 | #define DEFINE_EVENT(template, name, proto, args) |
| 237 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 238 | #undef DEFINE_EVENT_PRINT |
| 239 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 240 | static int \ |
| 241 | ftrace_format_##name(struct ftrace_event_call *unused, \ |
| 242 | struct trace_seq *s) \ |
| 243 | { \ |
| 244 | int ret = 0; \ |
| 245 | \ |
| 246 | ret = ftrace_format_setup_##template(unused, s); \ |
| 247 | if (!ret) \ |
| 248 | return ret; \ |
| 249 | \ |
Steven Rostedt | 6ff9a64 | 2009-06-10 14:28:34 -0400 | [diff] [blame] | 250 | trace_seq_printf(s, "\nprint fmt: " print); \ |
| 251 | \ |
| 252 | return ret; \ |
| 253 | } |
| 254 | |
| 255 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 256 | |
| 257 | /* |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 258 | * Stage 3 of the trace events. |
| 259 | * |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 260 | * Override the macros in <trace/trace_events.h> to include the following: |
| 261 | * |
| 262 | * enum print_line_t |
| 263 | * ftrace_raw_output_<call>(struct trace_iterator *iter, int flags) |
| 264 | * { |
| 265 | * struct trace_seq *s = &iter->seq; |
| 266 | * struct ftrace_raw_<call> *field; <-- defined in stage 1 |
| 267 | * struct trace_entry *entry; |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 268 | * struct trace_seq *p; |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 269 | * int ret; |
| 270 | * |
| 271 | * entry = iter->ent; |
| 272 | * |
| 273 | * if (entry->type != event_<call>.id) { |
| 274 | * WARN_ON_ONCE(1); |
| 275 | * return TRACE_TYPE_UNHANDLED; |
| 276 | * } |
| 277 | * |
| 278 | * field = (typeof(field))entry; |
| 279 | * |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 280 | * p = get_cpu_var(ftrace_event_seq); |
Steven Whitehouse | 56d8bd3 | 2009-06-03 14:52:03 +0100 | [diff] [blame] | 281 | * trace_seq_init(p); |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 282 | * ret = trace_seq_printf(s, <TP_printk> "\n"); |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 283 | * put_cpu(); |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 284 | * if (!ret) |
| 285 | * return TRACE_TYPE_PARTIAL_LINE; |
| 286 | * |
| 287 | * return TRACE_TYPE_HANDLED; |
| 288 | * } |
| 289 | * |
| 290 | * This is the method used to print the raw event to the trace |
| 291 | * output format. Note, this is not needed if the data is read |
| 292 | * in binary. |
| 293 | */ |
| 294 | |
| 295 | #undef __entry |
| 296 | #define __entry field |
| 297 | |
| 298 | #undef TP_printk |
| 299 | #define TP_printk(fmt, args...) fmt "\n", args |
| 300 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 301 | #undef __get_dynamic_array |
| 302 | #define __get_dynamic_array(field) \ |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 303 | ((void *)__entry + (__entry->__data_loc_##field & 0xffff)) |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 304 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 305 | #undef __get_str |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 306 | #define __get_str(field) (char *)__get_dynamic_array(field) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 307 | |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 308 | #undef __print_flags |
| 309 | #define __print_flags(flag, delim, flag_array...) \ |
| 310 | ({ \ |
Steven Rostedt | a48f494 | 2009-09-14 11:18:02 -0400 | [diff] [blame] | 311 | static const struct trace_print_flags __flags[] = \ |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 312 | { flag_array, { -1, NULL }}; \ |
Steven Rostedt | a48f494 | 2009-09-14 11:18:02 -0400 | [diff] [blame] | 313 | ftrace_print_flags_seq(p, delim, flag, __flags); \ |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 314 | }) |
| 315 | |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 316 | #undef __print_symbolic |
| 317 | #define __print_symbolic(value, symbol_array...) \ |
| 318 | ({ \ |
| 319 | static const struct trace_print_flags symbols[] = \ |
| 320 | { symbol_array, { -1, NULL }}; \ |
| 321 | ftrace_print_symbols_seq(p, value, symbols); \ |
| 322 | }) |
| 323 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 324 | #undef DECLARE_EVENT_CLASS |
| 325 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt | ec827c7 | 2009-09-14 10:50:23 -0400 | [diff] [blame] | 326 | static enum print_line_t \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 327 | ftrace_raw_output_id_##call(int event_id, const char *name, \ |
| 328 | struct trace_iterator *iter, int flags) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 329 | { \ |
| 330 | struct trace_seq *s = &iter->seq; \ |
| 331 | struct ftrace_raw_##call *field; \ |
| 332 | struct trace_entry *entry; \ |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 333 | struct trace_seq *p; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 334 | int ret; \ |
| 335 | \ |
| 336 | entry = iter->ent; \ |
| 337 | \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 338 | if (entry->type != event_id) { \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 339 | WARN_ON_ONCE(1); \ |
| 340 | return TRACE_TYPE_UNHANDLED; \ |
| 341 | } \ |
| 342 | \ |
| 343 | field = (typeof(field))entry; \ |
| 344 | \ |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 345 | p = &get_cpu_var(ftrace_event_seq); \ |
Steven Whitehouse | 56d8bd3 | 2009-06-03 14:52:03 +0100 | [diff] [blame] | 346 | trace_seq_init(p); \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 347 | ret = trace_seq_printf(s, "%s: ", name); \ |
| 348 | if (ret) \ |
| 349 | ret = trace_seq_printf(s, print); \ |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 350 | put_cpu(); \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 351 | if (!ret) \ |
| 352 | return TRACE_TYPE_PARTIAL_LINE; \ |
| 353 | \ |
| 354 | return TRACE_TYPE_HANDLED; \ |
| 355 | } |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 356 | |
| 357 | #undef DEFINE_EVENT |
| 358 | #define DEFINE_EVENT(template, name, proto, args) \ |
| 359 | static enum print_line_t \ |
| 360 | ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \ |
| 361 | { \ |
| 362 | return ftrace_raw_output_id_##template(event_##name.id, \ |
| 363 | #name, iter, flags); \ |
| 364 | } |
| 365 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 366 | #undef DEFINE_EVENT_PRINT |
| 367 | #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 368 | static enum print_line_t \ |
| 369 | ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \ |
| 370 | { \ |
| 371 | struct trace_seq *s = &iter->seq; \ |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 372 | struct ftrace_raw_##template *field; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 373 | struct trace_entry *entry; \ |
| 374 | struct trace_seq *p; \ |
| 375 | int ret; \ |
| 376 | \ |
| 377 | entry = iter->ent; \ |
| 378 | \ |
| 379 | if (entry->type != event_##call.id) { \ |
| 380 | WARN_ON_ONCE(1); \ |
| 381 | return TRACE_TYPE_UNHANDLED; \ |
| 382 | } \ |
| 383 | \ |
| 384 | field = (typeof(field))entry; \ |
| 385 | \ |
| 386 | p = &get_cpu_var(ftrace_event_seq); \ |
| 387 | trace_seq_init(p); \ |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 388 | ret = trace_seq_printf(s, "%s: ", #call); \ |
| 389 | if (ret) \ |
| 390 | ret = trace_seq_printf(s, print); \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 391 | put_cpu(); \ |
| 392 | if (!ret) \ |
| 393 | return TRACE_TYPE_PARTIAL_LINE; \ |
| 394 | \ |
| 395 | return TRACE_TYPE_HANDLED; \ |
| 396 | } |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 397 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 398 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 399 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 400 | #undef __field_ext |
| 401 | #define __field_ext(type, item, filter_type) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 402 | ret = trace_define_field(event_call, #type, #item, \ |
| 403 | offsetof(typeof(field), item), \ |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 404 | sizeof(field.item), \ |
| 405 | is_signed_type(type), filter_type); \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 406 | if (ret) \ |
| 407 | return ret; |
| 408 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 409 | #undef __field |
| 410 | #define __field(type, item) __field_ext(type, item, FILTER_OTHER) |
| 411 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 412 | #undef __array |
| 413 | #define __array(type, item, len) \ |
| 414 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ |
| 415 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
| 416 | offsetof(typeof(field), item), \ |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 417 | sizeof(field.item), 0, FILTER_OTHER); \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 418 | if (ret) \ |
| 419 | return ret; |
| 420 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 421 | #undef __dynamic_array |
| 422 | #define __dynamic_array(type, item, len) \ |
Lai Jiangshan | 68fd60a | 2009-07-16 10:53:34 +0800 | [diff] [blame] | 423 | ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \ |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 424 | offsetof(typeof(field), __data_loc_##item), \ |
| 425 | sizeof(field.__data_loc_##item), 0, \ |
| 426 | FILTER_OTHER); |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 427 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 428 | #undef __string |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 429 | #define __string(item, src) __dynamic_array(char, item, -1) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 430 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 431 | #undef DECLARE_EVENT_CLASS |
| 432 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \ |
Steven Rostedt | ec827c7 | 2009-09-14 10:50:23 -0400 | [diff] [blame] | 433 | static int \ |
Li Zefan | 14be96c | 2009-08-19 15:53:52 +0800 | [diff] [blame] | 434 | ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 435 | { \ |
| 436 | struct ftrace_raw_##call field; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 437 | int ret; \ |
| 438 | \ |
Li Zefan | e647d6b | 2009-08-19 15:54:32 +0800 | [diff] [blame] | 439 | ret = trace_define_common_fields(event_call); \ |
| 440 | if (ret) \ |
| 441 | return ret; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 442 | \ |
| 443 | tstruct; \ |
| 444 | \ |
| 445 | return ret; \ |
| 446 | } |
| 447 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 448 | #undef DEFINE_EVENT |
| 449 | #define DEFINE_EVENT(template, name, proto, args) |
| 450 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 451 | #undef DEFINE_EVENT_PRINT |
| 452 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 453 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 454 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 455 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 456 | |
| 457 | /* |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 458 | * remember the offset of each array from the beginning of the event. |
| 459 | */ |
| 460 | |
| 461 | #undef __entry |
| 462 | #define __entry entry |
| 463 | |
| 464 | #undef __field |
| 465 | #define __field(type, item) |
| 466 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 467 | #undef __field_ext |
| 468 | #define __field_ext(type, item, filter_type) |
| 469 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 470 | #undef __array |
| 471 | #define __array(type, item, len) |
| 472 | |
| 473 | #undef __dynamic_array |
| 474 | #define __dynamic_array(type, item, len) \ |
| 475 | __data_offsets->item = __data_size + \ |
| 476 | offsetof(typeof(*entry), __data); \ |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 477 | __data_offsets->item |= (len * sizeof(type)) << 16; \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 478 | __data_size += (len) * sizeof(type); |
| 479 | |
| 480 | #undef __string |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 481 | #define __string(item, src) __dynamic_array(char, item, strlen(src) + 1) |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 482 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 483 | #undef DECLARE_EVENT_CLASS |
| 484 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 485 | static inline int ftrace_get_offsets_##call( \ |
| 486 | struct ftrace_data_offsets_##call *__data_offsets, proto) \ |
| 487 | { \ |
| 488 | int __data_size = 0; \ |
| 489 | struct ftrace_raw_##call __maybe_unused *entry; \ |
| 490 | \ |
| 491 | tstruct; \ |
| 492 | \ |
| 493 | return __data_size; \ |
| 494 | } |
| 495 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 496 | #undef DEFINE_EVENT |
| 497 | #define DEFINE_EVENT(template, name, proto, args) |
| 498 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 499 | #undef DEFINE_EVENT_PRINT |
| 500 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 501 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 502 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 503 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 504 | |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 505 | #ifdef CONFIG_EVENT_PROFILE |
| 506 | |
| 507 | /* |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 508 | * Generate the functions needed for tracepoint perf_event support. |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 509 | * |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 510 | * NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 511 | * |
Frederic Weisbecker | e5e25cf | 2009-09-18 00:54:43 +0200 | [diff] [blame] | 512 | * static int ftrace_profile_enable_<call>(void) |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 513 | * { |
Frederic Weisbecker | e5e25cf | 2009-09-18 00:54:43 +0200 | [diff] [blame] | 514 | * return register_trace_<call>(ftrace_profile_<call>); |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 515 | * } |
| 516 | * |
Frederic Weisbecker | e5e25cf | 2009-09-18 00:54:43 +0200 | [diff] [blame] | 517 | * static void ftrace_profile_disable_<call>(void) |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 518 | * { |
Frederic Weisbecker | e5e25cf | 2009-09-18 00:54:43 +0200 | [diff] [blame] | 519 | * unregister_trace_<call>(ftrace_profile_<call>); |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 520 | * } |
| 521 | * |
| 522 | */ |
| 523 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 524 | #undef DECLARE_EVENT_CLASS |
| 525 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 526 | |
| 527 | #undef DEFINE_EVENT |
| 528 | #define DEFINE_EVENT(template, name, proto, args) \ |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 529 | \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 530 | static void ftrace_profile_##name(proto); \ |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 531 | \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 532 | static int ftrace_profile_enable_##name(struct ftrace_event_call *unused)\ |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 533 | { \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 534 | return register_trace_##name(ftrace_profile_##name); \ |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 535 | } \ |
| 536 | \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 537 | static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\ |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 538 | { \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 539 | unregister_trace_##name(ftrace_profile_##name); \ |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 540 | } |
| 541 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 542 | #undef DEFINE_EVENT_PRINT |
| 543 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 544 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 545 | |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 546 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 547 | |
Peter Zijlstra | 3a65930 | 2009-07-21 17:34:57 +0200 | [diff] [blame] | 548 | #endif |
| 549 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 550 | /* |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 551 | * Stage 4 of the trace events. |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 552 | * |
| 553 | * Override the macros in <trace/trace_events.h> to include the following: |
| 554 | * |
| 555 | * static void ftrace_event_<call>(proto) |
| 556 | * { |
| 557 | * event_trace_printk(_RET_IP_, "<call>: " <fmt>); |
| 558 | * } |
| 559 | * |
Masami Hiramatsu | bd1a5c8 | 2009-08-13 16:34:53 -0400 | [diff] [blame] | 560 | * static int ftrace_reg_event_<call>(struct ftrace_event_call *unused) |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 561 | * { |
| 562 | * int ret; |
| 563 | * |
| 564 | * ret = register_trace_<call>(ftrace_event_<call>); |
| 565 | * if (!ret) |
| 566 | * pr_info("event trace: Could not activate trace point " |
| 567 | * "probe to <call>"); |
| 568 | * return ret; |
| 569 | * } |
| 570 | * |
Masami Hiramatsu | bd1a5c8 | 2009-08-13 16:34:53 -0400 | [diff] [blame] | 571 | * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused) |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 572 | * { |
| 573 | * unregister_trace_<call>(ftrace_event_<call>); |
| 574 | * } |
| 575 | * |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 576 | * |
| 577 | * For those macros defined with TRACE_EVENT: |
| 578 | * |
| 579 | * static struct ftrace_event_call event_<call>; |
| 580 | * |
| 581 | * static void ftrace_raw_event_<call>(proto) |
| 582 | * { |
| 583 | * struct ring_buffer_event *event; |
| 584 | * struct ftrace_raw_<call> *entry; <-- defined in stage 1 |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 585 | * struct ring_buffer *buffer; |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 586 | * unsigned long irq_flags; |
| 587 | * int pc; |
| 588 | * |
| 589 | * local_save_flags(irq_flags); |
| 590 | * pc = preempt_count(); |
| 591 | * |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 592 | * event = trace_current_buffer_lock_reserve(&buffer, |
| 593 | * event_<call>.id, |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 594 | * sizeof(struct ftrace_raw_<call>), |
| 595 | * irq_flags, pc); |
| 596 | * if (!event) |
| 597 | * return; |
| 598 | * entry = ring_buffer_event_data(event); |
| 599 | * |
| 600 | * <assign>; <-- Here we assign the entries by the __field and |
| 601 | * __array macros. |
| 602 | * |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 603 | * trace_current_buffer_unlock_commit(buffer, event, irq_flags, pc); |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 604 | * } |
| 605 | * |
Masami Hiramatsu | bd1a5c8 | 2009-08-13 16:34:53 -0400 | [diff] [blame] | 606 | * static int ftrace_raw_reg_event_<call>(struct ftrace_event_call *unused) |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 607 | * { |
| 608 | * int ret; |
| 609 | * |
| 610 | * ret = register_trace_<call>(ftrace_raw_event_<call>); |
| 611 | * if (!ret) |
| 612 | * pr_info("event trace: Could not activate trace point " |
| 613 | * "probe to <call>"); |
| 614 | * return ret; |
| 615 | * } |
| 616 | * |
Masami Hiramatsu | bd1a5c8 | 2009-08-13 16:34:53 -0400 | [diff] [blame] | 617 | * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused) |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 618 | * { |
| 619 | * unregister_trace_<call>(ftrace_raw_event_<call>); |
| 620 | * } |
| 621 | * |
| 622 | * static struct trace_event ftrace_event_type_<call> = { |
| 623 | * .trace = ftrace_raw_output_<call>, <-- stage 2 |
| 624 | * }; |
| 625 | * |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 626 | * static struct ftrace_event_call __used |
| 627 | * __attribute__((__aligned__(4))) |
| 628 | * __attribute__((section("_ftrace_events"))) event_<call> = { |
| 629 | * .name = "<call>", |
| 630 | * .system = "<system>", |
Li Zefan | 87d9b4e | 2009-12-08 11:14:20 +0800 | [diff] [blame^] | 631 | * .raw_init = trace_event_raw_init, |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 632 | * .regfunc = ftrace_reg_event_<call>, |
| 633 | * .unregfunc = ftrace_unreg_event_<call>, |
| 634 | * .show_format = ftrace_format_<call>, |
| 635 | * } |
| 636 | * |
| 637 | */ |
| 638 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 639 | #ifdef CONFIG_EVENT_PROFILE |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 640 | |
| 641 | #define _TRACE_PROFILE_INIT(call) \ |
| 642 | .profile_count = ATOMIC_INIT(-1), \ |
| 643 | .profile_enable = ftrace_profile_enable_##call, \ |
| 644 | .profile_disable = ftrace_profile_disable_##call, |
| 645 | |
| 646 | #else |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 647 | #define _TRACE_PROFILE_INIT(call) |
| 648 | #endif |
| 649 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 650 | #undef __entry |
| 651 | #define __entry entry |
| 652 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 653 | #undef __field |
| 654 | #define __field(type, item) |
| 655 | |
| 656 | #undef __array |
| 657 | #define __array(type, item, len) |
| 658 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 659 | #undef __dynamic_array |
| 660 | #define __dynamic_array(type, item, len) \ |
| 661 | __entry->__data_loc_##item = __data_offsets.item; |
| 662 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 663 | #undef __string |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 664 | #define __string(item, src) __dynamic_array(char, item, -1) \ |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 665 | |
| 666 | #undef __assign_str |
| 667 | #define __assign_str(dst, src) \ |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 668 | strcpy(__get_str(dst), src); |
| 669 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 670 | #undef DECLARE_EVENT_CLASS |
| 671 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 672 | \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 673 | static void ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \ |
| 674 | proto) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 675 | { \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 676 | struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 677 | struct ring_buffer_event *event; \ |
| 678 | struct ftrace_raw_##call *entry; \ |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 679 | struct ring_buffer *buffer; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 680 | unsigned long irq_flags; \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 681 | int __data_size; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 682 | int pc; \ |
| 683 | \ |
| 684 | local_save_flags(irq_flags); \ |
| 685 | pc = preempt_count(); \ |
| 686 | \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 687 | __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \ |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 688 | \ |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 689 | event = trace_current_buffer_lock_reserve(&buffer, \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 690 | event_call->id, \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 691 | sizeof(*entry) + __data_size, \ |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 692 | irq_flags, pc); \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 693 | if (!event) \ |
| 694 | return; \ |
| 695 | entry = ring_buffer_event_data(event); \ |
| 696 | \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 697 | \ |
| 698 | tstruct \ |
| 699 | \ |
Li Zefan | a9c1c3a | 2009-06-01 15:35:13 +0800 | [diff] [blame] | 700 | { assign; } \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 701 | \ |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 702 | if (!filter_current_check_discard(buffer, event_call, entry, event)) \ |
| 703 | trace_nowake_buffer_unlock_commit(buffer, \ |
| 704 | event, irq_flags, pc); \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | #undef DEFINE_EVENT |
| 708 | #define DEFINE_EVENT(template, call, proto, args) \ |
| 709 | \ |
| 710 | static void ftrace_raw_event_##call(proto) \ |
| 711 | { \ |
| 712 | ftrace_raw_event_id_##template(&event_##call, args); \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 713 | } \ |
| 714 | \ |
Masami Hiramatsu | bd1a5c8 | 2009-08-13 16:34:53 -0400 | [diff] [blame] | 715 | static int ftrace_raw_reg_event_##call(struct ftrace_event_call *unused)\ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 716 | { \ |
| 717 | int ret; \ |
| 718 | \ |
| 719 | ret = register_trace_##call(ftrace_raw_event_##call); \ |
| 720 | if (ret) \ |
| 721 | pr_info("event trace: Could not activate trace point " \ |
Joe Perches | 4819568 | 2009-12-12 13:06:13 -0800 | [diff] [blame] | 722 | "probe to %s\n", #call); \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 723 | return ret; \ |
| 724 | } \ |
| 725 | \ |
Masami Hiramatsu | bd1a5c8 | 2009-08-13 16:34:53 -0400 | [diff] [blame] | 726 | static void ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused)\ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 727 | { \ |
| 728 | unregister_trace_##call(ftrace_raw_event_##call); \ |
| 729 | } \ |
| 730 | \ |
| 731 | static struct trace_event ftrace_event_type_##call = { \ |
| 732 | .trace = ftrace_raw_output_##call, \ |
Li Zefan | 87d9b4e | 2009-12-08 11:14:20 +0800 | [diff] [blame^] | 733 | }; |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 734 | |
| 735 | #undef DEFINE_EVENT_PRINT |
| 736 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 737 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 738 | |
| 739 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 740 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 741 | #undef DECLARE_EVENT_CLASS |
| 742 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 743 | |
| 744 | #undef DEFINE_EVENT |
| 745 | #define DEFINE_EVENT(template, call, proto, args) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 746 | \ |
| 747 | static struct ftrace_event_call __used \ |
| 748 | __attribute__((__aligned__(4))) \ |
| 749 | __attribute__((section("_ftrace_events"))) event_##call = { \ |
| 750 | .name = #call, \ |
| 751 | .system = __stringify(TRACE_SYSTEM), \ |
Steven Rostedt | 6d72373 | 2009-04-10 14:53:50 -0400 | [diff] [blame] | 752 | .event = &ftrace_event_type_##call, \ |
Li Zefan | 87d9b4e | 2009-12-08 11:14:20 +0800 | [diff] [blame^] | 753 | .raw_init = trace_event_raw_init, \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 754 | .regfunc = ftrace_raw_reg_event_##call, \ |
| 755 | .unregfunc = ftrace_raw_unreg_event_##call, \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 756 | .show_format = ftrace_format_##template, \ |
| 757 | .define_fields = ftrace_define_fields_##template, \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 758 | _TRACE_PROFILE_INIT(call) \ |
| 759 | } |
| 760 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 761 | #undef DEFINE_EVENT_PRINT |
| 762 | #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 763 | \ |
| 764 | static struct ftrace_event_call __used \ |
| 765 | __attribute__((__aligned__(4))) \ |
| 766 | __attribute__((section("_ftrace_events"))) event_##call = { \ |
| 767 | .name = #call, \ |
| 768 | .system = __stringify(TRACE_SYSTEM), \ |
| 769 | .event = &ftrace_event_type_##call, \ |
Li Zefan | 87d9b4e | 2009-12-08 11:14:20 +0800 | [diff] [blame^] | 770 | .raw_init = trace_event_raw_init, \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 771 | .regfunc = ftrace_raw_reg_event_##call, \ |
| 772 | .unregfunc = ftrace_raw_unreg_event_##call, \ |
| 773 | .show_format = ftrace_format_##call, \ |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 774 | .define_fields = ftrace_define_fields_##template, \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 775 | _TRACE_PROFILE_INIT(call) \ |
| 776 | } |
| 777 | |
| 778 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 779 | |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 780 | /* |
| 781 | * Define the insertion callback to profile events |
| 782 | * |
| 783 | * The job is very similar to ftrace_raw_event_<call> except that we don't |
| 784 | * insert in the ring buffer but in a perf counter. |
| 785 | * |
| 786 | * static void ftrace_profile_<call>(proto) |
| 787 | * { |
| 788 | * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets; |
| 789 | * struct ftrace_event_call *event_call = &event_<call>; |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 790 | * extern void perf_tp_event(int, u64, u64, void *, int); |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 791 | * struct ftrace_raw_##call *entry; |
Frederic Weisbecker | 444a2a3 | 2009-11-06 04:13:05 +0100 | [diff] [blame] | 792 | * struct perf_trace_buf *trace_buf; |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 793 | * u64 __addr = 0, __count = 1; |
| 794 | * unsigned long irq_flags; |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 795 | * struct trace_entry *ent; |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 796 | * int __entry_size; |
| 797 | * int __data_size; |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 798 | * int __cpu |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 799 | * int pc; |
| 800 | * |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 801 | * pc = preempt_count(); |
| 802 | * |
| 803 | * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args); |
Frederic Weisbecker | 304703a | 2009-08-10 16:11:32 +0200 | [diff] [blame] | 804 | * |
| 805 | * // Below we want to get the aligned size by taking into account |
| 806 | * // the u32 field that will later store the buffer size |
| 807 | * __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32), |
| 808 | * sizeof(u64)); |
| 809 | * __entry_size -= sizeof(u32); |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 810 | * |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 811 | * // Protect the non nmi buffer |
| 812 | * // This also protects the rcu read side |
| 813 | * local_irq_save(irq_flags); |
| 814 | * __cpu = smp_processor_id(); |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 815 | * |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 816 | * if (in_nmi()) |
Frederic Weisbecker | 444a2a3 | 2009-11-06 04:13:05 +0100 | [diff] [blame] | 817 | * trace_buf = rcu_dereference(perf_trace_buf_nmi); |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 818 | * else |
Frederic Weisbecker | 444a2a3 | 2009-11-06 04:13:05 +0100 | [diff] [blame] | 819 | * trace_buf = rcu_dereference(perf_trace_buf); |
Frederic Weisbecker | 1853db0 | 2009-08-10 16:38:36 +0200 | [diff] [blame] | 820 | * |
Frederic Weisbecker | 444a2a3 | 2009-11-06 04:13:05 +0100 | [diff] [blame] | 821 | * if (!trace_buf) |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 822 | * goto end; |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 823 | * |
Frederic Weisbecker | 444a2a3 | 2009-11-06 04:13:05 +0100 | [diff] [blame] | 824 | * trace_buf = per_cpu_ptr(trace_buf, __cpu); |
| 825 | * |
| 826 | * // Avoid recursion from perf that could mess up the buffer |
| 827 | * if (trace_buf->recursion++) |
| 828 | * goto end_recursion; |
| 829 | * |
| 830 | * raw_data = trace_buf->buf; |
| 831 | * |
| 832 | * // Make recursion update visible before entering perf_tp_event |
| 833 | * // so that we protect from perf recursions. |
| 834 | * |
| 835 | * barrier(); |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 836 | * |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 837 | * //zero dead bytes from alignment to avoid stack leak to userspace: |
| 838 | * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; |
| 839 | * entry = (struct ftrace_raw_<call> *)raw_data; |
| 840 | * ent = &entry->ent; |
| 841 | * tracing_generic_entry_update(ent, irq_flags, pc); |
| 842 | * ent->type = event_call->id; |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 843 | * |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 844 | * <tstruct> <- do some jobs with dynamic arrays |
| 845 | * |
| 846 | * <assign> <- affect our values |
| 847 | * |
Linus Torvalds | 43c1266 | 2009-09-21 09:15:07 -0700 | [diff] [blame] | 848 | * perf_tp_event(event_call->id, __addr, __count, entry, |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 849 | * __entry_size); <- submit them to perf counter |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 850 | * |
| 851 | * } |
| 852 | */ |
| 853 | |
| 854 | #ifdef CONFIG_EVENT_PROFILE |
| 855 | |
| 856 | #undef __perf_addr |
| 857 | #define __perf_addr(a) __addr = (a) |
| 858 | |
| 859 | #undef __perf_count |
| 860 | #define __perf_count(c) __count = (c) |
| 861 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 862 | #undef DECLARE_EVENT_CLASS |
| 863 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 864 | static void \ |
| 865 | ftrace_profile_templ_##call(struct ftrace_event_call *event_call, \ |
| 866 | proto) \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 867 | { \ |
| 868 | struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\ |
Peter Zijlstra | 4ed7c92 | 2009-11-23 11:37:29 +0100 | [diff] [blame] | 869 | extern int perf_swevent_get_recursion_context(void); \ |
| 870 | extern void perf_swevent_put_recursion_context(int rctx); \ |
Frederic Weisbecker | 444a2a3 | 2009-11-06 04:13:05 +0100 | [diff] [blame] | 871 | extern void perf_tp_event(int, u64, u64, void *, int); \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 872 | struct ftrace_raw_##call *entry; \ |
| 873 | u64 __addr = 0, __count = 1; \ |
| 874 | unsigned long irq_flags; \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 875 | struct trace_entry *ent; \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 876 | int __entry_size; \ |
| 877 | int __data_size; \ |
Frederic Weisbecker | ce71b9d | 2009-11-22 05:26:55 +0100 | [diff] [blame] | 878 | char *trace_buf; \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 879 | char *raw_data; \ |
| 880 | int __cpu; \ |
Peter Zijlstra | 4ed7c92 | 2009-11-23 11:37:29 +0100 | [diff] [blame] | 881 | int rctx; \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 882 | int pc; \ |
| 883 | \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 884 | pc = preempt_count(); \ |
| 885 | \ |
| 886 | __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \ |
Peter Zijlstra | a044560 | 2009-08-10 11:16:52 +0200 | [diff] [blame] | 887 | __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\ |
| 888 | sizeof(u64)); \ |
Frederic Weisbecker | 304703a | 2009-08-10 16:11:32 +0200 | [diff] [blame] | 889 | __entry_size -= sizeof(u32); \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 890 | \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 891 | if (WARN_ONCE(__entry_size > FTRACE_MAX_PROFILE_SIZE, \ |
| 892 | "profile buffer not large enough")) \ |
| 893 | return; \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 894 | \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 895 | local_irq_save(irq_flags); \ |
Frederic Weisbecker | ce71b9d | 2009-11-22 05:26:55 +0100 | [diff] [blame] | 896 | \ |
Peter Zijlstra | 4ed7c92 | 2009-11-23 11:37:29 +0100 | [diff] [blame] | 897 | rctx = perf_swevent_get_recursion_context(); \ |
| 898 | if (rctx < 0) \ |
| 899 | goto end_recursion; \ |
Frederic Weisbecker | ce71b9d | 2009-11-22 05:26:55 +0100 | [diff] [blame] | 900 | \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 901 | __cpu = smp_processor_id(); \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 902 | \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 903 | if (in_nmi()) \ |
Frederic Weisbecker | 444a2a3 | 2009-11-06 04:13:05 +0100 | [diff] [blame] | 904 | trace_buf = rcu_dereference(perf_trace_buf_nmi); \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 905 | else \ |
Frederic Weisbecker | 444a2a3 | 2009-11-06 04:13:05 +0100 | [diff] [blame] | 906 | trace_buf = rcu_dereference(perf_trace_buf); \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 907 | \ |
Frederic Weisbecker | 444a2a3 | 2009-11-06 04:13:05 +0100 | [diff] [blame] | 908 | if (!trace_buf) \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 909 | goto end; \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 910 | \ |
Frederic Weisbecker | ce71b9d | 2009-11-22 05:26:55 +0100 | [diff] [blame] | 911 | raw_data = per_cpu_ptr(trace_buf, __cpu); \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 912 | \ |
| 913 | *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; \ |
| 914 | entry = (struct ftrace_raw_##call *)raw_data; \ |
| 915 | ent = &entry->ent; \ |
| 916 | tracing_generic_entry_update(ent, irq_flags, pc); \ |
| 917 | ent->type = event_call->id; \ |
| 918 | \ |
| 919 | tstruct \ |
| 920 | \ |
| 921 | { assign; } \ |
| 922 | \ |
Linus Torvalds | 43c1266 | 2009-09-21 09:15:07 -0700 | [diff] [blame] | 923 | perf_tp_event(event_call->id, __addr, __count, entry, \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 924 | __entry_size); \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 925 | \ |
| 926 | end: \ |
Peter Zijlstra | 4ed7c92 | 2009-11-23 11:37:29 +0100 | [diff] [blame] | 927 | perf_swevent_put_recursion_context(rctx); \ |
| 928 | end_recursion: \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 929 | local_irq_restore(irq_flags); \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 930 | } |
| 931 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 932 | #undef DEFINE_EVENT |
| 933 | #define DEFINE_EVENT(template, call, proto, args) \ |
| 934 | static void ftrace_profile_##call(proto) \ |
| 935 | { \ |
| 936 | struct ftrace_event_call *event_call = &event_##call; \ |
| 937 | \ |
| 938 | ftrace_profile_templ_##template(event_call, args); \ |
| 939 | } |
| 940 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 941 | #undef DEFINE_EVENT_PRINT |
| 942 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 943 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 944 | |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 945 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 946 | #endif /* CONFIG_EVENT_PROFILE */ |
| 947 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 948 | #undef _TRACE_PROFILE_INIT |
| 949 | |