blob: ab1c46e70bb673a9b210c93a413c5c23a4506611 [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;
Steven Rostedted926f92011-05-03 13:25:24 -040040 unsigned long flags;
Steven Rostedtf45948e2011-05-02 12:29:25 -040041#endif
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020042};
43
Steven Rostedt60a7ecf2008-11-05 16:05:44 -050044extern int function_trace_stop;
45
Frederic Weisbeckere7d37372008-11-16 06:02:06 +010046/*
47 * Type of the current tracing.
48 */
49enum ftrace_tracing_type_t {
50 FTRACE_TYPE_ENTER = 0, /* Hook the call of the function */
51 FTRACE_TYPE_RETURN, /* Hook the return of the function */
52};
53
54/* Current tracing type, default is FTRACE_TYPE_ENTER */
55extern enum ftrace_tracing_type_t ftrace_tracing_type;
56
Steven Rostedt60a7ecf2008-11-05 16:05:44 -050057/**
58 * ftrace_stop - stop function tracer.
59 *
60 * A quick way to stop the function tracer. Note this an on off switch,
61 * it is not something that is recursive like preempt_disable.
62 * This does not disable the calling of mcount, it only stops the
63 * calling of functions from mcount.
64 */
65static inline void ftrace_stop(void)
66{
67 function_trace_stop = 1;
68}
69
70/**
71 * ftrace_start - start the function tracer.
72 *
73 * This function is the inverse of ftrace_stop. This does not enable
74 * the function tracing if the function tracer is disabled. This only
75 * sets the function tracer flag to continue calling the functions
76 * from mcount.
77 */
78static inline void ftrace_start(void)
79{
80 function_trace_stop = 0;
81}
82
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020083/*
84 * The ftrace_ops must be a static and should also
85 * be read_mostly. These functions do modify read_mostly variables
86 * so use them sparely. Never free an ftrace_op or modify the
87 * next pointer after it has been registered. Even after unregistering
88 * it, the next pointer may still be used internally.
89 */
90int register_ftrace_function(struct ftrace_ops *ops);
91int unregister_ftrace_function(struct ftrace_ops *ops);
92void clear_ftrace_function(void);
93
94extern void ftrace_stub(unsigned long a0, unsigned long a1);
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020095
Steven Rostedt606576c2008-10-06 19:06:12 -040096#else /* !CONFIG_FUNCTION_TRACER */
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -040097/*
98 * (un)register_ftrace_function must be a macro since the ops parameter
99 * must not be evaluated.
100 */
101#define register_ftrace_function(ops) ({ 0; })
102#define unregister_ftrace_function(ops) ({ 0; })
103static inline void clear_ftrace_function(void) { }
Steven Rostedt81adbdc2008-10-23 09:33:02 -0400104static inline void ftrace_kill(void) { }
Steven Rostedt60a7ecf2008-11-05 16:05:44 -0500105static inline void ftrace_stop(void) { }
106static inline void ftrace_start(void) { }
Steven Rostedt606576c2008-10-06 19:06:12 -0400107#endif /* CONFIG_FUNCTION_TRACER */
Steven Rostedt352ad252008-05-12 21:20:42 +0200108
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500109#ifdef CONFIG_STACK_TRACER
110extern int stack_tracer_enabled;
111int
112stack_trace_sysctl(struct ctl_table *table, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700113 void __user *buffer, size_t *lenp,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500114 loff_t *ppos);
115#endif
116
Steven Rostedtf6180772009-02-14 00:40:25 -0500117struct ftrace_func_command {
118 struct list_head list;
119 char *name;
120 int (*func)(char *func, char *cmd,
121 char *params, int enable);
122};
123
Steven Rostedt3d083392008-05-12 21:20:42 +0200124#ifdef CONFIG_DYNAMIC_FTRACE
Steven Rostedt31e88902008-11-14 16:21:19 -0800125
Steven Rostedt000ab692009-02-17 13:35:06 -0500126int ftrace_arch_code_modify_prepare(void);
127int ftrace_arch_code_modify_post_process(void);
128
Steven Rostedt809dcf22009-02-16 23:06:01 -0500129struct seq_file;
130
Steven Rostedtb6887d72009-02-17 12:32:04 -0500131struct ftrace_probe_ops {
Steven Rostedt59df055f2009-02-14 15:29:06 -0500132 void (*func)(unsigned long ip,
133 unsigned long parent_ip,
134 void **data);
135 int (*callback)(unsigned long ip, void **data);
136 void (*free)(void **data);
Steven Rostedt809dcf22009-02-16 23:06:01 -0500137 int (*print)(struct seq_file *m,
138 unsigned long ip,
Steven Rostedtb6887d72009-02-17 12:32:04 -0500139 struct ftrace_probe_ops *ops,
Steven Rostedt809dcf22009-02-16 23:06:01 -0500140 void *data);
Steven Rostedt59df055f2009-02-14 15:29:06 -0500141};
142
143extern int
Steven Rostedtb6887d72009-02-17 12:32:04 -0500144register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
Steven Rostedt59df055f2009-02-14 15:29:06 -0500145 void *data);
146extern void
Steven Rostedtb6887d72009-02-17 12:32:04 -0500147unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
Steven Rostedt59df055f2009-02-14 15:29:06 -0500148 void *data);
149extern void
Steven Rostedtb6887d72009-02-17 12:32:04 -0500150unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops);
151extern void unregister_ftrace_function_probe_all(char *glob);
Steven Rostedt59df055f2009-02-14 15:29:06 -0500152
Masami Hiramatsu2cfa1972010-02-02 16:49:11 -0500153extern int ftrace_text_reserved(void *start, void *end);
154
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200155enum {
Steven Rostedted926f92011-05-03 13:25:24 -0400156 FTRACE_FL_ENABLED = (1 << 30),
157 FTRACE_FL_FREE = (1 << 31),
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200158};
159
Steven Rostedted926f92011-05-03 13:25:24 -0400160#define FTRACE_FL_MASK (0x3UL << 30)
161#define FTRACE_REF_MAX ((1 << 30) - 1)
162
Steven Rostedt3d083392008-05-12 21:20:42 +0200163struct dyn_ftrace {
Lai Jiangshanee000b72009-03-24 13:38:06 +0800164 union {
165 unsigned long ip; /* address of mcount call-site */
166 struct dyn_ftrace *freelist;
167 };
168 union {
169 unsigned long flags;
170 struct dyn_ftrace *newlist;
171 };
172 struct dyn_arch_ftrace arch;
Steven Rostedt3d083392008-05-12 21:20:42 +0200173};
174
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200175int ftrace_force_update(void);
Steven Rostedt77a2b372008-05-12 21:20:45 +0200176void ftrace_set_filter(unsigned char *buf, int len, int reset);
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200177
Steven Rostedtf6180772009-02-14 00:40:25 -0500178int register_ftrace_command(struct ftrace_func_command *cmd);
179int unregister_ftrace_command(struct ftrace_func_command *cmd);
180
Steven Rostedt3d083392008-05-12 21:20:42 +0200181/* defined in arch */
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200182extern int ftrace_ip_converted(unsigned long ip);
Steven Rostedtd61f82d2008-05-12 21:20:43 +0200183extern int ftrace_dyn_arch_init(void *data);
Steven Rostedtd61f82d2008-05-12 21:20:43 +0200184extern int ftrace_update_ftrace_func(ftrace_func_t func);
185extern void ftrace_caller(void);
186extern void ftrace_call(void);
187extern void mcount_call(void);
Shaohua Lif0001202009-01-09 11:29:42 +0800188
189#ifndef FTRACE_ADDR
190#define FTRACE_ADDR ((unsigned long)ftrace_caller)
191#endif
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100192#ifdef CONFIG_FUNCTION_GRAPH_TRACER
193extern void ftrace_graph_caller(void);
Steven Rostedt5a45cfe2008-11-26 00:16:24 -0500194extern int ftrace_enable_ftrace_graph_caller(void);
195extern int ftrace_disable_ftrace_graph_caller(void);
196#else
197static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; }
198static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; }
Frederic Weisbeckere7d37372008-11-16 06:02:06 +0100199#endif
Steven Rostedtad90c0e2008-05-27 20:48:37 -0400200
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400201/**
Wenji Huang57794a92009-02-06 17:33:27 +0800202 * ftrace_make_nop - convert code into nop
Steven Rostedt31e88902008-11-14 16:21:19 -0800203 * @mod: module structure if called by module load initialization
204 * @rec: the mcount call site record
205 * @addr: the address that the call site should be calling
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400206 *
207 * This is a very sensitive operation and great care needs
208 * to be taken by the arch. The operation should carefully
209 * read the location, check to see if what is read is indeed
210 * what we expect it to be, and then on success of the compare,
211 * it should write to the location.
212 *
Steven Rostedt31e88902008-11-14 16:21:19 -0800213 * The code segment at @rec->ip should be a caller to @addr
214 *
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400215 * Return must be:
216 * 0 on success
217 * -EFAULT on error reading the location
218 * -EINVAL on a failed compare of the contents
219 * -EPERM on error writing to the location
220 * Any other value will be considered a failure.
221 */
Steven Rostedt31e88902008-11-14 16:21:19 -0800222extern int ftrace_make_nop(struct module *mod,
223 struct dyn_ftrace *rec, unsigned long addr);
224
225/**
226 * ftrace_make_call - convert a nop call site into a call to addr
227 * @rec: the mcount call site record
228 * @addr: the address that the call site should call
229 *
230 * This is a very sensitive operation and great care needs
231 * to be taken by the arch. The operation should carefully
232 * read the location, check to see if what is read is indeed
233 * what we expect it to be, and then on success of the compare,
234 * it should write to the location.
235 *
236 * The code segment at @rec->ip should be a nop
237 *
238 * Return must be:
239 * 0 on success
240 * -EFAULT on error reading the location
241 * -EINVAL on a failed compare of the contents
242 * -EPERM on error writing to the location
243 * Any other value will be considered a failure.
244 */
245extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
246
Steven Rostedt31e88902008-11-14 16:21:19 -0800247/* May be defined in arch */
248extern int ftrace_arch_read_dyn_info(char *buf, int size);
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400249
Abhishek Sagarecea6562008-06-21 23:47:53 +0530250extern int skip_trace(unsigned long ip);
251
Steven Rostedtc0719e52008-09-06 01:06:03 -0400252extern void ftrace_disable_daemon(void);
253extern void ftrace_enable_daemon(void);
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200254#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400255static inline int skip_trace(unsigned long ip) { return 0; }
256static inline int ftrace_force_update(void) { return 0; }
257static inline void ftrace_set_filter(unsigned char *buf, int len, int reset)
258{
259}
260static inline void ftrace_disable_daemon(void) { }
261static inline void ftrace_enable_daemon(void) { }
jolsa@redhat.come7247a12009-10-07 19:00:35 +0200262static inline void ftrace_release_mod(struct module *mod) {}
Steven Rostedtf6180772009-02-14 00:40:25 -0500263static inline int register_ftrace_command(struct ftrace_func_command *cmd)
264{
Ingo Molnar97d0bb82009-02-17 11:47:39 +0100265 return -EINVAL;
Steven Rostedtf6180772009-02-14 00:40:25 -0500266}
267static inline int unregister_ftrace_command(char *cmd_name)
268{
Ingo Molnar97d0bb82009-02-17 11:47:39 +0100269 return -EINVAL;
Steven Rostedtf6180772009-02-14 00:40:25 -0500270}
Masami Hiramatsu2cfa1972010-02-02 16:49:11 -0500271static inline int ftrace_text_reserved(void *start, void *end)
272{
273 return 0;
274}
Abhishek Sagarecea6562008-06-21 23:47:53 +0530275#endif /* CONFIG_DYNAMIC_FTRACE */
Steven Rostedt352ad252008-05-12 21:20:42 +0200276
Ingo Molnaraeaee8a2008-05-12 21:20:49 +0200277/* totally disable ftrace - can not re-enable after this */
278void ftrace_kill(void);
279
Ingo Molnarf43fdad2008-05-12 21:20:43 +0200280static inline void tracer_disable(void)
281{
Steven Rostedt606576c2008-10-06 19:06:12 -0400282#ifdef CONFIG_FUNCTION_TRACER
Ingo Molnarf43fdad2008-05-12 21:20:43 +0200283 ftrace_enabled = 0;
284#endif
285}
286
Huang Ying37002732008-08-18 16:24:56 +0800287/*
288 * Ftrace disable/restore without lock. Some synchronization mechanism
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700289 * must be used to prevent ftrace_enabled to be changed between
Huang Ying37002732008-08-18 16:24:56 +0800290 * disable/restore.
291 */
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700292static inline int __ftrace_enabled_save(void)
293{
Steven Rostedt606576c2008-10-06 19:06:12 -0400294#ifdef CONFIG_FUNCTION_TRACER
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700295 int saved_ftrace_enabled = ftrace_enabled;
296 ftrace_enabled = 0;
297 return saved_ftrace_enabled;
298#else
299 return 0;
300#endif
301}
302
303static inline void __ftrace_enabled_restore(int enabled)
304{
Steven Rostedt606576c2008-10-06 19:06:12 -0400305#ifdef CONFIG_FUNCTION_TRACER
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700306 ftrace_enabled = enabled;
307#endif
308}
309
Uwe Kleine-Koenigc79a61f2009-02-27 21:30:03 +0100310#ifndef HAVE_ARCH_CALLER_ADDR
311# ifdef CONFIG_FRAME_POINTER
312# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
313# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
314# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
315# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
316# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
317# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
318# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
319# else
320# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
321# define CALLER_ADDR1 0UL
322# define CALLER_ADDR2 0UL
323# define CALLER_ADDR3 0UL
324# define CALLER_ADDR4 0UL
325# define CALLER_ADDR5 0UL
326# define CALLER_ADDR6 0UL
327# endif
328#endif /* ifndef HAVE_ARCH_CALLER_ADDR */
Steven Rostedt352ad252008-05-12 21:20:42 +0200329
Steven Rostedt81d68a92008-05-12 21:20:42 +0200330#ifdef CONFIG_IRQSOFF_TRACER
Ingo Molnar489f1392008-02-25 13:38:05 +0100331 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
332 extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200333#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400334 static inline void time_hardirqs_on(unsigned long a0, unsigned long a1) { }
335 static inline void time_hardirqs_off(unsigned long a0, unsigned long a1) { }
Steven Rostedt81d68a92008-05-12 21:20:42 +0200336#endif
337
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200338#ifdef CONFIG_PREEMPT_TRACER
Ingo Molnar489f1392008-02-25 13:38:05 +0100339 extern void trace_preempt_on(unsigned long a0, unsigned long a1);
340 extern void trace_preempt_off(unsigned long a0, unsigned long a1);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200341#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400342 static inline void trace_preempt_on(unsigned long a0, unsigned long a1) { }
343 static inline void trace_preempt_off(unsigned long a0, unsigned long a1) { }
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200344#endif
345
Steven Rostedt68bf21a2008-08-14 15:45:08 -0400346#ifdef CONFIG_FTRACE_MCOUNT_RECORD
347extern void ftrace_init(void);
348#else
349static inline void ftrace_init(void) { }
350#endif
351
Frederic Weisbecker71566a02008-10-31 12:57:20 +0100352/*
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100353 * Structure that defines an entry function trace.
354 */
355struct ftrace_graph_ent {
356 unsigned long func; /* Current function */
357 int depth;
358};
Steven Rostedtdd0e5452008-08-01 12:26:41 -0400359
Frederic Weisbecker71566a02008-10-31 12:57:20 +0100360/*
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100361 * Structure that defines a return function trace.
362 */
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100363struct ftrace_graph_ret {
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100364 unsigned long func; /* Current function */
365 unsigned long long calltime;
366 unsigned long long rettime;
Frederic Weisbecker02310222008-11-17 03:22:41 +0100367 /* Number of functions that overran the depth limit for current task */
368 unsigned long overrun;
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100369 int depth;
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100370};
371
Jiri Olsa62b915f2010-04-02 19:01:22 +0200372/* Type of the callback handlers for tracing function graph*/
373typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
374typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
375
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100376#ifdef CONFIG_FUNCTION_GRAPH_TRACER
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100377
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400378/* for init task */
Tetsuo Handaf876d342009-04-08 14:05:43 +0900379#define INIT_FTRACE_GRAPH .ret_stack = NULL,
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400380
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100381/*
Steven Rostedt712406a2009-02-09 10:54:03 -0800382 * Stack of return addresses for functions
383 * of a thread.
384 * Used in struct thread_info
385 */
386struct ftrace_ret_stack {
387 unsigned long ret;
388 unsigned long func;
389 unsigned long long calltime;
Steven Rostedta2a16d62009-03-24 23:17:58 -0400390 unsigned long long subtime;
Steven Rostedt71e308a2009-06-18 12:45:08 -0400391 unsigned long fp;
Steven Rostedt712406a2009-02-09 10:54:03 -0800392};
393
394/*
395 * Primary handler of a function return.
396 * It relays on ftrace_return_to_handler.
397 * Defined in entry_32/64.S
398 */
399extern void return_to_handler(void);
400
401extern int
Steven Rostedt71e308a2009-06-18 12:45:08 -0400402ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
403 unsigned long frame_pointer);
Steven Rostedt712406a2009-02-09 10:54:03 -0800404
405/*
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100406 * Sometimes we don't want to trace a function with the function
407 * graph tracer but we want them to keep traced by the usual function
408 * tracer if the function graph tracer is not configured.
409 */
410#define __notrace_funcgraph notrace
411
Frederic Weisbeckerbcbc4f22008-12-09 23:54:20 +0100412/*
413 * We want to which function is an entrypoint of a hardirq.
414 * That will help us to put a signal on output.
415 */
416#define __irq_entry __attribute__((__section__(".irqentry.text")))
417
418/* Limits of hardirq entrypoints */
419extern char __irqentry_text_start[];
420extern char __irqentry_text_end[];
421
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100422#define FTRACE_RETFUNC_DEPTH 50
423#define FTRACE_RETSTACK_ALLOC_SIZE 32
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100424extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
425 trace_func_graph_ent_t entryfunc);
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100426
Steven Rostedt14a866c2008-12-02 23:50:02 -0500427extern void ftrace_graph_stop(void);
428
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100429/* The current handlers in use */
430extern trace_func_graph_ret_t ftrace_graph_return;
431extern trace_func_graph_ent_t ftrace_graph_entry;
432
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100433extern void unregister_ftrace_graph(void);
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100434
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100435extern void ftrace_graph_init_task(struct task_struct *t);
436extern void ftrace_graph_exit_task(struct task_struct *t);
Steven Rostedt868baf02011-02-10 21:26:13 -0500437extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu);
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100438
439static inline int task_curr_ret_stack(struct task_struct *t)
440{
441 return t->curr_ret_stack;
442}
Frederic Weisbecker380c4b12008-12-06 03:43:41 +0100443
444static inline void pause_graph_tracing(void)
445{
446 atomic_inc(&current->tracing_graph_pause);
447}
448
449static inline void unpause_graph_tracing(void)
450{
451 atomic_dec(&current->tracing_graph_pause);
452}
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400453#else /* !CONFIG_FUNCTION_GRAPH_TRACER */
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100454
455#define __notrace_funcgraph
Frederic Weisbeckerbcbc4f22008-12-09 23:54:20 +0100456#define __irq_entry
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400457#define INIT_FTRACE_GRAPH
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100458
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100459static inline void ftrace_graph_init_task(struct task_struct *t) { }
460static inline void ftrace_graph_exit_task(struct task_struct *t) { }
Steven Rostedt868baf02011-02-10 21:26:13 -0500461static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { }
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100462
Jiri Olsa62b915f2010-04-02 19:01:22 +0200463static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc,
464 trace_func_graph_ent_t entryfunc)
465{
466 return -1;
467}
468static inline void unregister_ftrace_graph(void) { }
469
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100470static inline int task_curr_ret_stack(struct task_struct *tsk)
471{
472 return -1;
473}
Frederic Weisbecker380c4b12008-12-06 03:43:41 +0100474
475static inline void pause_graph_tracing(void) { }
476static inline void unpause_graph_tracing(void) { }
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400477#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100478
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500479#ifdef CONFIG_TRACING
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500480
481/* flags for current->trace */
482enum {
483 TSK_TRACE_FL_TRACE_BIT = 0,
484 TSK_TRACE_FL_GRAPH_BIT = 1,
485};
486enum {
487 TSK_TRACE_FL_TRACE = 1 << TSK_TRACE_FL_TRACE_BIT,
488 TSK_TRACE_FL_GRAPH = 1 << TSK_TRACE_FL_GRAPH_BIT,
489};
490
491static inline void set_tsk_trace_trace(struct task_struct *tsk)
492{
493 set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
494}
495
496static inline void clear_tsk_trace_trace(struct task_struct *tsk)
497{
498 clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
499}
500
501static inline int test_tsk_trace_trace(struct task_struct *tsk)
502{
503 return tsk->trace & TSK_TRACE_FL_TRACE;
504}
505
506static inline void set_tsk_trace_graph(struct task_struct *tsk)
507{
508 set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
509}
510
511static inline void clear_tsk_trace_graph(struct task_struct *tsk)
512{
513 clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
514}
515
516static inline int test_tsk_trace_graph(struct task_struct *tsk)
517{
518 return tsk->trace & TSK_TRACE_FL_GRAPH;
519}
520
Frederic Weisbeckercecbca92010-04-18 19:08:41 +0200521enum ftrace_dump_mode;
522
523extern enum ftrace_dump_mode ftrace_dump_on_oops;
Ingo Molnar526211b2009-03-05 10:28:45 +0100524
Steven Rostedt261842b2009-04-16 21:41:52 -0400525#ifdef CONFIG_PREEMPT
526#define INIT_TRACE_RECURSION .trace_recursion = 0,
527#endif
528
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500529#endif /* CONFIG_TRACING */
530
Steven Rostedt261842b2009-04-16 21:41:52 -0400531#ifndef INIT_TRACE_RECURSION
532#define INIT_TRACE_RECURSION
533#endif
Markus Metzgerb1818742009-01-19 10:31:01 +0100534
Mike Frysingere7b8e672010-01-26 04:40:03 -0500535#ifdef CONFIG_FTRACE_SYSCALLS
536
537unsigned long arch_syscall_addr(int nr);
538
539#endif /* CONFIG_FTRACE_SYSCALLS */
540
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +0200541#endif /* _LINUX_FTRACE_H */