diff options
Diffstat (limited to 'include/linux/ftrace.h')
-rw-r--r-- | include/linux/ftrace.h | 123 |
1 files changed, 92 insertions, 31 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index fdb2a89ae543..847bb3c48dd0 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
@@ -95,6 +95,13 @@ stack_trace_sysctl(struct ctl_table *table, int write, | |||
95 | loff_t *ppos); | 95 | loff_t *ppos); |
96 | #endif | 96 | #endif |
97 | 97 | ||
98 | struct ftrace_func_command { | ||
99 | struct list_head list; | ||
100 | char *name; | ||
101 | int (*func)(char *func, char *cmd, | ||
102 | char *params, int enable); | ||
103 | }; | ||
104 | |||
98 | #ifdef CONFIG_DYNAMIC_FTRACE | 105 | #ifdef CONFIG_DYNAMIC_FTRACE |
99 | /* asm/ftrace.h must be defined for archs supporting dynamic ftrace */ | 106 | /* asm/ftrace.h must be defined for archs supporting dynamic ftrace */ |
100 | #include <asm/ftrace.h> | 107 | #include <asm/ftrace.h> |
@@ -102,6 +109,30 @@ stack_trace_sysctl(struct ctl_table *table, int write, | |||
102 | int ftrace_arch_code_modify_prepare(void); | 109 | int ftrace_arch_code_modify_prepare(void); |
103 | int ftrace_arch_code_modify_post_process(void); | 110 | int ftrace_arch_code_modify_post_process(void); |
104 | 111 | ||
112 | struct seq_file; | ||
113 | |||
114 | struct ftrace_probe_ops { | ||
115 | void (*func)(unsigned long ip, | ||
116 | unsigned long parent_ip, | ||
117 | void **data); | ||
118 | int (*callback)(unsigned long ip, void **data); | ||
119 | void (*free)(void **data); | ||
120 | int (*print)(struct seq_file *m, | ||
121 | unsigned long ip, | ||
122 | struct ftrace_probe_ops *ops, | ||
123 | void *data); | ||
124 | }; | ||
125 | |||
126 | extern int | ||
127 | register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, | ||
128 | void *data); | ||
129 | extern void | ||
130 | unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, | ||
131 | void *data); | ||
132 | extern void | ||
133 | unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops); | ||
134 | extern void unregister_ftrace_function_probe_all(char *glob); | ||
135 | |||
105 | enum { | 136 | enum { |
106 | FTRACE_FL_FREE = (1 << 0), | 137 | FTRACE_FL_FREE = (1 << 0), |
107 | FTRACE_FL_FAILED = (1 << 1), | 138 | FTRACE_FL_FAILED = (1 << 1), |
@@ -122,6 +153,9 @@ struct dyn_ftrace { | |||
122 | int ftrace_force_update(void); | 153 | int ftrace_force_update(void); |
123 | void ftrace_set_filter(unsigned char *buf, int len, int reset); | 154 | void ftrace_set_filter(unsigned char *buf, int len, int reset); |
124 | 155 | ||
156 | int register_ftrace_command(struct ftrace_func_command *cmd); | ||
157 | int unregister_ftrace_command(struct ftrace_func_command *cmd); | ||
158 | |||
125 | /* defined in arch */ | 159 | /* defined in arch */ |
126 | extern int ftrace_ip_converted(unsigned long ip); | 160 | extern int ftrace_ip_converted(unsigned long ip); |
127 | extern int ftrace_dyn_arch_init(void *data); | 161 | extern int ftrace_dyn_arch_init(void *data); |
@@ -129,6 +163,10 @@ extern int ftrace_update_ftrace_func(ftrace_func_t func); | |||
129 | extern void ftrace_caller(void); | 163 | extern void ftrace_caller(void); |
130 | extern void ftrace_call(void); | 164 | extern void ftrace_call(void); |
131 | extern void mcount_call(void); | 165 | extern void mcount_call(void); |
166 | |||
167 | #ifndef FTRACE_ADDR | ||
168 | #define FTRACE_ADDR ((unsigned long)ftrace_caller) | ||
169 | #endif | ||
132 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 170 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
133 | extern void ftrace_graph_caller(void); | 171 | extern void ftrace_graph_caller(void); |
134 | extern int ftrace_enable_ftrace_graph_caller(void); | 172 | extern int ftrace_enable_ftrace_graph_caller(void); |
@@ -139,7 +177,7 @@ static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; } | |||
139 | #endif | 177 | #endif |
140 | 178 | ||
141 | /** | 179 | /** |
142 | * ftrace_make_nop - convert code into top | 180 | * ftrace_make_nop - convert code into nop |
143 | * @mod: module structure if called by module load initialization | 181 | * @mod: module structure if called by module load initialization |
144 | * @rec: the mcount call site record | 182 | * @rec: the mcount call site record |
145 | * @addr: the address that the call site should be calling | 183 | * @addr: the address that the call site should be calling |
@@ -201,6 +239,14 @@ extern void ftrace_enable_daemon(void); | |||
201 | # define ftrace_disable_daemon() do { } while (0) | 239 | # define ftrace_disable_daemon() do { } while (0) |
202 | # define ftrace_enable_daemon() do { } while (0) | 240 | # define ftrace_enable_daemon() do { } while (0) |
203 | static inline void ftrace_release(void *start, unsigned long size) { } | 241 | static inline void ftrace_release(void *start, unsigned long size) { } |
242 | static inline int register_ftrace_command(struct ftrace_func_command *cmd) | ||
243 | { | ||
244 | return -EINVAL; | ||
245 | } | ||
246 | static inline int unregister_ftrace_command(char *cmd_name) | ||
247 | { | ||
248 | return -EINVAL; | ||
249 | } | ||
204 | #endif /* CONFIG_DYNAMIC_FTRACE */ | 250 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
205 | 251 | ||
206 | /* totally disable ftrace - can not re-enable after this */ | 252 | /* totally disable ftrace - can not re-enable after this */ |
@@ -301,6 +347,9 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); | |||
301 | extern int | 347 | extern int |
302 | __ftrace_printk(unsigned long ip, const char *fmt, ...) | 348 | __ftrace_printk(unsigned long ip, const char *fmt, ...) |
303 | __attribute__ ((format (printf, 2, 3))); | 349 | __attribute__ ((format (printf, 2, 3))); |
350 | # define ftrace_vprintk(fmt, ap) __ftrace_printk(_THIS_IP_, fmt, ap) | ||
351 | extern int | ||
352 | __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); | ||
304 | extern void ftrace_dump(void); | 353 | extern void ftrace_dump(void); |
305 | #else | 354 | #else |
306 | static inline void | 355 | static inline void |
@@ -316,6 +365,11 @@ ftrace_printk(const char *fmt, ...) | |||
316 | { | 365 | { |
317 | return 0; | 366 | return 0; |
318 | } | 367 | } |
368 | static inline int | ||
369 | ftrace_vprintk(const char *fmt, va_list ap) | ||
370 | { | ||
371 | return 0; | ||
372 | } | ||
319 | static inline void ftrace_dump(void) { } | 373 | static inline void ftrace_dump(void) { } |
320 | #endif | 374 | #endif |
321 | 375 | ||
@@ -330,36 +384,6 @@ ftrace_init_module(struct module *mod, | |||
330 | unsigned long *start, unsigned long *end) { } | 384 | unsigned long *start, unsigned long *end) { } |
331 | #endif | 385 | #endif |
332 | 386 | ||
333 | enum { | ||
334 | POWER_NONE = 0, | ||
335 | POWER_CSTATE = 1, | ||
336 | POWER_PSTATE = 2, | ||
337 | }; | ||
338 | |||
339 | struct power_trace { | ||
340 | #ifdef CONFIG_POWER_TRACER | ||
341 | ktime_t stamp; | ||
342 | ktime_t end; | ||
343 | int type; | ||
344 | int state; | ||
345 | #endif | ||
346 | }; | ||
347 | |||
348 | #ifdef CONFIG_POWER_TRACER | ||
349 | extern void trace_power_start(struct power_trace *it, unsigned int type, | ||
350 | unsigned int state); | ||
351 | extern void trace_power_mark(struct power_trace *it, unsigned int type, | ||
352 | unsigned int state); | ||
353 | extern void trace_power_end(struct power_trace *it); | ||
354 | #else | ||
355 | static inline void trace_power_start(struct power_trace *it, unsigned int type, | ||
356 | unsigned int state) { } | ||
357 | static inline void trace_power_mark(struct power_trace *it, unsigned int type, | ||
358 | unsigned int state) { } | ||
359 | static inline void trace_power_end(struct power_trace *it) { } | ||
360 | #endif | ||
361 | |||
362 | |||
363 | /* | 387 | /* |
364 | * Structure that defines an entry function trace. | 388 | * Structure that defines an entry function trace. |
365 | */ | 389 | */ |
@@ -383,6 +407,30 @@ struct ftrace_graph_ret { | |||
383 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 407 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
384 | 408 | ||
385 | /* | 409 | /* |
410 | * Stack of return addresses for functions | ||
411 | * of a thread. | ||
412 | * Used in struct thread_info | ||
413 | */ | ||
414 | struct ftrace_ret_stack { | ||
415 | unsigned long ret; | ||
416 | unsigned long func; | ||
417 | unsigned long long calltime; | ||
418 | }; | ||
419 | |||
420 | /* | ||
421 | * Primary handler of a function return. | ||
422 | * It relays on ftrace_return_to_handler. | ||
423 | * Defined in entry_32/64.S | ||
424 | */ | ||
425 | extern void return_to_handler(void); | ||
426 | |||
427 | extern int | ||
428 | ftrace_push_return_trace(unsigned long ret, unsigned long long time, | ||
429 | unsigned long func, int *depth); | ||
430 | extern void | ||
431 | ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret); | ||
432 | |||
433 | /* | ||
386 | * Sometimes we don't want to trace a function with the function | 434 | * Sometimes we don't want to trace a function with the function |
387 | * graph tracer but we want them to keep traced by the usual function | 435 | * graph tracer but we want them to keep traced by the usual function |
388 | * tracer if the function graph tracer is not configured. | 436 | * tracer if the function graph tracer is not configured. |
@@ -495,4 +543,17 @@ static inline int test_tsk_trace_graph(struct task_struct *tsk) | |||
495 | 543 | ||
496 | #endif /* CONFIG_TRACING */ | 544 | #endif /* CONFIG_TRACING */ |
497 | 545 | ||
546 | |||
547 | #ifdef CONFIG_HW_BRANCH_TRACER | ||
548 | |||
549 | void trace_hw_branch(u64 from, u64 to); | ||
550 | void trace_hw_branch_oops(void); | ||
551 | |||
552 | #else /* CONFIG_HW_BRANCH_TRACER */ | ||
553 | |||
554 | static inline void trace_hw_branch(u64 from, u64 to) {} | ||
555 | static inline void trace_hw_branch_oops(void) {} | ||
556 | |||
557 | #endif /* CONFIG_HW_BRANCH_TRACER */ | ||
558 | |||
498 | #endif /* _LINUX_FTRACE_H */ | 559 | #endif /* _LINUX_FTRACE_H */ |