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 (Red Hat) | acd388f | 2015-03-31 14:37:12 -0400 | [diff] [blame^] | 21 | #ifndef TRACE_SYSTEM_VAR |
| 22 | #define TRACE_SYSTEM_VAR TRACE_SYSTEM |
| 23 | #endif |
| 24 | |
| 25 | #define __app__(x, y) str__##x##y |
| 26 | #define __app(x, y) __app__(x, y) |
| 27 | |
| 28 | #define TRACE_SYSTEM_STRING __app(TRACE_SYSTEM_VAR,__trace_system_name) |
| 29 | |
| 30 | #define TRACE_MAKE_SYSTEM_STR() \ |
| 31 | static const char TRACE_SYSTEM_STRING[] = \ |
| 32 | __stringify(TRACE_SYSTEM) |
| 33 | |
| 34 | TRACE_MAKE_SYSTEM_STR(); |
| 35 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 36 | /* |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 37 | * DECLARE_EVENT_CLASS can be used to add a generic function |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 38 | * handlers for events. That is, if all events have the same |
| 39 | * parameters and just have distinct trace points. |
| 40 | * Each tracepoint can be defined with DEFINE_EVENT and that |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 41 | * will map the DECLARE_EVENT_CLASS to the tracepoint. |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 42 | * |
| 43 | * TRACE_EVENT is a one to one mapping between tracepoint and template. |
| 44 | */ |
| 45 | #undef TRACE_EVENT |
| 46 | #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 47 | DECLARE_EVENT_CLASS(name, \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 48 | PARAMS(proto), \ |
| 49 | PARAMS(args), \ |
| 50 | PARAMS(tstruct), \ |
| 51 | PARAMS(assign), \ |
| 52 | PARAMS(print)); \ |
| 53 | DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args)); |
| 54 | |
| 55 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 56 | #undef __field |
| 57 | #define __field(type, item) type item; |
| 58 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 59 | #undef __field_ext |
| 60 | #define __field_ext(type, item, filter_type) type item; |
| 61 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 62 | #undef __field_struct |
| 63 | #define __field_struct(type, item) type item; |
| 64 | |
| 65 | #undef __field_struct_ext |
| 66 | #define __field_struct_ext(type, item, filter_type) type item; |
| 67 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 68 | #undef __array |
| 69 | #define __array(type, item, len) type item[len]; |
| 70 | |
| 71 | #undef __dynamic_array |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 72 | #define __dynamic_array(type, item, len) u32 __data_loc_##item; |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 73 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 74 | #undef __string |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 75 | #define __string(item, src) __dynamic_array(char, item, -1) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 76 | |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 77 | #undef __bitmask |
| 78 | #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1) |
| 79 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 80 | #undef TP_STRUCT__entry |
| 81 | #define TP_STRUCT__entry(args...) args |
| 82 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 83 | #undef DECLARE_EVENT_CLASS |
| 84 | #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 85 | struct ftrace_raw_##name { \ |
| 86 | struct trace_entry ent; \ |
| 87 | tstruct \ |
| 88 | char __data[0]; \ |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 89 | }; \ |
| 90 | \ |
| 91 | static struct ftrace_event_class event_class_##name; |
| 92 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 93 | #undef DEFINE_EVENT |
| 94 | #define DEFINE_EVENT(template, name, proto, args) \ |
Steven Rostedt | 49c1774 | 2010-05-25 06:19:35 -0700 | [diff] [blame] | 95 | static struct ftrace_event_call __used \ |
Jeff Mahoney | 86c38a3 | 2010-02-24 13:59:23 -0500 | [diff] [blame] | 96 | __attribute__((__aligned__(4))) event_##name |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 97 | |
Steven Rostedt | f5abaa1 | 2013-06-20 11:44:44 -0400 | [diff] [blame] | 98 | #undef DEFINE_EVENT_FN |
| 99 | #define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg) \ |
| 100 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 101 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 102 | #undef DEFINE_EVENT_PRINT |
| 103 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 104 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 105 | |
Josh Stone | 9741987 | 2009-08-24 14:43:13 -0700 | [diff] [blame] | 106 | /* Callbacks are meaningless to ftrace. */ |
| 107 | #undef TRACE_EVENT_FN |
Frederic Weisbecker | 0dd7b74 | 2009-08-28 00:50:06 +0200 | [diff] [blame] | 108 | #define TRACE_EVENT_FN(name, proto, args, tstruct, \ |
| 109 | assign, print, reg, unreg) \ |
Frederic Weisbecker | 819ce45 | 2010-07-20 18:41:24 +0200 | [diff] [blame] | 110 | TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \ |
| 111 | PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \ |
Josh Stone | 9741987 | 2009-08-24 14:43:13 -0700 | [diff] [blame] | 112 | |
Frederic Weisbecker | 1ed0c59 | 2010-11-18 01:46:57 +0100 | [diff] [blame] | 113 | #undef TRACE_EVENT_FLAGS |
| 114 | #define TRACE_EVENT_FLAGS(name, value) \ |
Frederic Weisbecker | 53cf810b | 2010-11-18 02:11:42 +0100 | [diff] [blame] | 115 | __TRACE_EVENT_FLAGS(name, value) |
Frederic Weisbecker | 1ed0c59 | 2010-11-18 01:46:57 +0100 | [diff] [blame] | 116 | |
Peter Zijlstra | d5b5f39 | 2013-11-14 16:23:04 +0100 | [diff] [blame] | 117 | #undef TRACE_EVENT_PERF_PERM |
| 118 | #define TRACE_EVENT_PERF_PERM(name, expr...) \ |
| 119 | __TRACE_EVENT_PERF_PERM(name, expr) |
| 120 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 121 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 122 | |
| 123 | /* |
| 124 | * Stage 2 of the trace events. |
| 125 | * |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 126 | * Include the following: |
| 127 | * |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 128 | * struct ftrace_data_offsets_<call> { |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 129 | * u32 <item1>; |
| 130 | * u32 <item2>; |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 131 | * [...] |
| 132 | * }; |
| 133 | * |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 134 | * The __dynamic_array() macro will create each u32 <item>, this is |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 135 | * 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] | 136 | * 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] | 137 | */ |
| 138 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 139 | #undef __field |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 140 | #define __field(type, item) |
| 141 | |
| 142 | #undef __field_ext |
| 143 | #define __field_ext(type, item, filter_type) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 144 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 145 | #undef __field_struct |
| 146 | #define __field_struct(type, item) |
| 147 | |
| 148 | #undef __field_struct_ext |
| 149 | #define __field_struct_ext(type, item, filter_type) |
| 150 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 151 | #undef __array |
| 152 | #define __array(type, item, len) |
| 153 | |
| 154 | #undef __dynamic_array |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 155 | #define __dynamic_array(type, item, len) u32 item; |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 156 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 157 | #undef __string |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 158 | #define __string(item, src) __dynamic_array(char, item, -1) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 159 | |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 160 | #undef __bitmask |
| 161 | #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) |
| 162 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 163 | #undef DECLARE_EVENT_CLASS |
| 164 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 165 | struct ftrace_data_offsets_##call { \ |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 166 | tstruct; \ |
| 167 | }; |
| 168 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 169 | #undef DEFINE_EVENT |
| 170 | #define DEFINE_EVENT(template, name, proto, args) |
| 171 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 172 | #undef DEFINE_EVENT_PRINT |
| 173 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 174 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 175 | |
Frederic Weisbecker | 1ed0c59 | 2010-11-18 01:46:57 +0100 | [diff] [blame] | 176 | #undef TRACE_EVENT_FLAGS |
| 177 | #define TRACE_EVENT_FLAGS(event, flag) |
| 178 | |
Peter Zijlstra | d5b5f39 | 2013-11-14 16:23:04 +0100 | [diff] [blame] | 179 | #undef TRACE_EVENT_PERF_PERM |
| 180 | #define TRACE_EVENT_PERF_PERM(event, expr...) |
| 181 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 182 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 183 | |
| 184 | /* |
| 185 | * Stage 3 of the trace events. |
| 186 | * |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 187 | * Override the macros in <trace/trace_events.h> to include the following: |
| 188 | * |
| 189 | * enum print_line_t |
| 190 | * ftrace_raw_output_<call>(struct trace_iterator *iter, int flags) |
| 191 | * { |
| 192 | * struct trace_seq *s = &iter->seq; |
| 193 | * struct ftrace_raw_<call> *field; <-- defined in stage 1 |
| 194 | * struct trace_entry *entry; |
Lai Jiangshan | bc289ae | 2010-06-03 18:26:24 +0800 | [diff] [blame] | 195 | * struct trace_seq *p = &iter->tmp_seq; |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 196 | * int ret; |
| 197 | * |
| 198 | * entry = iter->ent; |
| 199 | * |
Steven Rostedt | 32c0eda | 2010-04-23 10:38:03 -0400 | [diff] [blame] | 200 | * if (entry->type != event_<call>->event.type) { |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 201 | * WARN_ON_ONCE(1); |
| 202 | * return TRACE_TYPE_UNHANDLED; |
| 203 | * } |
| 204 | * |
| 205 | * field = (typeof(field))entry; |
| 206 | * |
Steven Whitehouse | 56d8bd3 | 2009-06-03 14:52:03 +0100 | [diff] [blame] | 207 | * trace_seq_init(p); |
Li Zefan | 50354a8 | 2010-03-24 10:58:24 +0800 | [diff] [blame] | 208 | * ret = trace_seq_printf(s, "%s: ", <call>); |
| 209 | * if (ret) |
| 210 | * ret = trace_seq_printf(s, <TP_printk> "\n"); |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 211 | * if (!ret) |
| 212 | * return TRACE_TYPE_PARTIAL_LINE; |
| 213 | * |
| 214 | * return TRACE_TYPE_HANDLED; |
| 215 | * } |
| 216 | * |
| 217 | * This is the method used to print the raw event to the trace |
| 218 | * output format. Note, this is not needed if the data is read |
| 219 | * in binary. |
| 220 | */ |
| 221 | |
| 222 | #undef __entry |
| 223 | #define __entry field |
| 224 | |
| 225 | #undef TP_printk |
| 226 | #define TP_printk(fmt, args...) fmt "\n", args |
| 227 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 228 | #undef __get_dynamic_array |
| 229 | #define __get_dynamic_array(field) \ |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 230 | ((void *)__entry + (__entry->__data_loc_##field & 0xffff)) |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 231 | |
Steven Rostedt (Red Hat) | beba4bb | 2014-06-04 14:29:33 -0400 | [diff] [blame] | 232 | #undef __get_dynamic_array_len |
| 233 | #define __get_dynamic_array_len(field) \ |
| 234 | ((__entry->__data_loc_##field >> 16) & 0xffff) |
| 235 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 236 | #undef __get_str |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 237 | #define __get_str(field) (char *)__get_dynamic_array(field) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 238 | |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 239 | #undef __get_bitmask |
| 240 | #define __get_bitmask(field) \ |
| 241 | ({ \ |
| 242 | void *__bitmask = __get_dynamic_array(field); \ |
| 243 | unsigned int __bitmask_size; \ |
Steven Rostedt (Red Hat) | beba4bb | 2014-06-04 14:29:33 -0400 | [diff] [blame] | 244 | __bitmask_size = __get_dynamic_array_len(field); \ |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 245 | ftrace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ |
| 246 | }) |
| 247 | |
Steven Rostedt | be74b73a | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 248 | #undef __print_flags |
| 249 | #define __print_flags(flag, delim, flag_array...) \ |
| 250 | ({ \ |
Steven Rostedt | a48f494 | 2009-09-14 11:18:02 -0400 | [diff] [blame] | 251 | static const struct trace_print_flags __flags[] = \ |
Steven Rostedt | be74b73a | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 252 | { flag_array, { -1, NULL }}; \ |
Steven Rostedt | a48f494 | 2009-09-14 11:18:02 -0400 | [diff] [blame] | 253 | ftrace_print_flags_seq(p, delim, flag, __flags); \ |
Steven Rostedt | be74b73a | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 254 | }) |
| 255 | |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 256 | #undef __print_symbolic |
| 257 | #define __print_symbolic(value, symbol_array...) \ |
| 258 | ({ \ |
| 259 | static const struct trace_print_flags symbols[] = \ |
| 260 | { symbol_array, { -1, NULL }}; \ |
| 261 | ftrace_print_symbols_seq(p, value, symbols); \ |
| 262 | }) |
| 263 | |
liubo | 2fc1b6f | 2011-04-19 09:35:28 +0800 | [diff] [blame] | 264 | #undef __print_symbolic_u64 |
| 265 | #if BITS_PER_LONG == 32 |
| 266 | #define __print_symbolic_u64(value, symbol_array...) \ |
| 267 | ({ \ |
| 268 | static const struct trace_print_flags_u64 symbols[] = \ |
| 269 | { symbol_array, { -1, NULL } }; \ |
| 270 | ftrace_print_symbols_seq_u64(p, value, symbols); \ |
| 271 | }) |
| 272 | #else |
| 273 | #define __print_symbolic_u64(value, symbol_array...) \ |
| 274 | __print_symbolic(value, symbol_array) |
| 275 | #endif |
| 276 | |
Kei Tokunaga | 5a2e399 | 2010-04-01 20:40:58 +0900 | [diff] [blame] | 277 | #undef __print_hex |
| 278 | #define __print_hex(buf, buf_len) ftrace_print_hex_seq(p, buf, buf_len) |
| 279 | |
Dave Martin | 6ea2248 | 2015-01-28 12:48:53 +0000 | [diff] [blame] | 280 | #undef __print_array |
| 281 | #define __print_array(array, count, el_size) \ |
| 282 | ({ \ |
| 283 | BUILD_BUG_ON(el_size != 1 && el_size != 2 && \ |
| 284 | el_size != 4 && el_size != 8); \ |
| 285 | ftrace_print_array_seq(p, array, count, el_size); \ |
| 286 | }) |
| 287 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 288 | #undef DECLARE_EVENT_CLASS |
| 289 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt | 83f0d53 | 2010-02-16 10:38:47 -0500 | [diff] [blame] | 290 | static notrace enum print_line_t \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 291 | ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ |
| 292 | struct trace_event *trace_event) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 293 | { \ |
| 294 | struct trace_seq *s = &iter->seq; \ |
Li Zefan | f71130d | 2013-02-21 10:32:38 +0800 | [diff] [blame] | 295 | struct trace_seq __maybe_unused *p = &iter->tmp_seq; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 296 | struct ftrace_raw_##call *field; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 297 | int ret; \ |
| 298 | \ |
Li Zefan | f71130d | 2013-02-21 10:32:38 +0800 | [diff] [blame] | 299 | field = (typeof(field))iter->ent; \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 300 | \ |
Li Zefan | f71130d | 2013-02-21 10:32:38 +0800 | [diff] [blame] | 301 | ret = ftrace_raw_output_prep(iter, trace_event); \ |
Steven Rostedt (Red Hat) | 8e2e095 | 2014-11-14 11:42:06 -0500 | [diff] [blame] | 302 | if (ret != TRACE_TYPE_HANDLED) \ |
Li Zefan | f71130d | 2013-02-21 10:32:38 +0800 | [diff] [blame] | 303 | return ret; \ |
| 304 | \ |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 305 | trace_seq_printf(s, print); \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 306 | \ |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 307 | return trace_handle_return(s); \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 308 | } \ |
| 309 | static struct trace_event_functions ftrace_event_type_funcs_##call = { \ |
| 310 | .trace = ftrace_raw_output_##call, \ |
| 311 | }; |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 312 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 313 | #undef DEFINE_EVENT_PRINT |
| 314 | #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ |
Steven Rostedt | 83f0d53 | 2010-02-16 10:38:47 -0500 | [diff] [blame] | 315 | static notrace enum print_line_t \ |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 316 | ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ |
| 317 | struct trace_event *event) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 318 | { \ |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 319 | struct ftrace_raw_##template *field; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 320 | struct trace_entry *entry; \ |
Lai Jiangshan | bc289ae | 2010-06-03 18:26:24 +0800 | [diff] [blame] | 321 | struct trace_seq *p = &iter->tmp_seq; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 322 | \ |
| 323 | entry = iter->ent; \ |
| 324 | \ |
Steven Rostedt | 32c0eda | 2010-04-23 10:38:03 -0400 | [diff] [blame] | 325 | if (entry->type != event_##call.event.type) { \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 326 | WARN_ON_ONCE(1); \ |
| 327 | return TRACE_TYPE_UNHANDLED; \ |
| 328 | } \ |
| 329 | \ |
| 330 | field = (typeof(field))entry; \ |
| 331 | \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 332 | trace_seq_init(p); \ |
Steven Rostedt | 1d6bae9 | 2012-08-09 19:16:14 -0400 | [diff] [blame] | 333 | return ftrace_output_call(iter, #call, print); \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 334 | } \ |
| 335 | static struct trace_event_functions ftrace_event_type_funcs_##call = { \ |
| 336 | .trace = ftrace_raw_output_##call, \ |
| 337 | }; |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 338 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 339 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 340 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 341 | #undef __field_ext |
| 342 | #define __field_ext(type, item, filter_type) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 343 | ret = trace_define_field(event_call, #type, #item, \ |
| 344 | offsetof(typeof(field), item), \ |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 345 | sizeof(field.item), \ |
| 346 | is_signed_type(type), filter_type); \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 347 | if (ret) \ |
| 348 | return ret; |
| 349 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 350 | #undef __field_struct_ext |
| 351 | #define __field_struct_ext(type, item, filter_type) \ |
| 352 | ret = trace_define_field(event_call, #type, #item, \ |
| 353 | offsetof(typeof(field), item), \ |
| 354 | sizeof(field.item), \ |
| 355 | 0, filter_type); \ |
| 356 | if (ret) \ |
| 357 | return ret; |
| 358 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 359 | #undef __field |
| 360 | #define __field(type, item) __field_ext(type, item, FILTER_OTHER) |
| 361 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 362 | #undef __field_struct |
| 363 | #define __field_struct(type, item) __field_struct_ext(type, item, FILTER_OTHER) |
| 364 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 365 | #undef __array |
| 366 | #define __array(type, item, len) \ |
Steven Rostedt | 0429578 | 2010-11-12 22:32:11 -0500 | [diff] [blame] | 367 | do { \ |
Vaibhav Nagarnaik | 8729134 | 2014-02-13 19:51:48 -0800 | [diff] [blame] | 368 | char *type_str = #type"["__stringify(len)"]"; \ |
Steven Rostedt | 0429578 | 2010-11-12 22:32:11 -0500 | [diff] [blame] | 369 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ |
Vaibhav Nagarnaik | 8729134 | 2014-02-13 19:51:48 -0800 | [diff] [blame] | 370 | ret = trace_define_field(event_call, type_str, #item, \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 371 | offsetof(typeof(field), item), \ |
Lai Jiangshan | fb7ae98 | 2009-12-15 15:39:38 +0800 | [diff] [blame] | 372 | sizeof(field.item), \ |
| 373 | is_signed_type(type), FILTER_OTHER); \ |
Steven Rostedt | 0429578 | 2010-11-12 22:32:11 -0500 | [diff] [blame] | 374 | if (ret) \ |
| 375 | return ret; \ |
| 376 | } while (0); |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 377 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 378 | #undef __dynamic_array |
| 379 | #define __dynamic_array(type, item, len) \ |
Lai Jiangshan | 68fd60a | 2009-07-16 10:53:34 +0800 | [diff] [blame] | 380 | ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \ |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 381 | offsetof(typeof(field), __data_loc_##item), \ |
Lai Jiangshan | fb7ae98 | 2009-12-15 15:39:38 +0800 | [diff] [blame] | 382 | sizeof(field.__data_loc_##item), \ |
| 383 | is_signed_type(type), FILTER_OTHER); |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 384 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 385 | #undef __string |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 386 | #define __string(item, src) __dynamic_array(char, item, -1) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 387 | |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 388 | #undef __bitmask |
| 389 | #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) |
| 390 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 391 | #undef DECLARE_EVENT_CLASS |
| 392 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \ |
Li Zefan | 7e4f44b | 2013-02-21 10:33:33 +0800 | [diff] [blame] | 393 | static int notrace __init \ |
Li Zefan | 14be96c | 2009-08-19 15:53:52 +0800 | [diff] [blame] | 394 | ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 395 | { \ |
| 396 | struct ftrace_raw_##call field; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 397 | int ret; \ |
| 398 | \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 399 | tstruct; \ |
| 400 | \ |
| 401 | return ret; \ |
| 402 | } |
| 403 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 404 | #undef DEFINE_EVENT |
| 405 | #define DEFINE_EVENT(template, name, proto, args) |
| 406 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 407 | #undef DEFINE_EVENT_PRINT |
| 408 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 409 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 410 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 411 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 412 | |
| 413 | /* |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 414 | * remember the offset of each array from the beginning of the event. |
| 415 | */ |
| 416 | |
| 417 | #undef __entry |
| 418 | #define __entry entry |
| 419 | |
| 420 | #undef __field |
| 421 | #define __field(type, item) |
| 422 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 423 | #undef __field_ext |
| 424 | #define __field_ext(type, item, filter_type) |
| 425 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 426 | #undef __field_struct |
| 427 | #define __field_struct(type, item) |
| 428 | |
| 429 | #undef __field_struct_ext |
| 430 | #define __field_struct_ext(type, item, filter_type) |
| 431 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 432 | #undef __array |
| 433 | #define __array(type, item, len) |
| 434 | |
| 435 | #undef __dynamic_array |
| 436 | #define __dynamic_array(type, item, len) \ |
Filipe Brandenburger | 114e7b5 | 2014-02-28 21:32:17 -0800 | [diff] [blame] | 437 | __item_length = (len) * sizeof(type); \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 438 | __data_offsets->item = __data_size + \ |
| 439 | offsetof(typeof(*entry), __data); \ |
Filipe Brandenburger | 114e7b5 | 2014-02-28 21:32:17 -0800 | [diff] [blame] | 440 | __data_offsets->item |= __item_length << 16; \ |
| 441 | __data_size += __item_length; |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 442 | |
| 443 | #undef __string |
Steven Rostedt (Red Hat) | 4e58e54 | 2013-11-26 09:22:54 -0500 | [diff] [blame] | 444 | #define __string(item, src) __dynamic_array(char, item, \ |
| 445 | strlen((src) ? (const char *)(src) : "(null)") + 1) |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 446 | |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 447 | /* |
| 448 | * __bitmask_size_in_bytes_raw is the number of bytes needed to hold |
| 449 | * num_possible_cpus(). |
| 450 | */ |
| 451 | #define __bitmask_size_in_bytes_raw(nr_bits) \ |
| 452 | (((nr_bits) + 7) / 8) |
| 453 | |
| 454 | #define __bitmask_size_in_longs(nr_bits) \ |
| 455 | ((__bitmask_size_in_bytes_raw(nr_bits) + \ |
| 456 | ((BITS_PER_LONG / 8) - 1)) / (BITS_PER_LONG / 8)) |
| 457 | |
| 458 | /* |
| 459 | * __bitmask_size_in_bytes is the number of bytes needed to hold |
| 460 | * num_possible_cpus() padded out to the nearest long. This is what |
| 461 | * is saved in the buffer, just to be consistent. |
| 462 | */ |
| 463 | #define __bitmask_size_in_bytes(nr_bits) \ |
| 464 | (__bitmask_size_in_longs(nr_bits) * (BITS_PER_LONG / 8)) |
| 465 | |
| 466 | #undef __bitmask |
| 467 | #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, \ |
| 468 | __bitmask_size_in_longs(nr_bits)) |
| 469 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 470 | #undef DECLARE_EVENT_CLASS |
| 471 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt | 83f0d53 | 2010-02-16 10:38:47 -0500 | [diff] [blame] | 472 | static inline notrace int ftrace_get_offsets_##call( \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 473 | struct ftrace_data_offsets_##call *__data_offsets, proto) \ |
| 474 | { \ |
| 475 | int __data_size = 0; \ |
Filipe Brandenburger | 114e7b5 | 2014-02-28 21:32:17 -0800 | [diff] [blame] | 476 | int __maybe_unused __item_length; \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 477 | struct ftrace_raw_##call __maybe_unused *entry; \ |
| 478 | \ |
| 479 | tstruct; \ |
| 480 | \ |
| 481 | return __data_size; \ |
| 482 | } |
| 483 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 484 | #undef DEFINE_EVENT |
| 485 | #define DEFINE_EVENT(template, name, proto, args) |
| 486 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 487 | #undef DEFINE_EVENT_PRINT |
| 488 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 489 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 490 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 491 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 492 | |
| 493 | /* |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 494 | * Stage 4 of the trace events. |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 495 | * |
| 496 | * Override the macros in <trace/trace_events.h> to include the following: |
| 497 | * |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 498 | * For those macros defined with TRACE_EVENT: |
| 499 | * |
| 500 | * static struct ftrace_event_call event_<call>; |
| 501 | * |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 502 | * static void ftrace_raw_event_<call>(void *__data, proto) |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 503 | * { |
Steven Rostedt | ccb469a | 2012-08-02 10:32:10 -0400 | [diff] [blame] | 504 | * struct ftrace_event_file *ftrace_file = __data; |
| 505 | * struct ftrace_event_call *event_call = ftrace_file->event_call; |
Li Zefan | 50354a8 | 2010-03-24 10:58:24 +0800 | [diff] [blame] | 506 | * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets; |
Tom Zanussi | bac5fb9 | 2013-10-24 08:59:29 -0500 | [diff] [blame] | 507 | * unsigned long eflags = ftrace_file->flags; |
| 508 | * enum event_trigger_type __tt = ETT_NONE; |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 509 | * struct ring_buffer_event *event; |
| 510 | * struct ftrace_raw_<call> *entry; <-- defined in stage 1 |
Steven Rostedt | e77405a | 2009-09-02 14:17:06 -0400 | [diff] [blame] | 511 | * struct ring_buffer *buffer; |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 512 | * unsigned long irq_flags; |
Li Zefan | 50354a8 | 2010-03-24 10:58:24 +0800 | [diff] [blame] | 513 | * int __data_size; |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 514 | * int pc; |
| 515 | * |
Tom Zanussi | bac5fb9 | 2013-10-24 08:59:29 -0500 | [diff] [blame] | 516 | * if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) { |
| 517 | * if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE) |
| 518 | * event_triggers_call(ftrace_file, NULL); |
| 519 | * if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED) |
| 520 | * return; |
| 521 | * } |
Steven Rostedt (Red Hat) | 417944c | 2013-03-12 13:26:18 -0400 | [diff] [blame] | 522 | * |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 523 | * local_save_flags(irq_flags); |
| 524 | * pc = preempt_count(); |
| 525 | * |
Li Zefan | 50354a8 | 2010-03-24 10:58:24 +0800 | [diff] [blame] | 526 | * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args); |
| 527 | * |
Steven Rostedt | ccb469a | 2012-08-02 10:32:10 -0400 | [diff] [blame] | 528 | * event = trace_event_buffer_lock_reserve(&buffer, ftrace_file, |
Steven Rostedt | 32c0eda | 2010-04-23 10:38:03 -0400 | [diff] [blame] | 529 | * event_<call>->event.type, |
Li Zefan | 50354a8 | 2010-03-24 10:58:24 +0800 | [diff] [blame] | 530 | * sizeof(*entry) + __data_size, |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 531 | * irq_flags, pc); |
| 532 | * if (!event) |
| 533 | * return; |
| 534 | * entry = ring_buffer_event_data(event); |
| 535 | * |
Li Zefan | 50354a8 | 2010-03-24 10:58:24 +0800 | [diff] [blame] | 536 | * { <assign>; } <-- Here we assign the entries by the __field and |
| 537 | * __array macros. |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 538 | * |
Tom Zanussi | bac5fb9 | 2013-10-24 08:59:29 -0500 | [diff] [blame] | 539 | * if (eflags & FTRACE_EVENT_FL_TRIGGER_COND) |
| 540 | * __tt = event_triggers_call(ftrace_file, entry); |
| 541 | * |
| 542 | * if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, |
| 543 | * &ftrace_file->flags)) |
| 544 | * ring_buffer_discard_commit(buffer, event); |
| 545 | * else if (!filter_check_discard(ftrace_file, entry, buffer, event)) |
Tom Zanussi | f306cc8 | 2013-10-24 08:34:17 -0500 | [diff] [blame] | 546 | * trace_buffer_unlock_commit(buffer, event, irq_flags, pc); |
Tom Zanussi | bac5fb9 | 2013-10-24 08:59:29 -0500 | [diff] [blame] | 547 | * |
| 548 | * if (__tt) |
| 549 | * event_triggers_post_call(ftrace_file, __tt); |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 550 | * } |
| 551 | * |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 552 | * static struct trace_event ftrace_event_type_<call> = { |
| 553 | * .trace = ftrace_raw_output_<call>, <-- stage 2 |
| 554 | * }; |
| 555 | * |
Li Zefan | 50354a8 | 2010-03-24 10:58:24 +0800 | [diff] [blame] | 556 | * static const char print_fmt_<call>[] = <TP_printk>; |
| 557 | * |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 558 | * static struct ftrace_event_class __used event_class_<template> = { |
| 559 | * .system = "<system>", |
Steven Rostedt | 2e33af0 | 2010-04-22 10:35:55 -0400 | [diff] [blame] | 560 | * .define_fields = ftrace_define_fields_<call>, |
Steven Rostedt | 0405ab8 | 2010-04-22 11:46:44 -0400 | [diff] [blame] | 561 | * .fields = LIST_HEAD_INIT(event_class_##call.fields), |
| 562 | * .raw_init = trace_event_raw_init, |
| 563 | * .probe = ftrace_raw_event_##call, |
Steven Rostedt | a1d0ce8 | 2010-06-08 11:22:06 -0400 | [diff] [blame] | 564 | * .reg = ftrace_event_reg, |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 565 | * }; |
| 566 | * |
Steven Rostedt | e4a9ea5 | 2011-01-27 09:15:30 -0500 | [diff] [blame] | 567 | * static struct ftrace_event_call event_<call> = { |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 568 | * .class = event_class_<template>, |
Mathieu Desnoyers | abb43f6 | 2014-04-09 17:06:08 -0400 | [diff] [blame] | 569 | * { |
| 570 | * .tp = &__tracepoint_<call>, |
| 571 | * }, |
Steven Rostedt | 2e33af0 | 2010-04-22 10:35:55 -0400 | [diff] [blame] | 572 | * .event = &ftrace_event_type_<call>, |
Li Zefan | 50354a8 | 2010-03-24 10:58:24 +0800 | [diff] [blame] | 573 | * .print_fmt = print_fmt_<call>, |
Mathieu Desnoyers | de7b297 | 2014-04-08 17:26:21 -0400 | [diff] [blame] | 574 | * .flags = TRACE_EVENT_FL_TRACEPOINT, |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 575 | * }; |
Steven Rostedt | e4a9ea5 | 2011-01-27 09:15:30 -0500 | [diff] [blame] | 576 | * // its only safe to use pointers when doing linker tricks to |
| 577 | * // create an array. |
| 578 | * static struct ftrace_event_call __used |
| 579 | * __attribute__((section("_ftrace_events"))) *__event_<call> = &event_<call>; |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 580 | * |
| 581 | */ |
| 582 | |
Li Zefan | 07b139c | 2009-12-21 14:27:35 +0800 | [diff] [blame] | 583 | #ifdef CONFIG_PERF_EVENTS |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 584 | |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 585 | #define _TRACE_PERF_PROTO(call, proto) \ |
| 586 | static notrace void \ |
| 587 | perf_trace_##call(void *__data, proto); |
| 588 | |
Frederic Weisbecker | 97d5a22 | 2010-03-05 05:35:37 +0100 | [diff] [blame] | 589 | #define _TRACE_PERF_INIT(call) \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 590 | .perf_probe = perf_trace_##call, |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 591 | |
| 592 | #else |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 593 | #define _TRACE_PERF_PROTO(call, proto) |
Frederic Weisbecker | 97d5a22 | 2010-03-05 05:35:37 +0100 | [diff] [blame] | 594 | #define _TRACE_PERF_INIT(call) |
Li Zefan | 07b139c | 2009-12-21 14:27:35 +0800 | [diff] [blame] | 595 | #endif /* CONFIG_PERF_EVENTS */ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 596 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 597 | #undef __entry |
| 598 | #define __entry entry |
| 599 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 600 | #undef __field |
| 601 | #define __field(type, item) |
| 602 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 603 | #undef __field_struct |
| 604 | #define __field_struct(type, item) |
| 605 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 606 | #undef __array |
| 607 | #define __array(type, item, len) |
| 608 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 609 | #undef __dynamic_array |
| 610 | #define __dynamic_array(type, item, len) \ |
| 611 | __entry->__data_loc_##item = __data_offsets.item; |
| 612 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 613 | #undef __string |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 614 | #define __string(item, src) __dynamic_array(char, item, -1) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 615 | |
| 616 | #undef __assign_str |
| 617 | #define __assign_str(dst, src) \ |
Steven Rostedt (Red Hat) | 4e58e54 | 2013-11-26 09:22:54 -0500 | [diff] [blame] | 618 | strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)"); |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 619 | |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 620 | #undef __bitmask |
| 621 | #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) |
| 622 | |
| 623 | #undef __get_bitmask |
| 624 | #define __get_bitmask(field) (char *)__get_dynamic_array(field) |
| 625 | |
| 626 | #undef __assign_bitmask |
| 627 | #define __assign_bitmask(dst, src, nr_bits) \ |
| 628 | memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) |
| 629 | |
Lai Jiangshan | 0fa0eda | 2009-12-15 15:39:57 +0800 | [diff] [blame] | 630 | #undef TP_fast_assign |
| 631 | #define TP_fast_assign(args...) args |
| 632 | |
Oleg Nesterov | 1247396 | 2013-08-06 18:08:44 +0200 | [diff] [blame] | 633 | #undef __perf_addr |
| 634 | #define __perf_addr(a) (a) |
| 635 | |
| 636 | #undef __perf_count |
| 637 | #define __perf_count(c) (c) |
| 638 | |
| 639 | #undef __perf_task |
| 640 | #define __perf_task(t) (t) |
Lai Jiangshan | 0fa0eda | 2009-12-15 15:39:57 +0800 | [diff] [blame] | 641 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 642 | #undef DECLARE_EVENT_CLASS |
| 643 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 644 | \ |
Steven Rostedt | 83f0d53 | 2010-02-16 10:38:47 -0500 | [diff] [blame] | 645 | static notrace void \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 646 | ftrace_raw_event_##call(void *__data, proto) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 647 | { \ |
Steven Rostedt | ae63b31e | 2012-05-03 23:09:03 -0400 | [diff] [blame] | 648 | struct ftrace_event_file *ftrace_file = __data; \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 649 | struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\ |
Steven Rostedt | 3fd40d1 | 2012-08-09 22:42:57 -0400 | [diff] [blame] | 650 | struct ftrace_event_buffer fbuffer; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 651 | struct ftrace_raw_##call *entry; \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 652 | int __data_size; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 653 | \ |
Steven Rostedt (Red Hat) | 13a1e4a | 2014-01-06 21:32:10 -0500 | [diff] [blame] | 654 | if (ftrace_trigger_soft_disabled(ftrace_file)) \ |
| 655 | return; \ |
Steven Rostedt (Red Hat) | 417944c | 2013-03-12 13:26:18 -0400 | [diff] [blame] | 656 | \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 657 | __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \ |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 658 | \ |
Steven Rostedt | 3fd40d1 | 2012-08-09 22:42:57 -0400 | [diff] [blame] | 659 | entry = ftrace_event_buffer_reserve(&fbuffer, ftrace_file, \ |
| 660 | sizeof(*entry) + __data_size); \ |
| 661 | \ |
| 662 | if (!entry) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 663 | return; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 664 | \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 665 | tstruct \ |
| 666 | \ |
Li Zefan | a9c1c3a | 2009-06-01 15:35:13 +0800 | [diff] [blame] | 667 | { assign; } \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 668 | \ |
Steven Rostedt | 3fd40d1 | 2012-08-09 22:42:57 -0400 | [diff] [blame] | 669 | ftrace_event_buffer_commit(&fbuffer); \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 670 | } |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 671 | /* |
| 672 | * The ftrace_test_probe is compiled out, it is only here as a build time check |
| 673 | * to make sure that if the tracepoint handling changes, the ftrace probe will |
| 674 | * fail to compile unless it too is updated. |
| 675 | */ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 676 | |
| 677 | #undef DEFINE_EVENT |
| 678 | #define DEFINE_EVENT(template, call, proto, args) \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 679 | static inline void ftrace_test_probe_##call(void) \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 680 | { \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 681 | check_trace_callback_type_##call(ftrace_raw_event_##template); \ |
| 682 | } |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 683 | |
| 684 | #undef DEFINE_EVENT_PRINT |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 685 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 686 | |
| 687 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 688 | |
Lai Jiangshan | 509e760 | 2009-12-15 15:39:42 +0800 | [diff] [blame] | 689 | #undef __entry |
| 690 | #define __entry REC |
| 691 | |
| 692 | #undef __print_flags |
| 693 | #undef __print_symbolic |
Namhyung Kim | b102f1d | 2012-06-27 09:41:39 +0900 | [diff] [blame] | 694 | #undef __print_hex |
Lai Jiangshan | 509e760 | 2009-12-15 15:39:42 +0800 | [diff] [blame] | 695 | #undef __get_dynamic_array |
Steven Rostedt (Red Hat) | beba4bb | 2014-06-04 14:29:33 -0400 | [diff] [blame] | 696 | #undef __get_dynamic_array_len |
Lai Jiangshan | 509e760 | 2009-12-15 15:39:42 +0800 | [diff] [blame] | 697 | #undef __get_str |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 698 | #undef __get_bitmask |
Dave Martin | 6ea2248 | 2015-01-28 12:48:53 +0000 | [diff] [blame] | 699 | #undef __print_array |
Lai Jiangshan | 509e760 | 2009-12-15 15:39:42 +0800 | [diff] [blame] | 700 | |
| 701 | #undef TP_printk |
| 702 | #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args) |
| 703 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 704 | #undef DECLARE_EVENT_CLASS |
Lai Jiangshan | 509e760 | 2009-12-15 15:39:42 +0800 | [diff] [blame] | 705 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 706 | _TRACE_PERF_PROTO(call, PARAMS(proto)); \ |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 707 | static const char print_fmt_##call[] = print; \ |
Li Zefan | 523c811 | 2013-03-04 14:15:59 +0800 | [diff] [blame] | 708 | static struct ftrace_event_class __used __refdata event_class_##call = { \ |
Steven Rostedt (Red Hat) | acd388f | 2015-03-31 14:37:12 -0400 | [diff] [blame^] | 709 | .system = TRACE_SYSTEM_STRING, \ |
Steven Rostedt | 2e33af0 | 2010-04-22 10:35:55 -0400 | [diff] [blame] | 710 | .define_fields = ftrace_define_fields_##call, \ |
| 711 | .fields = LIST_HEAD_INIT(event_class_##call.fields),\ |
Steven Rostedt | 0405ab8 | 2010-04-22 11:46:44 -0400 | [diff] [blame] | 712 | .raw_init = trace_event_raw_init, \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 713 | .probe = ftrace_raw_event_##call, \ |
Steven Rostedt | a1d0ce8 | 2010-06-08 11:22:06 -0400 | [diff] [blame] | 714 | .reg = ftrace_event_reg, \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 715 | _TRACE_PERF_INIT(call) \ |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 716 | }; |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 717 | |
| 718 | #undef DEFINE_EVENT |
| 719 | #define DEFINE_EVENT(template, call, proto, args) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 720 | \ |
Steven Rostedt | e4a9ea5 | 2011-01-27 09:15:30 -0500 | [diff] [blame] | 721 | static struct ftrace_event_call __used event_##call = { \ |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 722 | .class = &event_class_##template, \ |
Mathieu Desnoyers | abb43f6 | 2014-04-09 17:06:08 -0400 | [diff] [blame] | 723 | { \ |
| 724 | .tp = &__tracepoint_##call, \ |
| 725 | }, \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 726 | .event.funcs = &ftrace_event_type_funcs_##template, \ |
Lai Jiangshan | 509e760 | 2009-12-15 15:39:42 +0800 | [diff] [blame] | 727 | .print_fmt = print_fmt_##template, \ |
Mathieu Desnoyers | de7b297 | 2014-04-08 17:26:21 -0400 | [diff] [blame] | 728 | .flags = TRACE_EVENT_FL_TRACEPOINT, \ |
Steven Rostedt | e4a9ea5 | 2011-01-27 09:15:30 -0500 | [diff] [blame] | 729 | }; \ |
| 730 | static struct ftrace_event_call __used \ |
| 731 | __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 732 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 733 | #undef DEFINE_EVENT_PRINT |
| 734 | #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 735 | \ |
Lai Jiangshan | 509e760 | 2009-12-15 15:39:42 +0800 | [diff] [blame] | 736 | static const char print_fmt_##call[] = print; \ |
| 737 | \ |
Steven Rostedt | e4a9ea5 | 2011-01-27 09:15:30 -0500 | [diff] [blame] | 738 | static struct ftrace_event_call __used event_##call = { \ |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 739 | .class = &event_class_##template, \ |
Mathieu Desnoyers | abb43f6 | 2014-04-09 17:06:08 -0400 | [diff] [blame] | 740 | { \ |
| 741 | .tp = &__tracepoint_##call, \ |
| 742 | }, \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 743 | .event.funcs = &ftrace_event_type_funcs_##call, \ |
Lai Jiangshan | 509e760 | 2009-12-15 15:39:42 +0800 | [diff] [blame] | 744 | .print_fmt = print_fmt_##call, \ |
Mathieu Desnoyers | de7b297 | 2014-04-08 17:26:21 -0400 | [diff] [blame] | 745 | .flags = TRACE_EVENT_FL_TRACEPOINT, \ |
Steven Rostedt | e4a9ea5 | 2011-01-27 09:15:30 -0500 | [diff] [blame] | 746 | }; \ |
| 747 | static struct ftrace_event_call __used \ |
| 748 | __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 749 | |
| 750 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 751 | |
Steven Rostedt (Red Hat) | acd388f | 2015-03-31 14:37:12 -0400 | [diff] [blame^] | 752 | #undef TRACE_SYSTEM_VAR |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 753 | |
Li Zefan | 07b139c | 2009-12-21 14:27:35 +0800 | [diff] [blame] | 754 | #ifdef CONFIG_PERF_EVENTS |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 755 | |
Lai Jiangshan | 509e760 | 2009-12-15 15:39:42 +0800 | [diff] [blame] | 756 | #undef __entry |
| 757 | #define __entry entry |
| 758 | |
| 759 | #undef __get_dynamic_array |
| 760 | #define __get_dynamic_array(field) \ |
| 761 | ((void *)__entry + (__entry->__data_loc_##field & 0xffff)) |
| 762 | |
Steven Rostedt (Red Hat) | beba4bb | 2014-06-04 14:29:33 -0400 | [diff] [blame] | 763 | #undef __get_dynamic_array_len |
| 764 | #define __get_dynamic_array_len(field) \ |
| 765 | ((__entry->__data_loc_##field >> 16) & 0xffff) |
| 766 | |
Lai Jiangshan | 509e760 | 2009-12-15 15:39:42 +0800 | [diff] [blame] | 767 | #undef __get_str |
| 768 | #define __get_str(field) (char *)__get_dynamic_array(field) |
| 769 | |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 770 | #undef __get_bitmask |
| 771 | #define __get_bitmask(field) (char *)__get_dynamic_array(field) |
| 772 | |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 773 | #undef __perf_addr |
Oleg Nesterov | 1247396 | 2013-08-06 18:08:44 +0200 | [diff] [blame] | 774 | #define __perf_addr(a) (__addr = (a)) |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 775 | |
| 776 | #undef __perf_count |
Oleg Nesterov | 1247396 | 2013-08-06 18:08:44 +0200 | [diff] [blame] | 777 | #define __perf_count(c) (__count = (c)) |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 778 | |
Andrew Vagin | e6dab5f | 2012-07-11 18:14:58 +0400 | [diff] [blame] | 779 | #undef __perf_task |
Oleg Nesterov | 1247396 | 2013-08-06 18:08:44 +0200 | [diff] [blame] | 780 | #define __perf_task(t) (__task = (t)) |
Andrew Vagin | 92e5193 | 2011-09-26 19:55:32 +0400 | [diff] [blame] | 781 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 782 | #undef DECLARE_EVENT_CLASS |
| 783 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt | 83f0d53 | 2010-02-16 10:38:47 -0500 | [diff] [blame] | 784 | static notrace void \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 785 | perf_trace_##call(void *__data, proto) \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 786 | { \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 787 | struct ftrace_event_call *event_call = __data; \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 788 | struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 789 | struct ftrace_raw_##call *entry; \ |
Peter Zijlstra (Intel) | 86038c5 | 2014-12-16 12:47:34 +0100 | [diff] [blame] | 790 | struct pt_regs *__regs; \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 791 | u64 __addr = 0, __count = 1; \ |
Andrew Vagin | e6dab5f | 2012-07-11 18:14:58 +0400 | [diff] [blame] | 792 | struct task_struct *__task = NULL; \ |
Peter Zijlstra | 1c024eca | 2010-05-19 14:02:22 +0200 | [diff] [blame] | 793 | struct hlist_head *head; \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 794 | int __entry_size; \ |
| 795 | int __data_size; \ |
Peter Zijlstra | 4ed7c92 | 2009-11-23 11:37:29 +0100 | [diff] [blame] | 796 | int rctx; \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 797 | \ |
| 798 | __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \ |
Oleg Nesterov | d027e6a | 2013-08-06 18:08:47 +0200 | [diff] [blame] | 799 | \ |
| 800 | head = this_cpu_ptr(event_call->perf_events); \ |
| 801 | if (__builtin_constant_p(!__task) && !__task && \ |
| 802 | hlist_empty(head)) \ |
| 803 | return; \ |
| 804 | \ |
Peter Zijlstra | a044560 | 2009-08-10 11:16:52 +0200 | [diff] [blame] | 805 | __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\ |
| 806 | sizeof(u64)); \ |
Frederic Weisbecker | 304703a | 2009-08-10 16:11:32 +0200 | [diff] [blame] | 807 | __entry_size -= sizeof(u32); \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 808 | \ |
Oleg Nesterov | 36009d07 | 2013-08-06 18:08:41 +0200 | [diff] [blame] | 809 | entry = perf_trace_buf_prepare(__entry_size, \ |
| 810 | event_call->event.type, &__regs, &rctx); \ |
Xiao Guangrong | 430ad5a | 2010-01-28 09:32:29 +0800 | [diff] [blame] | 811 | if (!entry) \ |
| 812 | return; \ |
Peter Zijlstra | b7e2ece | 2010-05-19 10:52:27 +0200 | [diff] [blame] | 813 | \ |
Peter Zijlstra (Intel) | 86038c5 | 2014-12-16 12:47:34 +0100 | [diff] [blame] | 814 | perf_fetch_caller_regs(__regs); \ |
| 815 | \ |
Frederic Weisbecker | 20ab4425 | 2009-09-18 06:10:28 +0200 | [diff] [blame] | 816 | tstruct \ |
| 817 | \ |
| 818 | { assign; } \ |
| 819 | \ |
Frederic Weisbecker | 97d5a22 | 2010-03-05 05:35:37 +0100 | [diff] [blame] | 820 | perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \ |
Peter Zijlstra (Intel) | 86038c5 | 2014-12-16 12:47:34 +0100 | [diff] [blame] | 821 | __count, __regs, head, __task); \ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 822 | } |
| 823 | |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 824 | /* |
| 825 | * This part is compiled out, it is only here as a build time check |
| 826 | * to make sure that if the tracepoint handling changes, the |
| 827 | * perf probe will fail to compile unless it too is updated. |
| 828 | */ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 829 | #undef DEFINE_EVENT |
Frederic Weisbecker | 6cc8a7c | 2010-03-19 01:23:53 +0100 | [diff] [blame] | 830 | #define DEFINE_EVENT(template, call, proto, args) \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 831 | static inline void perf_test_probe_##call(void) \ |
Frederic Weisbecker | 6cc8a7c | 2010-03-19 01:23:53 +0100 | [diff] [blame] | 832 | { \ |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 833 | check_trace_callback_type_##call(perf_trace_##template); \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 834 | } |
| 835 | |
Steven Rostedt | 2239291 | 2010-04-21 12:27:06 -0400 | [diff] [blame] | 836 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 837 | #undef DEFINE_EVENT_PRINT |
| 838 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 839 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 840 | |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 841 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
Li Zefan | 07b139c | 2009-12-21 14:27:35 +0800 | [diff] [blame] | 842 | #endif /* CONFIG_PERF_EVENTS */ |
Frederic Weisbecker | f413cdb | 2009-08-07 01:25:54 +0200 | [diff] [blame] | 843 | |