aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ftrace.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ftrace.h')
-rw-r--r--include/linux/ftrace.h252
1 files changed, 146 insertions, 106 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 677432b9cb7e..6dc1c652447e 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -1,15 +1,18 @@
1#ifndef _LINUX_FTRACE_H 1#ifndef _LINUX_FTRACE_H
2#define _LINUX_FTRACE_H 2#define _LINUX_FTRACE_H
3 3
4#include <linux/linkage.h> 4#include <linux/trace_clock.h>
5#include <linux/fs.h>
6#include <linux/ktime.h>
7#include <linux/init.h>
8#include <linux/types.h>
9#include <linux/module.h>
10#include <linux/kallsyms.h> 5#include <linux/kallsyms.h>
6#include <linux/linkage.h>
11#include <linux/bitops.h> 7#include <linux/bitops.h>
8#include <linux/module.h>
9#include <linux/ktime.h>
12#include <linux/sched.h> 10#include <linux/sched.h>
11#include <linux/types.h>
12#include <linux/init.h>
13#include <linux/fs.h>
14
15#include <asm/ftrace.h>
13 16
14#ifdef CONFIG_FUNCTION_TRACER 17#ifdef CONFIG_FUNCTION_TRACER
15 18
@@ -95,9 +98,41 @@ stack_trace_sysctl(struct ctl_table *table, int write,
95 loff_t *ppos); 98 loff_t *ppos);
96#endif 99#endif
97 100
101struct ftrace_func_command {
102 struct list_head list;
103 char *name;
104 int (*func)(char *func, char *cmd,
105 char *params, int enable);
106};
107
98#ifdef CONFIG_DYNAMIC_FTRACE 108#ifdef CONFIG_DYNAMIC_FTRACE
99/* asm/ftrace.h must be defined for archs supporting dynamic ftrace */ 109
100#include <asm/ftrace.h> 110int ftrace_arch_code_modify_prepare(void);
111int ftrace_arch_code_modify_post_process(void);
112
113struct seq_file;
114
115struct ftrace_probe_ops {
116 void (*func)(unsigned long ip,
117 unsigned long parent_ip,
118 void **data);
119 int (*callback)(unsigned long ip, void **data);
120 void (*free)(void **data);
121 int (*print)(struct seq_file *m,
122 unsigned long ip,
123 struct ftrace_probe_ops *ops,
124 void *data);
125};
126
127extern int
128register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
129 void *data);
130extern void
131unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
132 void *data);
133extern void
134unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops);
135extern void unregister_ftrace_function_probe_all(char *glob);
101 136
102enum { 137enum {
103 FTRACE_FL_FREE = (1 << 0), 138 FTRACE_FL_FREE = (1 << 0),
@@ -119,6 +154,9 @@ struct dyn_ftrace {
119int ftrace_force_update(void); 154int ftrace_force_update(void);
120void ftrace_set_filter(unsigned char *buf, int len, int reset); 155void ftrace_set_filter(unsigned char *buf, int len, int reset);
121 156
157int register_ftrace_command(struct ftrace_func_command *cmd);
158int unregister_ftrace_command(struct ftrace_func_command *cmd);
159
122/* defined in arch */ 160/* defined in arch */
123extern int ftrace_ip_converted(unsigned long ip); 161extern int ftrace_ip_converted(unsigned long ip);
124extern int ftrace_dyn_arch_init(void *data); 162extern int ftrace_dyn_arch_init(void *data);
@@ -126,6 +164,10 @@ extern int ftrace_update_ftrace_func(ftrace_func_t func);
126extern void ftrace_caller(void); 164extern void ftrace_caller(void);
127extern void ftrace_call(void); 165extern void ftrace_call(void);
128extern void mcount_call(void); 166extern void mcount_call(void);
167
168#ifndef FTRACE_ADDR
169#define FTRACE_ADDR ((unsigned long)ftrace_caller)
170#endif
129#ifdef CONFIG_FUNCTION_GRAPH_TRACER 171#ifdef CONFIG_FUNCTION_GRAPH_TRACER
130extern void ftrace_graph_caller(void); 172extern void ftrace_graph_caller(void);
131extern int ftrace_enable_ftrace_graph_caller(void); 173extern int ftrace_enable_ftrace_graph_caller(void);
@@ -136,7 +178,7 @@ static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; }
136#endif 178#endif
137 179
138/** 180/**
139 * ftrace_make_nop - convert code into top 181 * ftrace_make_nop - convert code into nop
140 * @mod: module structure if called by module load initialization 182 * @mod: module structure if called by module load initialization
141 * @rec: the mcount call site record 183 * @rec: the mcount call site record
142 * @addr: the address that the call site should be calling 184 * @addr: the address that the call site should be calling
@@ -181,7 +223,6 @@ extern int ftrace_make_nop(struct module *mod,
181 */ 223 */
182extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr); 224extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
183 225
184
185/* May be defined in arch */ 226/* May be defined in arch */
186extern int ftrace_arch_read_dyn_info(char *buf, int size); 227extern int ftrace_arch_read_dyn_info(char *buf, int size);
187 228
@@ -198,6 +239,14 @@ extern void ftrace_enable_daemon(void);
198# define ftrace_disable_daemon() do { } while (0) 239# define ftrace_disable_daemon() do { } while (0)
199# define ftrace_enable_daemon() do { } while (0) 240# define ftrace_enable_daemon() do { } while (0)
200static inline void ftrace_release(void *start, unsigned long size) { } 241static inline void ftrace_release(void *start, unsigned long size) { }
242static inline int register_ftrace_command(struct ftrace_func_command *cmd)
243{
244 return -EINVAL;
245}
246static inline int unregister_ftrace_command(char *cmd_name)
247{
248 return -EINVAL;
249}
201#endif /* CONFIG_DYNAMIC_FTRACE */ 250#endif /* CONFIG_DYNAMIC_FTRACE */
202 251
203/* totally disable ftrace - can not re-enable after this */ 252/* totally disable ftrace - can not re-enable after this */
@@ -233,24 +282,25 @@ static inline void __ftrace_enabled_restore(int enabled)
233#endif 282#endif
234} 283}
235 284
236#ifdef CONFIG_FRAME_POINTER 285#ifndef HAVE_ARCH_CALLER_ADDR
237/* TODO: need to fix this for ARM */ 286# ifdef CONFIG_FRAME_POINTER
238# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) 287# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
239# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1)) 288# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
240# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2)) 289# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
241# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3)) 290# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
242# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4)) 291# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
243# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5)) 292# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
244# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6)) 293# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
245#else 294# else
246# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) 295# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
247# define CALLER_ADDR1 0UL 296# define CALLER_ADDR1 0UL
248# define CALLER_ADDR2 0UL 297# define CALLER_ADDR2 0UL
249# define CALLER_ADDR3 0UL 298# define CALLER_ADDR3 0UL
250# define CALLER_ADDR4 0UL 299# define CALLER_ADDR4 0UL
251# define CALLER_ADDR5 0UL 300# define CALLER_ADDR5 0UL
252# define CALLER_ADDR6 0UL 301# define CALLER_ADDR6 0UL
253#endif 302# endif
303#endif /* ifndef HAVE_ARCH_CALLER_ADDR */
254 304
255#ifdef CONFIG_IRQSOFF_TRACER 305#ifdef CONFIG_IRQSOFF_TRACER
256 extern void time_hardirqs_on(unsigned long a0, unsigned long a1); 306 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
@@ -268,54 +318,6 @@ static inline void __ftrace_enabled_restore(int enabled)
268# define trace_preempt_off(a0, a1) do { } while (0) 318# define trace_preempt_off(a0, a1) do { } while (0)
269#endif 319#endif
270 320
271#ifdef CONFIG_TRACING
272extern int ftrace_dump_on_oops;
273
274extern void tracing_start(void);
275extern void tracing_stop(void);
276extern void ftrace_off_permanent(void);
277
278extern void
279ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
280
281/**
282 * ftrace_printk - printf formatting in the ftrace buffer
283 * @fmt: the printf format for printing
284 *
285 * Note: __ftrace_printk is an internal function for ftrace_printk and
286 * the @ip is passed in via the ftrace_printk macro.
287 *
288 * This function allows a kernel developer to debug fast path sections
289 * that printk is not appropriate for. By scattering in various
290 * printk like tracing in the code, a developer can quickly see
291 * where problems are occurring.
292 *
293 * This is intended as a debugging tool for the developer only.
294 * Please refrain from leaving ftrace_printks scattered around in
295 * your code.
296 */
297# define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt)
298extern int
299__ftrace_printk(unsigned long ip, const char *fmt, ...)
300 __attribute__ ((format (printf, 2, 3)));
301extern void ftrace_dump(void);
302#else
303static inline void
304ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
305static inline int
306ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
307
308static inline void tracing_start(void) { }
309static inline void tracing_stop(void) { }
310static inline void ftrace_off_permanent(void) { }
311static inline int
312ftrace_printk(const char *fmt, ...)
313{
314 return 0;
315}
316static inline void ftrace_dump(void) { }
317#endif
318
319#ifdef CONFIG_FTRACE_MCOUNT_RECORD 321#ifdef CONFIG_FTRACE_MCOUNT_RECORD
320extern void ftrace_init(void); 322extern void ftrace_init(void);
321extern void ftrace_init_module(struct module *mod, 323extern void ftrace_init_module(struct module *mod,
@@ -327,36 +329,6 @@ ftrace_init_module(struct module *mod,
327 unsigned long *start, unsigned long *end) { } 329 unsigned long *start, unsigned long *end) { }
328#endif 330#endif
329 331
330enum {
331 POWER_NONE = 0,
332 POWER_CSTATE = 1,
333 POWER_PSTATE = 2,
334};
335
336struct power_trace {
337#ifdef CONFIG_POWER_TRACER
338 ktime_t stamp;
339 ktime_t end;
340 int type;
341 int state;
342#endif
343};
344
345#ifdef CONFIG_POWER_TRACER
346extern void trace_power_start(struct power_trace *it, unsigned int type,
347 unsigned int state);
348extern void trace_power_mark(struct power_trace *it, unsigned int type,
349 unsigned int state);
350extern void trace_power_end(struct power_trace *it);
351#else
352static inline void trace_power_start(struct power_trace *it, unsigned int type,
353 unsigned int state) { }
354static inline void trace_power_mark(struct power_trace *it, unsigned int type,
355 unsigned int state) { }
356static inline void trace_power_end(struct power_trace *it) { }
357#endif
358
359
360/* 332/*
361 * Structure that defines an entry function trace. 333 * Structure that defines an entry function trace.
362 */ 334 */
@@ -380,6 +352,30 @@ struct ftrace_graph_ret {
380#ifdef CONFIG_FUNCTION_GRAPH_TRACER 352#ifdef CONFIG_FUNCTION_GRAPH_TRACER
381 353
382/* 354/*
355 * Stack of return addresses for functions
356 * of a thread.
357 * Used in struct thread_info
358 */
359struct ftrace_ret_stack {
360 unsigned long ret;
361 unsigned long func;
362 unsigned long long calltime;
363};
364
365/*
366 * Primary handler of a function return.
367 * It relays on ftrace_return_to_handler.
368 * Defined in entry_32/64.S
369 */
370extern void return_to_handler(void);
371
372extern int
373ftrace_push_return_trace(unsigned long ret, unsigned long long time,
374 unsigned long func, int *depth);
375extern void
376ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret);
377
378/*
383 * Sometimes we don't want to trace a function with the function 379 * Sometimes we don't want to trace a function with the function
384 * graph tracer but we want them to keep traced by the usual function 380 * graph tracer but we want them to keep traced by the usual function
385 * tracer if the function graph tracer is not configured. 381 * tracer if the function graph tracer is not configured.
@@ -490,6 +486,50 @@ static inline int test_tsk_trace_graph(struct task_struct *tsk)
490 return tsk->trace & TSK_TRACE_FL_GRAPH; 486 return tsk->trace & TSK_TRACE_FL_GRAPH;
491} 487}
492 488
489extern int ftrace_dump_on_oops;
490
493#endif /* CONFIG_TRACING */ 491#endif /* CONFIG_TRACING */
494 492
493
494#ifdef CONFIG_HW_BRANCH_TRACER
495
496void trace_hw_branch(u64 from, u64 to);
497void trace_hw_branch_oops(void);
498
499#else /* CONFIG_HW_BRANCH_TRACER */
500
501static inline void trace_hw_branch(u64 from, u64 to) {}
502static inline void trace_hw_branch_oops(void) {}
503
504#endif /* CONFIG_HW_BRANCH_TRACER */
505
506/*
507 * A syscall entry in the ftrace syscalls array.
508 *
509 * @name: name of the syscall
510 * @nb_args: number of parameters it takes
511 * @types: list of types as strings
512 * @args: list of args as strings (args[i] matches types[i])
513 */
514struct syscall_metadata {
515 const char *name;
516 int nb_args;
517 const char **types;
518 const char **args;
519};
520
521#ifdef CONFIG_FTRACE_SYSCALLS
522extern void arch_init_ftrace_syscalls(void);
523extern struct syscall_metadata *syscall_nr_to_meta(int nr);
524extern void start_ftrace_syscalls(void);
525extern void stop_ftrace_syscalls(void);
526extern void ftrace_syscall_enter(struct pt_regs *regs);
527extern void ftrace_syscall_exit(struct pt_regs *regs);
528#else
529static inline void start_ftrace_syscalls(void) { }
530static inline void stop_ftrace_syscalls(void) { }
531static inline void ftrace_syscall_enter(struct pt_regs *regs) { }
532static inline void ftrace_syscall_exit(struct pt_regs *regs) { }
533#endif
534
495#endif /* _LINUX_FTRACE_H */ 535#endif /* _LINUX_FTRACE_H */