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