+ extern struct tracepoint * const __start___tracepoints_ptrs[] __attribute__((weak, visibility("hidden"))); \
+ extern struct tracepoint * const __stop___tracepoints_ptrs[] __attribute__((weak, visibility("hidden"))); \
+ static struct tracepoint * __tracepoint_ptr_dummy \
+ __attribute__((used, section("__tracepoints_ptrs"))); \
+ static void __attribute__((constructor)) __tracepoints__init(void) \
+ { \
+ tracepoint_register_lib(__start___tracepoints_ptrs, \
+ __stop___tracepoints_ptrs - \
+ __start___tracepoints_ptrs); \
+ } \
+ \
+ static void __attribute__((destructor)) __tracepoints__destroy(void) \
+ { \
+ tracepoint_unregister_lib(__start___tracepoints_ptrs); \
+ }
+
+
+#ifndef TRACEPOINT_EVENT
+/*
+ * For use with the TRACEPOINT_EVENT macro:
+ *
+ * We define a tracepoint, its arguments, its printf format
+ * and its 'fast binary record' layout.
+ *
+ * Firstly, name your tracepoint via TRACEPOINT_EVENT(name : the
+ * 'subsystem_event' notation is fine.
+ *
+ * Think about this whole construct as the
+ * 'trace_sched_switch() function' from now on.
+ *
+ *
+ * TRACEPOINT_EVENT(sched_switch,
+ *
+ * *
+ * * A function has a regular function arguments
+ * * prototype, declare it via TP_PROTO():
+ * *
+ *
+ * TP_PROTO(struct rq *rq, struct task_struct *prev,
+ * struct task_struct *next),
+ *
+ * *
+ * * Define the call signature of the 'function'.
+ * * (Design sidenote: we use this instead of a
+ * * TP_PROTO1/TP_PROTO2/TP_PROTO3 ugliness.)
+ * *
+ *
+ * TP_ARGS(rq, prev, next),
+ *
+ * *
+ * * Fast binary tracing: define the trace record via
+ * * TP_STRUCT__entry(). You can think about it like a
+ * * regular C structure local variable definition.
+ * *
+ * * This is how the trace record is structured and will
+ * * be saved into the ring buffer. These are the fields
+ * * that will be exposed to readers.
+ * *
+ * * The declared 'local variable' is called '__entry'
+ * *
+ * * __field(pid_t, prev_prid) is equivalent to a standard declariton:
+ * *
+ * * pid_t prev_pid;
+ * *
+ * * __array(char, prev_comm, TASK_COMM_LEN) is equivalent to:
+ * *
+ * * char prev_comm[TASK_COMM_LEN];
+ * *
+ *
+ * TP_STRUCT__entry(
+ * __array( char, prev_comm, TASK_COMM_LEN )
+ * __field( pid_t, prev_pid )
+ * __field( int, prev_prio )
+ * __array( char, next_comm, TASK_COMM_LEN )
+ * __field( pid_t, next_pid )
+ * __field( int, next_prio )
+ * ),
+ *
+ * *
+ * * Assign the entry into the trace record, by embedding
+ * * a full C statement block into TP_fast_assign(). You
+ * * can refer to the trace record as '__entry' -
+ * * otherwise you can put arbitrary C code in here.
+ * *
+ * * Note: this C code will execute every time a trace event
+ * * happens, on an active tracepoint.
+ * *
+ *
+ * TP_fast_assign(
+ * memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
+ * __entry->prev_pid = prev->pid;
+ * __entry->prev_prio = prev->prio;
+ * memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
+ * __entry->next_pid = next->pid;
+ * __entry->next_prio = next->prio;
+ * )
+ *
+ * *
+ * * Formatted output of a trace record via TP_printf().
+ * * This is how the tracepoint will appear under debugging
+ * * of tracepoints.
+ * *
+ * * (raw-binary tracing wont actually perform this step.)
+ * *
+ *
+ * TP_printf("task %s:%d [%d] ==> %s:%d [%d]",
+ * __entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
+ * __entry->next_comm, __entry->next_pid, __entry->next_prio),
+ *
+ * );
+ *
+ * This macro construct is thus used for the regular printf format
+ * tracing setup.
+ *
+ * A set of (un)registration functions can be passed to the variant
+ * TRACEPOINT_EVENT_FN to perform any (un)registration work.
+ */
+
+struct trace_event {
+ const char *name;
+ int (*regfunc)(void *data);
+ int (*unregfunc)(void *data);
+};
+
+struct trace_event_lib {
+ struct trace_event * const *trace_events_start;
+ int trace_events_count;
+ struct cds_list_head list;
+};
+
+struct trace_event_iter {
+ struct trace_event_lib *lib;
+ struct trace_event * const *trace_event;
+};
+
+extern void lock_trace_events(void);
+extern void unlock_trace_events(void);
+
+extern void trace_event_iter_start(struct trace_event_iter *iter);
+extern void trace_event_iter_next(struct trace_event_iter *iter);
+extern void trace_event_iter_reset(struct trace_event_iter *iter);
+
+extern int trace_event_get_iter_range(struct trace_event * const **trace_event,
+ struct trace_event * const *begin,
+ struct trace_event * const *end);
+
+extern void trace_event_update_process(void);
+extern int is_trace_event_enabled(const char *channel, const char *name);
+
+extern int trace_event_register_lib(struct trace_event * const *start_trace_events,
+ int trace_event_count);
+
+extern int trace_event_unregister_lib(struct trace_event * const *start_trace_events);
+
+#define TRACEPOINT_EVENT_LIB \
+ extern struct trace_event * const __start___trace_events_ptrs[] \
+ __attribute__((weak, visibility("hidden"))); \
+ extern struct trace_event * const __stop___trace_events_ptrs[] \
+ __attribute__((weak, visibility("hidden"))); \
+ static struct trace_event * __event_ptrs_dummy \
+ __attribute__((used, section("__trace_events_ptrs"))); \
+ static void __attribute__((constructor)) \
+ __trace_events__init(void) \
+ { \
+ trace_event_register_lib(__start___trace_events_ptrs, \
+ __stop___trace_events_ptrs - \
+ __start___trace_events_ptrs); \
+ } \
+ \
+ static void __attribute__((destructor)) \
+ __trace_event__destroy(void) \