diff options
Diffstat (limited to 'include/linux/ftrace_event.h')
| -rw-r--r-- | include/linux/ftrace_event.h | 131 |
1 files changed, 101 insertions, 30 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index 2233c98d80df..02b8b24f8f51 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h | |||
| @@ -5,13 +5,12 @@ | |||
| 5 | #include <linux/trace_seq.h> | 5 | #include <linux/trace_seq.h> |
| 6 | #include <linux/percpu.h> | 6 | #include <linux/percpu.h> |
| 7 | #include <linux/hardirq.h> | 7 | #include <linux/hardirq.h> |
| 8 | #include <linux/perf_event.h> | ||
| 8 | 9 | ||
| 9 | struct trace_array; | 10 | struct trace_array; |
| 10 | struct tracer; | 11 | struct tracer; |
| 11 | struct dentry; | 12 | struct dentry; |
| 12 | 13 | ||
| 13 | DECLARE_PER_CPU(struct trace_seq, ftrace_event_seq); | ||
| 14 | |||
| 15 | struct trace_print_flags { | 14 | struct trace_print_flags { |
| 16 | unsigned long mask; | 15 | unsigned long mask; |
| 17 | const char *name; | 16 | const char *name; |
| @@ -24,6 +23,9 @@ const char *ftrace_print_flags_seq(struct trace_seq *p, const char *delim, | |||
| 24 | const char *ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val, | 23 | const char *ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val, |
| 25 | const struct trace_print_flags *symbol_array); | 24 | const struct trace_print_flags *symbol_array); |
| 26 | 25 | ||
| 26 | const char *ftrace_print_hex_seq(struct trace_seq *p, | ||
| 27 | const unsigned char *buf, int len); | ||
| 28 | |||
| 27 | /* | 29 | /* |
| 28 | * The trace entry - the most basic unit of tracing. This is what | 30 | * The trace entry - the most basic unit of tracing. This is what |
| 29 | * is printed in the end as a single line in the trace output, such as: | 31 | * is printed in the end as a single line in the trace output, such as: |
| @@ -54,9 +56,13 @@ struct trace_iterator { | |||
| 54 | struct ring_buffer_iter *buffer_iter[NR_CPUS]; | 56 | struct ring_buffer_iter *buffer_iter[NR_CPUS]; |
| 55 | unsigned long iter_flags; | 57 | unsigned long iter_flags; |
| 56 | 58 | ||
| 59 | /* trace_seq for __print_flags() and __print_symbolic() etc. */ | ||
| 60 | struct trace_seq tmp_seq; | ||
| 61 | |||
| 57 | /* The below is zeroed out in pipe_read */ | 62 | /* The below is zeroed out in pipe_read */ |
| 58 | struct trace_seq seq; | 63 | struct trace_seq seq; |
| 59 | struct trace_entry *ent; | 64 | struct trace_entry *ent; |
| 65 | unsigned long lost_events; | ||
| 60 | int leftover; | 66 | int leftover; |
| 61 | int cpu; | 67 | int cpu; |
| 62 | u64 ts; | 68 | u64 ts; |
| @@ -68,18 +74,25 @@ struct trace_iterator { | |||
| 68 | }; | 74 | }; |
| 69 | 75 | ||
| 70 | 76 | ||
| 77 | struct trace_event; | ||
| 78 | |||
| 71 | typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter, | 79 | typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter, |
| 72 | int flags); | 80 | int flags, struct trace_event *event); |
| 73 | struct trace_event { | 81 | |
| 74 | struct hlist_node node; | 82 | struct trace_event_functions { |
| 75 | struct list_head list; | ||
| 76 | int type; | ||
| 77 | trace_print_func trace; | 83 | trace_print_func trace; |
| 78 | trace_print_func raw; | 84 | trace_print_func raw; |
| 79 | trace_print_func hex; | 85 | trace_print_func hex; |
| 80 | trace_print_func binary; | 86 | trace_print_func binary; |
| 81 | }; | 87 | }; |
| 82 | 88 | ||
| 89 | struct trace_event { | ||
| 90 | struct hlist_node node; | ||
| 91 | struct list_head list; | ||
| 92 | int type; | ||
| 93 | struct trace_event_functions *funcs; | ||
| 94 | }; | ||
| 95 | |||
| 83 | extern int register_ftrace_event(struct trace_event *event); | 96 | extern int register_ftrace_event(struct trace_event *event); |
| 84 | extern int unregister_ftrace_event(struct trace_event *event); | 97 | extern int unregister_ftrace_event(struct trace_event *event); |
| 85 | 98 | ||
| @@ -111,35 +124,79 @@ void tracing_record_cmdline(struct task_struct *tsk); | |||
| 111 | 124 | ||
| 112 | struct event_filter; | 125 | struct event_filter; |
| 113 | 126 | ||
| 127 | enum trace_reg { | ||
| 128 | TRACE_REG_REGISTER, | ||
| 129 | TRACE_REG_UNREGISTER, | ||
| 130 | TRACE_REG_PERF_REGISTER, | ||
| 131 | TRACE_REG_PERF_UNREGISTER, | ||
| 132 | }; | ||
| 133 | |||
| 134 | struct ftrace_event_call; | ||
| 135 | |||
| 136 | struct ftrace_event_class { | ||
| 137 | char *system; | ||
| 138 | void *probe; | ||
| 139 | #ifdef CONFIG_PERF_EVENTS | ||
| 140 | void *perf_probe; | ||
| 141 | #endif | ||
| 142 | int (*reg)(struct ftrace_event_call *event, | ||
| 143 | enum trace_reg type); | ||
| 144 | int (*define_fields)(struct ftrace_event_call *); | ||
| 145 | struct list_head *(*get_fields)(struct ftrace_event_call *); | ||
| 146 | struct list_head fields; | ||
| 147 | int (*raw_init)(struct ftrace_event_call *); | ||
| 148 | }; | ||
| 149 | |||
| 150 | extern int ftrace_event_reg(struct ftrace_event_call *event, | ||
| 151 | enum trace_reg type); | ||
| 152 | |||
| 153 | enum { | ||
| 154 | TRACE_EVENT_FL_ENABLED_BIT, | ||
| 155 | TRACE_EVENT_FL_FILTERED_BIT, | ||
| 156 | TRACE_EVENT_FL_RECORDED_CMD_BIT, | ||
| 157 | }; | ||
| 158 | |||
| 159 | enum { | ||
| 160 | TRACE_EVENT_FL_ENABLED = (1 << TRACE_EVENT_FL_ENABLED_BIT), | ||
| 161 | TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT), | ||
| 162 | TRACE_EVENT_FL_RECORDED_CMD = (1 << TRACE_EVENT_FL_RECORDED_CMD_BIT), | ||
| 163 | }; | ||
| 164 | |||
| 114 | struct ftrace_event_call { | 165 | struct ftrace_event_call { |
| 115 | struct list_head list; | 166 | struct list_head list; |
| 167 | struct ftrace_event_class *class; | ||
| 116 | char *name; | 168 | char *name; |
| 117 | char *system; | ||
| 118 | struct dentry *dir; | 169 | struct dentry *dir; |
| 119 | struct trace_event *event; | 170 | struct trace_event event; |
| 120 | int enabled; | 171 | const char *print_fmt; |
| 121 | int (*regfunc)(struct ftrace_event_call *); | ||
| 122 | void (*unregfunc)(struct ftrace_event_call *); | ||
| 123 | int id; | ||
| 124 | int (*raw_init)(struct ftrace_event_call *); | ||
| 125 | int (*show_format)(struct ftrace_event_call *, | ||
| 126 | struct trace_seq *); | ||
| 127 | int (*define_fields)(struct ftrace_event_call *); | ||
| 128 | struct list_head fields; | ||
| 129 | int filter_active; | ||
| 130 | struct event_filter *filter; | 172 | struct event_filter *filter; |
| 131 | void *mod; | 173 | void *mod; |
| 132 | void *data; | 174 | void *data; |
| 133 | 175 | ||
| 134 | int profile_count; | 176 | /* |
| 135 | int (*profile_enable)(struct ftrace_event_call *); | 177 | * 32 bit flags: |
| 136 | void (*profile_disable)(struct ftrace_event_call *); | 178 | * bit 1: enabled |
| 179 | * bit 2: filter_active | ||
| 180 | * bit 3: enabled cmd record | ||
| 181 | * | ||
| 182 | * Changes to flags must hold the event_mutex. | ||
| 183 | * | ||
| 184 | * Note: Reads of flags do not hold the event_mutex since | ||
| 185 | * they occur in critical sections. But the way flags | ||
| 186 | * is currently used, these changes do no affect the code | ||
| 187 | * except that when a change is made, it may have a slight | ||
| 188 | * delay in propagating the changes to other CPUs due to | ||
| 189 | * caching and such. | ||
| 190 | */ | ||
| 191 | unsigned int flags; | ||
| 192 | |||
| 193 | #ifdef CONFIG_PERF_EVENTS | ||
| 194 | int perf_refcount; | ||
| 195 | struct hlist_head *perf_events; | ||
| 196 | #endif | ||
| 137 | }; | 197 | }; |
| 138 | 198 | ||
| 139 | #define FTRACE_MAX_PROFILE_SIZE 2048 | 199 | #define PERF_MAX_TRACE_SIZE 2048 |
| 140 | |||
| 141 | extern char *perf_trace_buf; | ||
| 142 | extern char *perf_trace_buf_nmi; | ||
| 143 | 200 | ||
| 144 | #define MAX_FILTER_PRED 32 | 201 | #define MAX_FILTER_PRED 32 |
| 145 | #define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */ | 202 | #define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */ |
| @@ -188,13 +245,27 @@ do { \ | |||
| 188 | __trace_printk(ip, fmt, ##args); \ | 245 | __trace_printk(ip, fmt, ##args); \ |
| 189 | } while (0) | 246 | } while (0) |
| 190 | 247 | ||
| 191 | #ifdef CONFIG_EVENT_PROFILE | 248 | #ifdef CONFIG_PERF_EVENTS |
| 192 | struct perf_event; | 249 | struct perf_event; |
| 193 | extern int ftrace_profile_enable(int event_id); | 250 | |
| 194 | extern void ftrace_profile_disable(int event_id); | 251 | DECLARE_PER_CPU(struct pt_regs, perf_trace_regs); |
| 195 | extern int ftrace_profile_set_filter(struct perf_event *event, int event_id, | 252 | |
| 253 | extern int perf_trace_init(struct perf_event *event); | ||
| 254 | extern void perf_trace_destroy(struct perf_event *event); | ||
| 255 | extern int perf_trace_enable(struct perf_event *event); | ||
| 256 | extern void perf_trace_disable(struct perf_event *event); | ||
| 257 | extern int ftrace_profile_set_filter(struct perf_event *event, int event_id, | ||
| 196 | char *filter_str); | 258 | char *filter_str); |
| 197 | extern void ftrace_profile_free_filter(struct perf_event *event); | 259 | extern void ftrace_profile_free_filter(struct perf_event *event); |
| 260 | extern void *perf_trace_buf_prepare(int size, unsigned short type, | ||
| 261 | struct pt_regs *regs, int *rctxp); | ||
| 262 | |||
| 263 | static inline void | ||
| 264 | perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr, | ||
| 265 | u64 count, struct pt_regs *regs, void *head) | ||
| 266 | { | ||
| 267 | perf_tp_event(addr, count, raw_data, size, regs, head, rctx); | ||
| 268 | } | ||
| 198 | #endif | 269 | #endif |
| 199 | 270 | ||
| 200 | #endif /* _LINUX_FTRACE_EVENT_H */ | 271 | #endif /* _LINUX_FTRACE_EVENT_H */ |
