blob: 6658a51390fe89d1ad94ababf53bb5da87c55611 [file] [log] [blame]
Mike Frysinger9849ed42010-07-20 03:13:35 -04001/*
2 * Ftrace header. For implementation details beyond the random comments
3 * scattered below, see: Documentation/trace/ftrace-design.txt
4 */
5
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +02006#ifndef _LINUX_FTRACE_H
7#define _LINUX_FTRACE_H
8
Frederic Weisbecker00126932009-03-05 01:49:22 +01009#include <linux/trace_clock.h>
Frederic Weisbecker56010202008-10-02 13:26:05 +020010#include <linux/kallsyms.h>
Frederic Weisbecker00126932009-03-05 01:49:22 +010011#include <linux/linkage.h>
Steven Rostedtea4e2bc2008-12-03 15:36:57 -050012#include <linux/bitops.h>
Frederic Weisbecker00126932009-03-05 01:49:22 +010013#include <linux/module.h>
14#include <linux/ktime.h>
Frederic Weisbecker21a8c462008-12-04 23:51:23 +010015#include <linux/sched.h>
Frederic Weisbecker00126932009-03-05 01:49:22 +010016#include <linux/types.h>
17#include <linux/init.h>
18#include <linux/fs.h>
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020019
Uwe Kleine-Koenigc79a61f2009-02-27 21:30:03 +010020#include <asm/ftrace.h>
21
Steven Rostedt606576c2008-10-06 19:06:12 -040022#ifdef CONFIG_FUNCTION_TRACER
Ingo Molnar3e1932a2008-10-02 17:45:47 +020023
Steven Rostedtb0fc4942008-05-12 21:20:43 +020024extern int ftrace_enabled;
25extern int
26ftrace_enable_sysctl(struct ctl_table *table, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070027 void __user *buffer, size_t *lenp,
Steven Rostedtb0fc4942008-05-12 21:20:43 +020028 loff_t *ppos);
29
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020030typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
31
Steven Rostedtf45948e2011-05-02 12:29:25 -040032struct ftrace_hash;
33
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020034struct ftrace_ops {
Steven Rostedtf45948e2011-05-02 12:29:25 -040035 ftrace_func_t func;
36 struct ftrace_ops *next;
37#ifdef CONFIG_DYNAMIC_FTRACE
38 struct ftrace_hash *notrace_hash;
39 struct ftrace_hash *filter_hash;
40#endif
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020041};
42
Steven Rostedt60a7ecf2008-11-05 16:05:44 -050043extern int function_trace_stop;
44
Frederic Weisbeckere7d37372008-11-16 06:02:06 +010045/*
46 * Type of the current tracing.
47 */
48enum ftrace_tracing_type_t {
49 FTRACE_TYPE_ENTER = 0, /* Hook the call of the function */
50 FTRACE_TYPE_RETURN, /* Hook the return of the function */
51};
52
53/* Current tracing type, default is FTRACE_TYPE_ENTER */
54extern enum ftrace_tracing_type_t ftrace_tracing_type;
55
Steven Rostedt60a7ecf2008-11-05 16:05:44 -050056/**
57 * ftrace_stop - stop function tracer.
58 *
59 * A quick way to stop the function tracer. Note this an on off switch,
60 * it is not something that is recursive like preempt_disable.
61 * This does not disable the calling of mcount, it only stops the
62 * calling of functions from mcount.
63 */
64static inline void ftrace_stop(void)
65{
66 function_trace_stop = 1;
67}
68
69/**
70 * ftrace_start - start the function tracer.
71 *
72 * This function is the inverse of ftrace_stop. This does not enable
73 * the function tracing if the function tracer is disabled. This only
74 * sets the function tracer flag to continue calling the functions
75 * from mcount.
76 */
77static inline void ftrace_start(void)
78{
79 function_trace_stop = 0;
80}
81
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020082/*
83 * The ftrace_ops must be a static and should also
84 * be read_mostly. These functions do modify read_mostly variables
85 * so use them sparely. Never free an ftrace_op or modify the
86 * next pointer after it has been registered. Even after unregistering
87 * it, the next pointer may still be used internally.
88 */
89int register_ftrace_function(struct ftrace_ops *ops);
90int unregister_ftrace_function(struct ftrace_ops *ops);
91void clear_ftrace_function(void);
92
93extern void ftrace_stub(unsigned long a0, unsigned long a1);
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020094
Steven Rostedt606576c2008-10-06 19:06:12 -040095#else /* !CONFIG_FUNCTION_TRACER */
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -040096/*
97 * (un)register_ftrace_function must be a macro since the ops parameter
98 * must not be evaluated.
99 */
100#define register_ftrace_function(ops) ({ 0; })
101#define unregister_ftrace_function(ops) ({ 0; })
102static inline void clear_ftrace_function(void) { }
Steven Rostedt81adbdc2008-10-23 09:33:02 -0400103static inline void ftrace_kill(void) { }
Steven Rostedt60a7ecf2008-11-05 16:05:44 -0500104static inline void ftrace_stop(void) { }
105static inline void ftrace_start(void) { }
Steven Rostedt606576c2008-10-06 19:06:12 -0400106#endif /* CONFIG_FUNCTION_TRACER */
Steven Rostedt352ad252008-05-12 21:20:42 +0200107
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500108#ifdef CONFIG_STACK_TRACER
109extern int stack_tracer_enabled;
110int
111stack_trace_sysctl(struct ctl_table *table, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700112 void __user *buffer, size_t *lenp,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500113 loff_t *ppos);
114#endif
115
Steven Rostedtf6180772009-02-14 00:40:25 -0500116struct ftrace_func_command {
117 struct list_head list;
118 char *name;
119 int (*func)(char *func, char *cmd,
120 char *params, int enable);
121};
122
Steven Rostedt3d083392008-05-12 21:20:42 +0200123#ifdef CONFIG_DYNAMIC_FTRACE
Steven Rostedt31e88902008-11-14 16:21:19 -0800124
Steven Rostedt000ab692009-02-17 13:35:06 -0500125int ftrace_arch_code_modify_prepare(void);
126int ftrace_arch_code_modify_post_process(void);
127
Steven Rostedt809dcf22009-02-16 23:06:01 -0500128struct seq_file;
129
Steven Rostedtb6887d72009-02-17 12:32:04 -0500130struct ftrace_probe_ops {
Steven Rostedt59df055f2009-02-14 15:29:06 -0500131 void (*func)(unsigned long ip,
132 unsigned long parent_ip,
133 void **data);
134 int (*callback)(unsigned long ip, void **data);
135 void (*free)(void **data);
Steven Rostedt809dcf22009-02-16 23:06:01 -0500136 int (*print)(struct seq_file *m,
137 unsigned long ip,
Steven Rostedtb6887d72009-02-17 12:32:04 -0500138 struct ftrace_probe_ops *ops,
Steven Rostedt809dcf22009-02-16 23:06:01 -0500139 void *data);
Steven Rostedt59df055f2009-02-14 15:29:06 -0500140};
141
142extern int
Steven Rostedtb6887d72009-02-17 12:32:04 -0500143register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
Steven Rostedt59df055f2009-02-14 15:29:06 -0500144 void *data);
145extern void
Steven Rostedtb6887d72009-02-17 12:32:04 -0500146unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
Steven Rostedt59df055f2009-02-14 15:29:06 -0500147 void *data);
148extern void
Steven Rostedtb6887d72009-02-17 12:32:04 -0500149unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops);
150extern void unregister_ftrace_function_probe_all(char *glob);
Steven Rostedt59df055f2009-02-14 15:29:06 -0500151
Masami Hiramatsu2cfa1972010-02-02 16:49:11 -0500152extern int ftrace_text_reserved(void *start, void *end);
153
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200154enum {
Steven Rostedt37ad5082008-05-12 21:20:48 +0200155 FTRACE_FL_FREE = (1 << 0),
Steven Rostedt1cf41dd72011-04-29 20:59:51 -0400156 FTRACE_FL_ENABLED = (1 << 1),
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200157};
158
Steven Rostedt3d083392008-05-12 21:20:42 +0200159struct dyn_ftrace {
Lai Jiangshanee000b72009-03-24 13:38:06 +0800160 union {
161 unsigned long ip; /* address of mcount call-site */
162 struct dyn_ftrace *freelist;
163 };
164 union {
165 unsigned long flags;
166 struct dyn_ftrace *newlist;
167 };
168 struct dyn_arch_ftrace arch;
Steven Rostedt3d083392008-05-12 21:20:42 +0200169};
170
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200171int ftrace_force_update(void);
Steven Rostedt77a2b372008-05-12 21:20:45 +0200172void ftrace_set_filter(unsigned char *buf, int len, int reset);
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200173
Steven Rostedtf6180772009-02-14 00:40:25 -0500174int register_ftrace_command(struct ftrace_func_command *cmd);
175int unregister_ftrace_command(struct ftrace_func_command *cmd);
176
Steven Rostedt3d083392008-05-12 21:20:42 +0200177/* defined in arch */
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200178extern int ftrace_ip_converted(unsigned long ip);
Steven Rostedtd61f82d2008-05-12 21:20:43 +0200179extern int ftrace_dyn_arch_init(void *data);
Steven Rostedtd61f82d2008-05-12 21:20:43 +0200180extern int ftrace_update_ftrace_func(ftrace_func_t func);
181extern void ftrace_caller(void);
182extern void ftrace_call(void);
183extern void mcount_call(void);
Shaohua Lif0001202009-01-09 11:29:42 +0800184
185#ifndef FTRACE_ADDR
186#define FTRACE_ADDR ((unsigned long)ftrace_caller)
187#endif
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100188#ifdef CONFIG_FUNCTION_GRAPH_TRACER
189extern void ftrace_graph_caller(void);
Steven Rostedt5a45cfe2008-11-26 00:16:24 -0500190extern int ftrace_enable_ftrace_graph_caller(void);
191extern int ftrace_disable_ftrace_graph_caller(void);
192#else
193static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; }
194static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; }
Frederic Weisbeckere7d37372008-11-16 06:02:06 +0100195#endif
Steven Rostedtad90c0e2008-05-27 20:48:37 -0400196
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400197/**
Wenji Huang57794a92009-02-06 17:33:27 +0800198 * ftrace_make_nop - convert code into nop
Steven Rostedt31e88902008-11-14 16:21:19 -0800199 * @mod: module structure if called by module load initialization
200 * @rec: the mcount call site record
201 * @addr: the address that the call site should be calling
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400202 *
203 * This is a very sensitive operation and great care needs
204 * to be taken by the arch. The operation should carefully
205 * read the location, check to see if what is read is indeed
206 * what we expect it to be, and then on success of the compare,
207 * it should write to the location.
208 *
Steven Rostedt31e88902008-11-14 16:21:19 -0800209 * The code segment at @rec->ip should be a caller to @addr
210 *
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400211 * Return must be:
212 * 0 on success
213 * -EFAULT on error reading the location
214 * -EINVAL on a failed compare of the contents
215 * -EPERM on error writing to the location
216 * Any other value will be considered a failure.
217 */
Steven Rostedt31e88902008-11-14 16:21:19 -0800218extern int ftrace_make_nop(struct module *mod,
219 struct dyn_ftrace *rec, unsigned long addr);
220
221/**
222 * ftrace_make_call - convert a nop call site into a call to addr
223 * @rec: the mcount call site record
224 * @addr: the address that the call site should call
225 *
226 * This is a very sensitive operation and great care needs
227 * to be taken by the arch. The operation should carefully
228 * read the location, check to see if what is read is indeed
229 * what we expect it to be, and then on success of the compare,
230 * it should write to the location.
231 *
232 * The code segment at @rec->ip should be a nop
233 *
234 * Return must be:
235 * 0 on success
236 * -EFAULT on error reading the location
237 * -EINVAL on a failed compare of the contents
238 * -EPERM on error writing to the location
239 * Any other value will be considered a failure.
240 */
241extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
242
Steven Rostedt31e88902008-11-14 16:21:19 -0800243/* May be defined in arch */
244extern int ftrace_arch_read_dyn_info(char *buf, int size);
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400245
Abhishek Sagarecea6562008-06-21 23:47:53 +0530246extern int skip_trace(unsigned long ip);
247
Steven Rostedtc0719e52008-09-06 01:06:03 -0400248extern void ftrace_disable_daemon(void);
249extern void ftrace_enable_daemon(void);
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200250#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400251static inline int skip_trace(unsigned long ip) { return 0; }
252static inline int ftrace_force_update(void) { return 0; }
253static inline void ftrace_set_filter(unsigned char *buf, int len, int reset)
254{
255}
256static inline void ftrace_disable_daemon(void) { }
257static inline void ftrace_enable_daemon(void) { }
jolsa@redhat.come7247a12009-10-07 19:00:35 +0200258static inline void ftrace_release_mod(struct module *mod) {}
Steven Rostedtf6180772009-02-14 00:40:25 -0500259static inline int register_ftrace_command(struct ftrace_func_command *cmd)
260{
Ingo Molnar97d0bb82009-02-17 11:47:39 +0100261 return -EINVAL;
Steven Rostedtf6180772009-02-14 00:40:25 -0500262}
263static inline int unregister_ftrace_command(char *cmd_name)
264{
Ingo Molnar97d0bb82009-02-17 11:47:39 +0100265 return -EINVAL;
Steven Rostedtf6180772009-02-14 00:40:25 -0500266}
Masami Hiramatsu2cfa1972010-02-02 16:49:11 -0500267static inline int ftrace_text_reserved(void *start, void *end)
268{
269 return 0;
270}
Abhishek Sagarecea6562008-06-21 23:47:53 +0530271#endif /* CONFIG_DYNAMIC_FTRACE */
Steven Rostedt352ad252008-05-12 21:20:42 +0200272
Ingo Molnaraeaee8a2008-05-12 21:20:49 +0200273/* totally disable ftrace - can not re-enable after this */
274void ftrace_kill(void);
275
Ingo Molnarf43fdad2008-05-12 21:20:43 +0200276static inline void tracer_disable(void)
277{
Steven Rostedt606576c2008-10-06 19:06:12 -0400278#ifdef CONFIG_FUNCTION_TRACER
Ingo Molnarf43fdad2008-05-12 21:20:43 +0200279 ftrace_enabled = 0;
280#endif
281}
282
Huang Ying37002732008-08-18 16:24:56 +0800283/*
284 * Ftrace disable/restore without lock. Some synchronization mechanism
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700285 * must be used to prevent ftrace_enabled to be changed between
Huang Ying37002732008-08-18 16:24:56 +0800286 * disable/restore.
287 */
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700288static inline int __ftrace_enabled_save(void)
289{
Steven Rostedt606576c2008-10-06 19:06:12 -0400290#ifdef CONFIG_FUNCTION_TRACER
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700291 int saved_ftrace_enabled = ftrace_enabled;
292 ftrace_enabled = 0;
293 return saved_ftrace_enabled;
294#else
295 return 0;
296#endif
297}
298
299static inline void __ftrace_enabled_restore(int enabled)
300{
Steven Rostedt606576c2008-10-06 19:06:12 -0400301#ifdef CONFIG_FUNCTION_TRACER
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700302 ftrace_enabled = enabled;
303#endif
304}
305
Uwe Kleine-Koenigc79a61f2009-02-27 21:30:03 +0100306#ifndef HAVE_ARCH_CALLER_ADDR
307# ifdef CONFIG_FRAME_POINTER
308# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
309# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
310# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
311# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
312# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
313# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
314# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
315# else
316# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
317# define CALLER_ADDR1 0UL
318# define CALLER_ADDR2 0UL
319# define CALLER_ADDR3 0UL
320# define CALLER_ADDR4 0UL
321# define CALLER_ADDR5 0UL
322# define CALLER_ADDR6 0UL
323# endif
324#endif /* ifndef HAVE_ARCH_CALLER_ADDR */
Steven Rostedt352ad252008-05-12 21:20:42 +0200325
Steven Rostedt81d68a92008-05-12 21:20:42 +0200326#ifdef CONFIG_IRQSOFF_TRACER
Ingo Molnar489f1392008-02-25 13:38:05 +0100327 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
328 extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200329#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400330 static inline void time_hardirqs_on(unsigned long a0, unsigned long a1) { }
331 static inline void time_hardirqs_off(unsigned long a0, unsigned long a1) { }
Steven Rostedt81d68a92008-05-12 21:20:42 +0200332#endif
333
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200334#ifdef CONFIG_PREEMPT_TRACER
Ingo Molnar489f1392008-02-25 13:38:05 +0100335 extern void trace_preempt_on(unsigned long a0, unsigned long a1);
336 extern void trace_preempt_off(unsigned long a0, unsigned long a1);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200337#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400338 static inline void trace_preempt_on(unsigned long a0, unsigned long a1) { }
339 static inline void trace_preempt_off(unsigned long a0, unsigned long a1) { }
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200340#endif
341
Steven Rostedt68bf21a2008-08-14 15:45:08 -0400342#ifdef CONFIG_FTRACE_MCOUNT_RECORD
343extern void ftrace_init(void);
344#else
345static inline void ftrace_init(void) { }
346#endif
347
Frederic Weisbecker71566a02008-10-31 12:57:20 +0100348/*
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100349 * Structure that defines an entry function trace.
350 */
351struct ftrace_graph_ent {
352 unsigned long func; /* Current function */
353 int depth;
354};
Steven Rostedtdd0e5452008-08-01 12:26:41 -0400355
Frederic Weisbecker71566a02008-10-31 12:57:20 +0100356/*
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100357 * Structure that defines a return function trace.
358 */
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100359struct ftrace_graph_ret {
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100360 unsigned long func; /* Current function */
361 unsigned long long calltime;
362 unsigned long long rettime;
Frederic Weisbecker02310222008-11-17 03:22:41 +0100363 /* Number of functions that overran the depth limit for current task */
364 unsigned long overrun;
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100365 int depth;
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100366};
367
Jiri Olsa62b915f2010-04-02 19:01:22 +0200368/* Type of the callback handlers for tracing function graph*/
369typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
370typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
371
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100372#ifdef CONFIG_FUNCTION_GRAPH_TRACER
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100373
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400374/* for init task */
Tetsuo Handaf876d342009-04-08 14:05:43 +0900375#define INIT_FTRACE_GRAPH .ret_stack = NULL,
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400376
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100377/*
Steven Rostedt712406a2009-02-09 10:54:03 -0800378 * Stack of return addresses for functions
379 * of a thread.
380 * Used in struct thread_info
381 */
382struct ftrace_ret_stack {
383 unsigned long ret;
384 unsigned long func;
385 unsigned long long calltime;
Steven Rostedta2a16d62009-03-24 23:17:58 -0400386 unsigned long long subtime;
Steven Rostedt71e308a2009-06-18 12:45:08 -0400387 unsigned long fp;
Steven Rostedt712406a2009-02-09 10:54:03 -0800388};
389
390/*
391 * Primary handler of a function return.
392 * It relays on ftrace_return_to_handler.
393 * Defined in entry_32/64.S
394 */
395extern void return_to_handler(void);
396
397extern int
Steven Rostedt71e308a2009-06-18 12:45:08 -0400398ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
399 unsigned long frame_pointer);
Steven Rostedt712406a2009-02-09 10:54:03 -0800400
401/*
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100402 * Sometimes we don't want to trace a function with the function
403 * graph tracer but we want them to keep traced by the usual function
404 * tracer if the function graph tracer is not configured.
405 */
406#define __notrace_funcgraph notrace
407
Frederic Weisbeckerbcbc4f22008-12-09 23:54:20 +0100408/*
409 * We want to which function is an entrypoint of a hardirq.
410 * That will help us to put a signal on output.
411 */
412#define __irq_entry __attribute__((__section__(".irqentry.text")))
413
414/* Limits of hardirq entrypoints */
415extern char __irqentry_text_start[];
416extern char __irqentry_text_end[];
417
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100418#define FTRACE_RETFUNC_DEPTH 50
419#define FTRACE_RETSTACK_ALLOC_SIZE 32
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100420extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
421 trace_func_graph_ent_t entryfunc);
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100422
Steven Rostedt14a866c2008-12-02 23:50:02 -0500423extern void ftrace_graph_stop(void);
424
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100425/* The current handlers in use */
426extern trace_func_graph_ret_t ftrace_graph_return;
427extern trace_func_graph_ent_t ftrace_graph_entry;
428
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100429extern void unregister_ftrace_graph(void);
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100430
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100431extern void ftrace_graph_init_task(struct task_struct *t);
432extern void ftrace_graph_exit_task(struct task_struct *t);
Steven Rostedt868baf02011-02-10 21:26:13 -0500433extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu);
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100434
435static inline int task_curr_ret_stack(struct task_struct *t)
436{
437 return t->curr_ret_stack;
438}
Frederic Weisbecker380c4b12008-12-06 03:43:41 +0100439
440static inline void pause_graph_tracing(void)
441{
442 atomic_inc(&current->tracing_graph_pause);
443}
444
445static inline void unpause_graph_tracing(void)
446{
447 atomic_dec(&current->tracing_graph_pause);
448}
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400449#else /* !CONFIG_FUNCTION_GRAPH_TRACER */
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100450
451#define __notrace_funcgraph
Frederic Weisbeckerbcbc4f22008-12-09 23:54:20 +0100452#define __irq_entry
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400453#define INIT_FTRACE_GRAPH
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100454
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100455static inline void ftrace_graph_init_task(struct task_struct *t) { }
456static inline void ftrace_graph_exit_task(struct task_struct *t) { }
Steven Rostedt868baf02011-02-10 21:26:13 -0500457static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { }
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100458
Jiri Olsa62b915f2010-04-02 19:01:22 +0200459static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc,
460 trace_func_graph_ent_t entryfunc)
461{
462 return -1;
463}
464static inline void unregister_ftrace_graph(void) { }
465
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100466static inline int task_curr_ret_stack(struct task_struct *tsk)
467{
468 return -1;
469}
Frederic Weisbecker380c4b12008-12-06 03:43:41 +0100470
471static inline void pause_graph_tracing(void) { }
472static inline void unpause_graph_tracing(void) { }
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400473#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100474
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500475#ifdef CONFIG_TRACING
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500476
477/* flags for current->trace */
478enum {
479 TSK_TRACE_FL_TRACE_BIT = 0,
480 TSK_TRACE_FL_GRAPH_BIT = 1,
481};
482enum {
483 TSK_TRACE_FL_TRACE = 1 << TSK_TRACE_FL_TRACE_BIT,
484 TSK_TRACE_FL_GRAPH = 1 << TSK_TRACE_FL_GRAPH_BIT,
485};
486
487static inline void set_tsk_trace_trace(struct task_struct *tsk)
488{
489 set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
490}
491
492static inline void clear_tsk_trace_trace(struct task_struct *tsk)
493{
494 clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
495}
496
497static inline int test_tsk_trace_trace(struct task_struct *tsk)
498{
499 return tsk->trace & TSK_TRACE_FL_TRACE;
500}
501
502static inline void set_tsk_trace_graph(struct task_struct *tsk)
503{
504 set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
505}
506
507static inline void clear_tsk_trace_graph(struct task_struct *tsk)
508{
509 clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
510}
511
512static inline int test_tsk_trace_graph(struct task_struct *tsk)
513{
514 return tsk->trace & TSK_TRACE_FL_GRAPH;
515}
516
Frederic Weisbeckercecbca92010-04-18 19:08:41 +0200517enum ftrace_dump_mode;
518
519extern enum ftrace_dump_mode ftrace_dump_on_oops;
Ingo Molnar526211b2009-03-05 10:28:45 +0100520
Steven Rostedt261842b2009-04-16 21:41:52 -0400521#ifdef CONFIG_PREEMPT
522#define INIT_TRACE_RECURSION .trace_recursion = 0,
523#endif
524
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500525#endif /* CONFIG_TRACING */
526
Steven Rostedt261842b2009-04-16 21:41:52 -0400527#ifndef INIT_TRACE_RECURSION
528#define INIT_TRACE_RECURSION
529#endif
Markus Metzgerb1818742009-01-19 10:31:01 +0100530
Mike Frysingere7b8e672010-01-26 04:40:03 -0500531#ifdef CONFIG_FTRACE_SYSCALLS
532
533unsigned long arch_syscall_addr(int nr);
534
535#endif /* CONFIG_FTRACE_SYSCALLS */
536
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +0200537#endif /* _LINUX_FTRACE_H */