diff options
Diffstat (limited to 'include/trace/trace_events.h')
-rw-r--r-- | include/trace/trace_events.h | 258 |
1 files changed, 258 insertions, 0 deletions
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h index 43be3b0e44d3..de996cf61053 100644 --- a/include/trace/trace_events.h +++ b/include/trace/trace_events.h | |||
@@ -506,3 +506,261 @@ static inline notrace int trace_event_get_offsets_##call( \ | |||
506 | 506 | ||
507 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | 507 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
508 | 508 | ||
509 | /* | ||
510 | * Stage 4 of the trace events. | ||
511 | * | ||
512 | * Override the macros in <trace/trace_events.h> to include the following: | ||
513 | * | ||
514 | * For those macros defined with TRACE_EVENT: | ||
515 | * | ||
516 | * static struct trace_event_call event_<call>; | ||
517 | * | ||
518 | * static void trace_event_raw_event_<call>(void *__data, proto) | ||
519 | * { | ||
520 | * struct trace_event_file *trace_file = __data; | ||
521 | * struct trace_event_call *event_call = trace_file->event_call; | ||
522 | * struct trace_event_data_offsets_<call> __maybe_unused __data_offsets; | ||
523 | * unsigned long eflags = trace_file->flags; | ||
524 | * enum event_trigger_type __tt = ETT_NONE; | ||
525 | * struct ring_buffer_event *event; | ||
526 | * struct trace_event_raw_<call> *entry; <-- defined in stage 1 | ||
527 | * struct ring_buffer *buffer; | ||
528 | * unsigned long irq_flags; | ||
529 | * int __data_size; | ||
530 | * int pc; | ||
531 | * | ||
532 | * if (!(eflags & EVENT_FILE_FL_TRIGGER_COND)) { | ||
533 | * if (eflags & EVENT_FILE_FL_TRIGGER_MODE) | ||
534 | * event_triggers_call(trace_file, NULL); | ||
535 | * if (eflags & EVENT_FILE_FL_SOFT_DISABLED) | ||
536 | * return; | ||
537 | * } | ||
538 | * | ||
539 | * local_save_flags(irq_flags); | ||
540 | * pc = preempt_count(); | ||
541 | * | ||
542 | * __data_size = trace_event_get_offsets_<call>(&__data_offsets, args); | ||
543 | * | ||
544 | * event = trace_event_buffer_lock_reserve(&buffer, trace_file, | ||
545 | * event_<call>->event.type, | ||
546 | * sizeof(*entry) + __data_size, | ||
547 | * irq_flags, pc); | ||
548 | * if (!event) | ||
549 | * return; | ||
550 | * entry = ring_buffer_event_data(event); | ||
551 | * | ||
552 | * { <assign>; } <-- Here we assign the entries by the __field and | ||
553 | * __array macros. | ||
554 | * | ||
555 | * if (eflags & EVENT_FILE_FL_TRIGGER_COND) | ||
556 | * __tt = event_triggers_call(trace_file, entry); | ||
557 | * | ||
558 | * if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, | ||
559 | * &trace_file->flags)) | ||
560 | * ring_buffer_discard_commit(buffer, event); | ||
561 | * else if (!filter_check_discard(trace_file, entry, buffer, event)) | ||
562 | * trace_buffer_unlock_commit(buffer, event, irq_flags, pc); | ||
563 | * | ||
564 | * if (__tt) | ||
565 | * event_triggers_post_call(trace_file, __tt); | ||
566 | * } | ||
567 | * | ||
568 | * static struct trace_event ftrace_event_type_<call> = { | ||
569 | * .trace = trace_raw_output_<call>, <-- stage 2 | ||
570 | * }; | ||
571 | * | ||
572 | * static char print_fmt_<call>[] = <TP_printk>; | ||
573 | * | ||
574 | * static struct trace_event_class __used event_class_<template> = { | ||
575 | * .system = "<system>", | ||
576 | * .define_fields = trace_event_define_fields_<call>, | ||
577 | * .fields = LIST_HEAD_INIT(event_class_##call.fields), | ||
578 | * .raw_init = trace_event_raw_init, | ||
579 | * .probe = trace_event_raw_event_##call, | ||
580 | * .reg = trace_event_reg, | ||
581 | * }; | ||
582 | * | ||
583 | * static struct trace_event_call event_<call> = { | ||
584 | * .class = event_class_<template>, | ||
585 | * { | ||
586 | * .tp = &__tracepoint_<call>, | ||
587 | * }, | ||
588 | * .event = &ftrace_event_type_<call>, | ||
589 | * .print_fmt = print_fmt_<call>, | ||
590 | * .flags = TRACE_EVENT_FL_TRACEPOINT, | ||
591 | * }; | ||
592 | * // its only safe to use pointers when doing linker tricks to | ||
593 | * // create an array. | ||
594 | * static struct trace_event_call __used | ||
595 | * __attribute__((section("_ftrace_events"))) *__event_<call> = &event_<call>; | ||
596 | * | ||
597 | */ | ||
598 | |||
599 | #ifdef CONFIG_PERF_EVENTS | ||
600 | |||
601 | #define _TRACE_PERF_PROTO(call, proto) \ | ||
602 | static notrace void \ | ||
603 | perf_trace_##call(void *__data, proto); | ||
604 | |||
605 | #define _TRACE_PERF_INIT(call) \ | ||
606 | .perf_probe = perf_trace_##call, | ||
607 | |||
608 | #else | ||
609 | #define _TRACE_PERF_PROTO(call, proto) | ||
610 | #define _TRACE_PERF_INIT(call) | ||
611 | #endif /* CONFIG_PERF_EVENTS */ | ||
612 | |||
613 | #undef __entry | ||
614 | #define __entry entry | ||
615 | |||
616 | #undef __field | ||
617 | #define __field(type, item) | ||
618 | |||
619 | #undef __field_struct | ||
620 | #define __field_struct(type, item) | ||
621 | |||
622 | #undef __array | ||
623 | #define __array(type, item, len) | ||
624 | |||
625 | #undef __dynamic_array | ||
626 | #define __dynamic_array(type, item, len) \ | ||
627 | __entry->__data_loc_##item = __data_offsets.item; | ||
628 | |||
629 | #undef __string | ||
630 | #define __string(item, src) __dynamic_array(char, item, -1) | ||
631 | |||
632 | #undef __assign_str | ||
633 | #define __assign_str(dst, src) \ | ||
634 | strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)"); | ||
635 | |||
636 | #undef __bitmask | ||
637 | #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) | ||
638 | |||
639 | #undef __get_bitmask | ||
640 | #define __get_bitmask(field) (char *)__get_dynamic_array(field) | ||
641 | |||
642 | #undef __assign_bitmask | ||
643 | #define __assign_bitmask(dst, src, nr_bits) \ | ||
644 | memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) | ||
645 | |||
646 | #undef TP_fast_assign | ||
647 | #define TP_fast_assign(args...) args | ||
648 | |||
649 | #undef __perf_addr | ||
650 | #define __perf_addr(a) (a) | ||
651 | |||
652 | #undef __perf_count | ||
653 | #define __perf_count(c) (c) | ||
654 | |||
655 | #undef __perf_task | ||
656 | #define __perf_task(t) (t) | ||
657 | |||
658 | #undef DECLARE_EVENT_CLASS | ||
659 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ | ||
660 | \ | ||
661 | static notrace void \ | ||
662 | trace_event_raw_event_##call(void *__data, proto) \ | ||
663 | { \ | ||
664 | struct trace_event_file *trace_file = __data; \ | ||
665 | struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\ | ||
666 | struct trace_event_buffer fbuffer; \ | ||
667 | struct trace_event_raw_##call *entry; \ | ||
668 | int __data_size; \ | ||
669 | \ | ||
670 | if (trace_trigger_soft_disabled(trace_file)) \ | ||
671 | return; \ | ||
672 | \ | ||
673 | __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \ | ||
674 | \ | ||
675 | entry = trace_event_buffer_reserve(&fbuffer, trace_file, \ | ||
676 | sizeof(*entry) + __data_size); \ | ||
677 | \ | ||
678 | if (!entry) \ | ||
679 | return; \ | ||
680 | \ | ||
681 | tstruct \ | ||
682 | \ | ||
683 | { assign; } \ | ||
684 | \ | ||
685 | trace_event_buffer_commit(&fbuffer); \ | ||
686 | } | ||
687 | /* | ||
688 | * The ftrace_test_probe is compiled out, it is only here as a build time check | ||
689 | * to make sure that if the tracepoint handling changes, the ftrace probe will | ||
690 | * fail to compile unless it too is updated. | ||
691 | */ | ||
692 | |||
693 | #undef DEFINE_EVENT | ||
694 | #define DEFINE_EVENT(template, call, proto, args) \ | ||
695 | static inline void ftrace_test_probe_##call(void) \ | ||
696 | { \ | ||
697 | check_trace_callback_type_##call(trace_event_raw_event_##template); \ | ||
698 | } | ||
699 | |||
700 | #undef DEFINE_EVENT_PRINT | ||
701 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) | ||
702 | |||
703 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | ||
704 | |||
705 | #undef __entry | ||
706 | #define __entry REC | ||
707 | |||
708 | #undef __print_flags | ||
709 | #undef __print_symbolic | ||
710 | #undef __print_hex | ||
711 | #undef __get_dynamic_array | ||
712 | #undef __get_dynamic_array_len | ||
713 | #undef __get_str | ||
714 | #undef __get_bitmask | ||
715 | #undef __print_array | ||
716 | |||
717 | #undef TP_printk | ||
718 | #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args) | ||
719 | |||
720 | #undef DECLARE_EVENT_CLASS | ||
721 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ | ||
722 | _TRACE_PERF_PROTO(call, PARAMS(proto)); \ | ||
723 | static char print_fmt_##call[] = print; \ | ||
724 | static struct trace_event_class __used __refdata event_class_##call = { \ | ||
725 | .system = TRACE_SYSTEM_STRING, \ | ||
726 | .define_fields = trace_event_define_fields_##call, \ | ||
727 | .fields = LIST_HEAD_INIT(event_class_##call.fields),\ | ||
728 | .raw_init = trace_event_raw_init, \ | ||
729 | .probe = trace_event_raw_event_##call, \ | ||
730 | .reg = trace_event_reg, \ | ||
731 | _TRACE_PERF_INIT(call) \ | ||
732 | }; | ||
733 | |||
734 | #undef DEFINE_EVENT | ||
735 | #define DEFINE_EVENT(template, call, proto, args) \ | ||
736 | \ | ||
737 | static struct trace_event_call __used event_##call = { \ | ||
738 | .class = &event_class_##template, \ | ||
739 | { \ | ||
740 | .tp = &__tracepoint_##call, \ | ||
741 | }, \ | ||
742 | .event.funcs = &trace_event_type_funcs_##template, \ | ||
743 | .print_fmt = print_fmt_##template, \ | ||
744 | .flags = TRACE_EVENT_FL_TRACEPOINT, \ | ||
745 | }; \ | ||
746 | static struct trace_event_call __used \ | ||
747 | __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call | ||
748 | |||
749 | #undef DEFINE_EVENT_PRINT | ||
750 | #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ | ||
751 | \ | ||
752 | static char print_fmt_##call[] = print; \ | ||
753 | \ | ||
754 | static struct trace_event_call __used event_##call = { \ | ||
755 | .class = &event_class_##template, \ | ||
756 | { \ | ||
757 | .tp = &__tracepoint_##call, \ | ||
758 | }, \ | ||
759 | .event.funcs = &trace_event_type_funcs_##call, \ | ||
760 | .print_fmt = print_fmt_##call, \ | ||
761 | .flags = TRACE_EVENT_FL_TRACEPOINT, \ | ||
762 | }; \ | ||
763 | static struct trace_event_call __used \ | ||
764 | __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call | ||
765 | |||
766 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | ||