blob: 4609c0ece79a71690c0e85bd76ef86c1e97e6580 [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
Steven Rostedtb8489142011-05-04 09:27:52 -040034enum {
35 FTRACE_OPS_FL_ENABLED = 1 << 0,
36 FTRACE_OPS_FL_GLOBAL = 1 << 1,
37};
38
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020039struct ftrace_ops {
Steven Rostedtf45948e2011-05-02 12:29:25 -040040 ftrace_func_t func;
41 struct ftrace_ops *next;
Steven Rostedtb8489142011-05-04 09:27:52 -040042 unsigned long flags;
Steven Rostedtf45948e2011-05-02 12:29:25 -040043#ifdef CONFIG_DYNAMIC_FTRACE
44 struct ftrace_hash *notrace_hash;
45 struct ftrace_hash *filter_hash;
46#endif
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020047};
48
Steven Rostedt60a7ecf2008-11-05 16:05:44 -050049extern int function_trace_stop;
50
Frederic Weisbeckere7d37372008-11-16 06:02:06 +010051/*
52 * Type of the current tracing.
53 */
54enum ftrace_tracing_type_t {
55 FTRACE_TYPE_ENTER = 0, /* Hook the call of the function */
56 FTRACE_TYPE_RETURN, /* Hook the return of the function */
57};
58
59/* Current tracing type, default is FTRACE_TYPE_ENTER */
60extern enum ftrace_tracing_type_t ftrace_tracing_type;
61
Steven Rostedt60a7ecf2008-11-05 16:05:44 -050062/**
63 * ftrace_stop - stop function tracer.
64 *
65 * A quick way to stop the function tracer. Note this an on off switch,
66 * it is not something that is recursive like preempt_disable.
67 * This does not disable the calling of mcount, it only stops the
68 * calling of functions from mcount.
69 */
70static inline void ftrace_stop(void)
71{
72 function_trace_stop = 1;
73}
74
75/**
76 * ftrace_start - start the function tracer.
77 *
78 * This function is the inverse of ftrace_stop. This does not enable
79 * the function tracing if the function tracer is disabled. This only
80 * sets the function tracer flag to continue calling the functions
81 * from mcount.
82 */
83static inline void ftrace_start(void)
84{
85 function_trace_stop = 0;
86}
87
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020088/*
89 * The ftrace_ops must be a static and should also
90 * be read_mostly. These functions do modify read_mostly variables
91 * so use them sparely. Never free an ftrace_op or modify the
92 * next pointer after it has been registered. Even after unregistering
93 * it, the next pointer may still be used internally.
94 */
95int register_ftrace_function(struct ftrace_ops *ops);
96int unregister_ftrace_function(struct ftrace_ops *ops);
97void clear_ftrace_function(void);
98
99extern void ftrace_stub(unsigned long a0, unsigned long a1);
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +0200100
Steven Rostedt606576c2008-10-06 19:06:12 -0400101#else /* !CONFIG_FUNCTION_TRACER */
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400102/*
103 * (un)register_ftrace_function must be a macro since the ops parameter
104 * must not be evaluated.
105 */
106#define register_ftrace_function(ops) ({ 0; })
107#define unregister_ftrace_function(ops) ({ 0; })
108static inline void clear_ftrace_function(void) { }
Steven Rostedt81adbdc2008-10-23 09:33:02 -0400109static inline void ftrace_kill(void) { }
Steven Rostedt60a7ecf2008-11-05 16:05:44 -0500110static inline void ftrace_stop(void) { }
111static inline void ftrace_start(void) { }
Steven Rostedt606576c2008-10-06 19:06:12 -0400112#endif /* CONFIG_FUNCTION_TRACER */
Steven Rostedt352ad252008-05-12 21:20:42 +0200113
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500114#ifdef CONFIG_STACK_TRACER
115extern int stack_tracer_enabled;
116int
117stack_trace_sysctl(struct ctl_table *table, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700118 void __user *buffer, size_t *lenp,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500119 loff_t *ppos);
120#endif
121
Steven Rostedtf6180772009-02-14 00:40:25 -0500122struct ftrace_func_command {
123 struct list_head list;
124 char *name;
125 int (*func)(char *func, char *cmd,
126 char *params, int enable);
127};
128
Steven Rostedt3d083392008-05-12 21:20:42 +0200129#ifdef CONFIG_DYNAMIC_FTRACE
Steven Rostedt31e88902008-11-14 16:21:19 -0800130
Steven Rostedt000ab692009-02-17 13:35:06 -0500131int ftrace_arch_code_modify_prepare(void);
132int ftrace_arch_code_modify_post_process(void);
133
Steven Rostedt809dcf22009-02-16 23:06:01 -0500134struct seq_file;
135
Steven Rostedtb6887d72009-02-17 12:32:04 -0500136struct ftrace_probe_ops {
Steven Rostedt59df055f2009-02-14 15:29:06 -0500137 void (*func)(unsigned long ip,
138 unsigned long parent_ip,
139 void **data);
140 int (*callback)(unsigned long ip, void **data);
141 void (*free)(void **data);
Steven Rostedt809dcf22009-02-16 23:06:01 -0500142 int (*print)(struct seq_file *m,
143 unsigned long ip,
Steven Rostedtb6887d72009-02-17 12:32:04 -0500144 struct ftrace_probe_ops *ops,
Steven Rostedt809dcf22009-02-16 23:06:01 -0500145 void *data);
Steven Rostedt59df055f2009-02-14 15:29:06 -0500146};
147
148extern int
Steven Rostedtb6887d72009-02-17 12:32:04 -0500149register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
Steven Rostedt59df055f2009-02-14 15:29:06 -0500150 void *data);
151extern void
Steven Rostedtb6887d72009-02-17 12:32:04 -0500152unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
Steven Rostedt59df055f2009-02-14 15:29:06 -0500153 void *data);
154extern void
Steven Rostedtb6887d72009-02-17 12:32:04 -0500155unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops);
156extern void unregister_ftrace_function_probe_all(char *glob);
Steven Rostedt59df055f2009-02-14 15:29:06 -0500157
Masami Hiramatsu2cfa1972010-02-02 16:49:11 -0500158extern int ftrace_text_reserved(void *start, void *end);
159
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200160enum {
Steven Rostedted926f92011-05-03 13:25:24 -0400161 FTRACE_FL_ENABLED = (1 << 30),
162 FTRACE_FL_FREE = (1 << 31),
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200163};
164
Steven Rostedted926f92011-05-03 13:25:24 -0400165#define FTRACE_FL_MASK (0x3UL << 30)
166#define FTRACE_REF_MAX ((1 << 30) - 1)
167
Steven Rostedt3d083392008-05-12 21:20:42 +0200168struct dyn_ftrace {
Lai Jiangshanee000b72009-03-24 13:38:06 +0800169 union {
170 unsigned long ip; /* address of mcount call-site */
171 struct dyn_ftrace *freelist;
172 };
173 union {
174 unsigned long flags;
175 struct dyn_ftrace *newlist;
176 };
177 struct dyn_arch_ftrace arch;
Steven Rostedt3d083392008-05-12 21:20:42 +0200178};
179
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200180int ftrace_force_update(void);
Steven Rostedt77a2b372008-05-12 21:20:45 +0200181void ftrace_set_filter(unsigned char *buf, int len, int reset);
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200182
Steven Rostedtf6180772009-02-14 00:40:25 -0500183int register_ftrace_command(struct ftrace_func_command *cmd);
184int unregister_ftrace_command(struct ftrace_func_command *cmd);
185
Steven Rostedt3d083392008-05-12 21:20:42 +0200186/* defined in arch */
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200187extern int ftrace_ip_converted(unsigned long ip);
Steven Rostedtd61f82d2008-05-12 21:20:43 +0200188extern int ftrace_dyn_arch_init(void *data);
Steven Rostedtd61f82d2008-05-12 21:20:43 +0200189extern int ftrace_update_ftrace_func(ftrace_func_t func);
190extern void ftrace_caller(void);
191extern void ftrace_call(void);
192extern void mcount_call(void);
Shaohua Lif0001202009-01-09 11:29:42 +0800193
194#ifndef FTRACE_ADDR
195#define FTRACE_ADDR ((unsigned long)ftrace_caller)
196#endif
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100197#ifdef CONFIG_FUNCTION_GRAPH_TRACER
198extern void ftrace_graph_caller(void);
Steven Rostedt5a45cfe2008-11-26 00:16:24 -0500199extern int ftrace_enable_ftrace_graph_caller(void);
200extern int ftrace_disable_ftrace_graph_caller(void);
201#else
202static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; }
203static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; }
Frederic Weisbeckere7d37372008-11-16 06:02:06 +0100204#endif
Steven Rostedtad90c0e2008-05-27 20:48:37 -0400205
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400206/**
Wenji Huang57794a92009-02-06 17:33:27 +0800207 * ftrace_make_nop - convert code into nop
Steven Rostedt31e88902008-11-14 16:21:19 -0800208 * @mod: module structure if called by module load initialization
209 * @rec: the mcount call site record
210 * @addr: the address that the call site should be calling
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400211 *
212 * This is a very sensitive operation and great care needs
213 * to be taken by the arch. The operation should carefully
214 * read the location, check to see if what is read is indeed
215 * what we expect it to be, and then on success of the compare,
216 * it should write to the location.
217 *
Steven Rostedt31e88902008-11-14 16:21:19 -0800218 * The code segment at @rec->ip should be a caller to @addr
219 *
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400220 * Return must be:
221 * 0 on success
222 * -EFAULT on error reading the location
223 * -EINVAL on a failed compare of the contents
224 * -EPERM on error writing to the location
225 * Any other value will be considered a failure.
226 */
Steven Rostedt31e88902008-11-14 16:21:19 -0800227extern int ftrace_make_nop(struct module *mod,
228 struct dyn_ftrace *rec, unsigned long addr);
229
230/**
231 * ftrace_make_call - convert a nop call site into a call to addr
232 * @rec: the mcount call site record
233 * @addr: the address that the call site should call
234 *
235 * This is a very sensitive operation and great care needs
236 * to be taken by the arch. The operation should carefully
237 * read the location, check to see if what is read is indeed
238 * what we expect it to be, and then on success of the compare,
239 * it should write to the location.
240 *
241 * The code segment at @rec->ip should be a nop
242 *
243 * Return must be:
244 * 0 on success
245 * -EFAULT on error reading the location
246 * -EINVAL on a failed compare of the contents
247 * -EPERM on error writing to the location
248 * Any other value will be considered a failure.
249 */
250extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
251
Steven Rostedt31e88902008-11-14 16:21:19 -0800252/* May be defined in arch */
253extern int ftrace_arch_read_dyn_info(char *buf, int size);
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400254
Abhishek Sagarecea6562008-06-21 23:47:53 +0530255extern int skip_trace(unsigned long ip);
256
Steven Rostedtc0719e52008-09-06 01:06:03 -0400257extern void ftrace_disable_daemon(void);
258extern void ftrace_enable_daemon(void);
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200259#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400260static inline int skip_trace(unsigned long ip) { return 0; }
261static inline int ftrace_force_update(void) { return 0; }
262static inline void ftrace_set_filter(unsigned char *buf, int len, int reset)
263{
264}
265static inline void ftrace_disable_daemon(void) { }
266static inline void ftrace_enable_daemon(void) { }
jolsa@redhat.come7247a12009-10-07 19:00:35 +0200267static inline void ftrace_release_mod(struct module *mod) {}
Steven Rostedtf6180772009-02-14 00:40:25 -0500268static inline int register_ftrace_command(struct ftrace_func_command *cmd)
269{
Ingo Molnar97d0bb82009-02-17 11:47:39 +0100270 return -EINVAL;
Steven Rostedtf6180772009-02-14 00:40:25 -0500271}
272static inline int unregister_ftrace_command(char *cmd_name)
273{
Ingo Molnar97d0bb82009-02-17 11:47:39 +0100274 return -EINVAL;
Steven Rostedtf6180772009-02-14 00:40:25 -0500275}
Masami Hiramatsu2cfa1972010-02-02 16:49:11 -0500276static inline int ftrace_text_reserved(void *start, void *end)
277{
278 return 0;
279}
Abhishek Sagarecea6562008-06-21 23:47:53 +0530280#endif /* CONFIG_DYNAMIC_FTRACE */
Steven Rostedt352ad252008-05-12 21:20:42 +0200281
Ingo Molnaraeaee8a2008-05-12 21:20:49 +0200282/* totally disable ftrace - can not re-enable after this */
283void ftrace_kill(void);
284
Ingo Molnarf43fdad2008-05-12 21:20:43 +0200285static inline void tracer_disable(void)
286{
Steven Rostedt606576c2008-10-06 19:06:12 -0400287#ifdef CONFIG_FUNCTION_TRACER
Ingo Molnarf43fdad2008-05-12 21:20:43 +0200288 ftrace_enabled = 0;
289#endif
290}
291
Huang Ying37002732008-08-18 16:24:56 +0800292/*
293 * Ftrace disable/restore without lock. Some synchronization mechanism
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700294 * must be used to prevent ftrace_enabled to be changed between
Huang Ying37002732008-08-18 16:24:56 +0800295 * disable/restore.
296 */
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700297static inline int __ftrace_enabled_save(void)
298{
Steven Rostedt606576c2008-10-06 19:06:12 -0400299#ifdef CONFIG_FUNCTION_TRACER
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700300 int saved_ftrace_enabled = ftrace_enabled;
301 ftrace_enabled = 0;
302 return saved_ftrace_enabled;
303#else
304 return 0;
305#endif
306}
307
308static inline void __ftrace_enabled_restore(int enabled)
309{
Steven Rostedt606576c2008-10-06 19:06:12 -0400310#ifdef CONFIG_FUNCTION_TRACER
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700311 ftrace_enabled = enabled;
312#endif
313}
314
Uwe Kleine-Koenigc79a61f2009-02-27 21:30:03 +0100315#ifndef HAVE_ARCH_CALLER_ADDR
316# ifdef CONFIG_FRAME_POINTER
317# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
318# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
319# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
320# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
321# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
322# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
323# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
324# else
325# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
326# define CALLER_ADDR1 0UL
327# define CALLER_ADDR2 0UL
328# define CALLER_ADDR3 0UL
329# define CALLER_ADDR4 0UL
330# define CALLER_ADDR5 0UL
331# define CALLER_ADDR6 0UL
332# endif
333#endif /* ifndef HAVE_ARCH_CALLER_ADDR */
Steven Rostedt352ad252008-05-12 21:20:42 +0200334
Steven Rostedt81d68a92008-05-12 21:20:42 +0200335#ifdef CONFIG_IRQSOFF_TRACER
Ingo Molnar489f1392008-02-25 13:38:05 +0100336 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
337 extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200338#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400339 static inline void time_hardirqs_on(unsigned long a0, unsigned long a1) { }
340 static inline void time_hardirqs_off(unsigned long a0, unsigned long a1) { }
Steven Rostedt81d68a92008-05-12 21:20:42 +0200341#endif
342
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200343#ifdef CONFIG_PREEMPT_TRACER
Ingo Molnar489f1392008-02-25 13:38:05 +0100344 extern void trace_preempt_on(unsigned long a0, unsigned long a1);
345 extern void trace_preempt_off(unsigned long a0, unsigned long a1);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200346#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400347 static inline void trace_preempt_on(unsigned long a0, unsigned long a1) { }
348 static inline void trace_preempt_off(unsigned long a0, unsigned long a1) { }
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200349#endif
350
Steven Rostedt68bf21a2008-08-14 15:45:08 -0400351#ifdef CONFIG_FTRACE_MCOUNT_RECORD
352extern void ftrace_init(void);
353#else
354static inline void ftrace_init(void) { }
355#endif
356
Frederic Weisbecker71566a02008-10-31 12:57:20 +0100357/*
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100358 * Structure that defines an entry function trace.
359 */
360struct ftrace_graph_ent {
361 unsigned long func; /* Current function */
362 int depth;
363};
Steven Rostedtdd0e5452008-08-01 12:26:41 -0400364
Frederic Weisbecker71566a02008-10-31 12:57:20 +0100365/*
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100366 * Structure that defines a return function trace.
367 */
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100368struct ftrace_graph_ret {
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100369 unsigned long func; /* Current function */
370 unsigned long long calltime;
371 unsigned long long rettime;
Frederic Weisbecker02310222008-11-17 03:22:41 +0100372 /* Number of functions that overran the depth limit for current task */
373 unsigned long overrun;
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100374 int depth;
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100375};
376
Jiri Olsa62b915f2010-04-02 19:01:22 +0200377/* Type of the callback handlers for tracing function graph*/
378typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
379typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
380
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100381#ifdef CONFIG_FUNCTION_GRAPH_TRACER
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100382
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400383/* for init task */
Tetsuo Handaf876d342009-04-08 14:05:43 +0900384#define INIT_FTRACE_GRAPH .ret_stack = NULL,
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400385
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100386/*
Steven Rostedt712406a2009-02-09 10:54:03 -0800387 * Stack of return addresses for functions
388 * of a thread.
389 * Used in struct thread_info
390 */
391struct ftrace_ret_stack {
392 unsigned long ret;
393 unsigned long func;
394 unsigned long long calltime;
Steven Rostedta2a16d62009-03-24 23:17:58 -0400395 unsigned long long subtime;
Steven Rostedt71e308a2009-06-18 12:45:08 -0400396 unsigned long fp;
Steven Rostedt712406a2009-02-09 10:54:03 -0800397};
398
399/*
400 * Primary handler of a function return.
401 * It relays on ftrace_return_to_handler.
402 * Defined in entry_32/64.S
403 */
404extern void return_to_handler(void);
405
406extern int
Steven Rostedt71e308a2009-06-18 12:45:08 -0400407ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
408 unsigned long frame_pointer);
Steven Rostedt712406a2009-02-09 10:54:03 -0800409
410/*
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100411 * Sometimes we don't want to trace a function with the function
412 * graph tracer but we want them to keep traced by the usual function
413 * tracer if the function graph tracer is not configured.
414 */
415#define __notrace_funcgraph notrace
416
Frederic Weisbeckerbcbc4f22008-12-09 23:54:20 +0100417/*
418 * We want to which function is an entrypoint of a hardirq.
419 * That will help us to put a signal on output.
420 */
421#define __irq_entry __attribute__((__section__(".irqentry.text")))
422
423/* Limits of hardirq entrypoints */
424extern char __irqentry_text_start[];
425extern char __irqentry_text_end[];
426
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100427#define FTRACE_RETFUNC_DEPTH 50
428#define FTRACE_RETSTACK_ALLOC_SIZE 32
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100429extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
430 trace_func_graph_ent_t entryfunc);
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100431
Steven Rostedt14a866c2008-12-02 23:50:02 -0500432extern void ftrace_graph_stop(void);
433
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100434/* The current handlers in use */
435extern trace_func_graph_ret_t ftrace_graph_return;
436extern trace_func_graph_ent_t ftrace_graph_entry;
437
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100438extern void unregister_ftrace_graph(void);
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100439
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100440extern void ftrace_graph_init_task(struct task_struct *t);
441extern void ftrace_graph_exit_task(struct task_struct *t);
Steven Rostedt868baf02011-02-10 21:26:13 -0500442extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu);
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100443
444static inline int task_curr_ret_stack(struct task_struct *t)
445{
446 return t->curr_ret_stack;
447}
Frederic Weisbecker380c4b12008-12-06 03:43:41 +0100448
449static inline void pause_graph_tracing(void)
450{
451 atomic_inc(&current->tracing_graph_pause);
452}
453
454static inline void unpause_graph_tracing(void)
455{
456 atomic_dec(&current->tracing_graph_pause);
457}
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400458#else /* !CONFIG_FUNCTION_GRAPH_TRACER */
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100459
460#define __notrace_funcgraph
Frederic Weisbeckerbcbc4f22008-12-09 23:54:20 +0100461#define __irq_entry
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400462#define INIT_FTRACE_GRAPH
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100463
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100464static inline void ftrace_graph_init_task(struct task_struct *t) { }
465static inline void ftrace_graph_exit_task(struct task_struct *t) { }
Steven Rostedt868baf02011-02-10 21:26:13 -0500466static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { }
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100467
Jiri Olsa62b915f2010-04-02 19:01:22 +0200468static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc,
469 trace_func_graph_ent_t entryfunc)
470{
471 return -1;
472}
473static inline void unregister_ftrace_graph(void) { }
474
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100475static inline int task_curr_ret_stack(struct task_struct *tsk)
476{
477 return -1;
478}
Frederic Weisbecker380c4b12008-12-06 03:43:41 +0100479
480static inline void pause_graph_tracing(void) { }
481static inline void unpause_graph_tracing(void) { }
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400482#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100483
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500484#ifdef CONFIG_TRACING
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500485
486/* flags for current->trace */
487enum {
488 TSK_TRACE_FL_TRACE_BIT = 0,
489 TSK_TRACE_FL_GRAPH_BIT = 1,
490};
491enum {
492 TSK_TRACE_FL_TRACE = 1 << TSK_TRACE_FL_TRACE_BIT,
493 TSK_TRACE_FL_GRAPH = 1 << TSK_TRACE_FL_GRAPH_BIT,
494};
495
496static inline void set_tsk_trace_trace(struct task_struct *tsk)
497{
498 set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
499}
500
501static inline void clear_tsk_trace_trace(struct task_struct *tsk)
502{
503 clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
504}
505
506static inline int test_tsk_trace_trace(struct task_struct *tsk)
507{
508 return tsk->trace & TSK_TRACE_FL_TRACE;
509}
510
511static inline void set_tsk_trace_graph(struct task_struct *tsk)
512{
513 set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
514}
515
516static inline void clear_tsk_trace_graph(struct task_struct *tsk)
517{
518 clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
519}
520
521static inline int test_tsk_trace_graph(struct task_struct *tsk)
522{
523 return tsk->trace & TSK_TRACE_FL_GRAPH;
524}
525
Frederic Weisbeckercecbca92010-04-18 19:08:41 +0200526enum ftrace_dump_mode;
527
528extern enum ftrace_dump_mode ftrace_dump_on_oops;
Ingo Molnar526211b2009-03-05 10:28:45 +0100529
Steven Rostedt261842b2009-04-16 21:41:52 -0400530#ifdef CONFIG_PREEMPT
531#define INIT_TRACE_RECURSION .trace_recursion = 0,
532#endif
533
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500534#endif /* CONFIG_TRACING */
535
Steven Rostedt261842b2009-04-16 21:41:52 -0400536#ifndef INIT_TRACE_RECURSION
537#define INIT_TRACE_RECURSION
538#endif
Markus Metzgerb1818742009-01-19 10:31:01 +0100539
Mike Frysingere7b8e672010-01-26 04:40:03 -0500540#ifdef CONFIG_FTRACE_SYSCALLS
541
542unsigned long arch_syscall_addr(int nr);
543
544#endif /* CONFIG_FTRACE_SYSCALLS */
545
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +0200546#endif /* _LINUX_FTRACE_H */