blob: dcd6a7c3a4358b310b430a16dc52f43b547e02f2 [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
32struct ftrace_ops {
33 ftrace_func_t func;
34 struct ftrace_ops *next;
35};
36
Steven Rostedt60a7ecf2008-11-05 16:05:44 -050037extern int function_trace_stop;
38
Frederic Weisbeckere7d37372008-11-16 06:02:06 +010039/*
40 * Type of the current tracing.
41 */
42enum ftrace_tracing_type_t {
43 FTRACE_TYPE_ENTER = 0, /* Hook the call of the function */
44 FTRACE_TYPE_RETURN, /* Hook the return of the function */
45};
46
47/* Current tracing type, default is FTRACE_TYPE_ENTER */
48extern enum ftrace_tracing_type_t ftrace_tracing_type;
49
Steven Rostedt60a7ecf2008-11-05 16:05:44 -050050/**
51 * ftrace_stop - stop function tracer.
52 *
53 * A quick way to stop the function tracer. Note this an on off switch,
54 * it is not something that is recursive like preempt_disable.
55 * This does not disable the calling of mcount, it only stops the
56 * calling of functions from mcount.
57 */
58static inline void ftrace_stop(void)
59{
60 function_trace_stop = 1;
61}
62
63/**
64 * ftrace_start - start the function tracer.
65 *
66 * This function is the inverse of ftrace_stop. This does not enable
67 * the function tracing if the function tracer is disabled. This only
68 * sets the function tracer flag to continue calling the functions
69 * from mcount.
70 */
71static inline void ftrace_start(void)
72{
73 function_trace_stop = 0;
74}
75
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020076/*
77 * The ftrace_ops must be a static and should also
78 * be read_mostly. These functions do modify read_mostly variables
79 * so use them sparely. Never free an ftrace_op or modify the
80 * next pointer after it has been registered. Even after unregistering
81 * it, the next pointer may still be used internally.
82 */
83int register_ftrace_function(struct ftrace_ops *ops);
84int unregister_ftrace_function(struct ftrace_ops *ops);
85void clear_ftrace_function(void);
86
87extern void ftrace_stub(unsigned long a0, unsigned long a1);
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020088
Steven Rostedt606576c2008-10-06 19:06:12 -040089#else /* !CONFIG_FUNCTION_TRACER */
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -040090/*
91 * (un)register_ftrace_function must be a macro since the ops parameter
92 * must not be evaluated.
93 */
94#define register_ftrace_function(ops) ({ 0; })
95#define unregister_ftrace_function(ops) ({ 0; })
96static inline void clear_ftrace_function(void) { }
Steven Rostedt81adbdc2008-10-23 09:33:02 -040097static inline void ftrace_kill(void) { }
Steven Rostedt60a7ecf2008-11-05 16:05:44 -050098static inline void ftrace_stop(void) { }
99static inline void ftrace_start(void) { }
Steven Rostedt606576c2008-10-06 19:06:12 -0400100#endif /* CONFIG_FUNCTION_TRACER */
Steven Rostedt352ad252008-05-12 21:20:42 +0200101
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500102#ifdef CONFIG_STACK_TRACER
103extern int stack_tracer_enabled;
104int
105stack_trace_sysctl(struct ctl_table *table, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700106 void __user *buffer, size_t *lenp,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500107 loff_t *ppos);
108#endif
109
Steven Rostedtf6180772009-02-14 00:40:25 -0500110struct ftrace_func_command {
111 struct list_head list;
112 char *name;
113 int (*func)(char *func, char *cmd,
114 char *params, int enable);
115};
116
Steven Rostedt3d083392008-05-12 21:20:42 +0200117#ifdef CONFIG_DYNAMIC_FTRACE
Steven Rostedt31e88902008-11-14 16:21:19 -0800118
Steven Rostedt000ab692009-02-17 13:35:06 -0500119int ftrace_arch_code_modify_prepare(void);
120int ftrace_arch_code_modify_post_process(void);
121
Steven Rostedt809dcf22009-02-16 23:06:01 -0500122struct seq_file;
123
Steven Rostedtb6887d72009-02-17 12:32:04 -0500124struct ftrace_probe_ops {
Steven Rostedt59df055f2009-02-14 15:29:06 -0500125 void (*func)(unsigned long ip,
126 unsigned long parent_ip,
127 void **data);
128 int (*callback)(unsigned long ip, void **data);
129 void (*free)(void **data);
Steven Rostedt809dcf22009-02-16 23:06:01 -0500130 int (*print)(struct seq_file *m,
131 unsigned long ip,
Steven Rostedtb6887d72009-02-17 12:32:04 -0500132 struct ftrace_probe_ops *ops,
Steven Rostedt809dcf22009-02-16 23:06:01 -0500133 void *data);
Steven Rostedt59df055f2009-02-14 15:29:06 -0500134};
135
136extern int
Steven Rostedtb6887d72009-02-17 12:32:04 -0500137register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
Steven Rostedt59df055f2009-02-14 15:29:06 -0500138 void *data);
139extern void
Steven Rostedtb6887d72009-02-17 12:32:04 -0500140unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
Steven Rostedt59df055f2009-02-14 15:29:06 -0500141 void *data);
142extern void
Steven Rostedtb6887d72009-02-17 12:32:04 -0500143unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops);
144extern void unregister_ftrace_function_probe_all(char *glob);
Steven Rostedt59df055f2009-02-14 15:29:06 -0500145
Masami Hiramatsu2cfa1972010-02-02 16:49:11 -0500146extern int ftrace_text_reserved(void *start, void *end);
147
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200148enum {
Steven Rostedt37ad5082008-05-12 21:20:48 +0200149 FTRACE_FL_FREE = (1 << 0),
150 FTRACE_FL_FAILED = (1 << 1),
151 FTRACE_FL_FILTER = (1 << 2),
152 FTRACE_FL_ENABLED = (1 << 3),
Steven Rostedt41c52c02008-05-22 11:46:33 -0400153 FTRACE_FL_NOTRACE = (1 << 4),
Abhishek Sagar0eb96702008-06-01 21:47:30 +0530154 FTRACE_FL_CONVERTED = (1 << 5),
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200155};
156
Steven Rostedt3d083392008-05-12 21:20:42 +0200157struct dyn_ftrace {
Lai Jiangshanee000b72009-03-24 13:38:06 +0800158 union {
159 unsigned long ip; /* address of mcount call-site */
160 struct dyn_ftrace *freelist;
161 };
162 union {
163 unsigned long flags;
164 struct dyn_ftrace *newlist;
165 };
166 struct dyn_arch_ftrace arch;
Steven Rostedt3d083392008-05-12 21:20:42 +0200167};
168
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200169int ftrace_force_update(void);
Steven Rostedt77a2b372008-05-12 21:20:45 +0200170void ftrace_set_filter(unsigned char *buf, int len, int reset);
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200171
Steven Rostedtf6180772009-02-14 00:40:25 -0500172int register_ftrace_command(struct ftrace_func_command *cmd);
173int unregister_ftrace_command(struct ftrace_func_command *cmd);
174
Steven Rostedt3d083392008-05-12 21:20:42 +0200175/* defined in arch */
Steven Rostedt3c1720f2008-05-12 21:20:43 +0200176extern int ftrace_ip_converted(unsigned long ip);
Steven Rostedtd61f82d2008-05-12 21:20:43 +0200177extern int ftrace_dyn_arch_init(void *data);
Steven Rostedtd61f82d2008-05-12 21:20:43 +0200178extern int ftrace_update_ftrace_func(ftrace_func_t func);
179extern void ftrace_caller(void);
180extern void ftrace_call(void);
181extern void mcount_call(void);
Shaohua Lif0001202009-01-09 11:29:42 +0800182
183#ifndef FTRACE_ADDR
184#define FTRACE_ADDR ((unsigned long)ftrace_caller)
185#endif
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100186#ifdef CONFIG_FUNCTION_GRAPH_TRACER
187extern void ftrace_graph_caller(void);
Steven Rostedt5a45cfe2008-11-26 00:16:24 -0500188extern int ftrace_enable_ftrace_graph_caller(void);
189extern int ftrace_disable_ftrace_graph_caller(void);
190#else
191static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; }
192static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; }
Frederic Weisbeckere7d37372008-11-16 06:02:06 +0100193#endif
Steven Rostedtad90c0e2008-05-27 20:48:37 -0400194
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400195/**
Wenji Huang57794a92009-02-06 17:33:27 +0800196 * ftrace_make_nop - convert code into nop
Steven Rostedt31e88902008-11-14 16:21:19 -0800197 * @mod: module structure if called by module load initialization
198 * @rec: the mcount call site record
199 * @addr: the address that the call site should be calling
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400200 *
201 * This is a very sensitive operation and great care needs
202 * to be taken by the arch. The operation should carefully
203 * read the location, check to see if what is read is indeed
204 * what we expect it to be, and then on success of the compare,
205 * it should write to the location.
206 *
Steven Rostedt31e88902008-11-14 16:21:19 -0800207 * The code segment at @rec->ip should be a caller to @addr
208 *
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400209 * Return must be:
210 * 0 on success
211 * -EFAULT on error reading the location
212 * -EINVAL on a failed compare of the contents
213 * -EPERM on error writing to the location
214 * Any other value will be considered a failure.
215 */
Steven Rostedt31e88902008-11-14 16:21:19 -0800216extern int ftrace_make_nop(struct module *mod,
217 struct dyn_ftrace *rec, unsigned long addr);
218
219/**
220 * ftrace_make_call - convert a nop call site into a call to addr
221 * @rec: the mcount call site record
222 * @addr: the address that the call site should call
223 *
224 * This is a very sensitive operation and great care needs
225 * to be taken by the arch. The operation should carefully
226 * read the location, check to see if what is read is indeed
227 * what we expect it to be, and then on success of the compare,
228 * it should write to the location.
229 *
230 * The code segment at @rec->ip should be a nop
231 *
232 * Return must be:
233 * 0 on success
234 * -EFAULT on error reading the location
235 * -EINVAL on a failed compare of the contents
236 * -EPERM on error writing to the location
237 * Any other value will be considered a failure.
238 */
239extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
240
Steven Rostedt31e88902008-11-14 16:21:19 -0800241/* May be defined in arch */
242extern int ftrace_arch_read_dyn_info(char *buf, int size);
Steven Rostedt593eb8a2008-10-23 09:32:59 -0400243
Abhishek Sagarecea6562008-06-21 23:47:53 +0530244extern int skip_trace(unsigned long ip);
245
Steven Rostedtc0719e52008-09-06 01:06:03 -0400246extern void ftrace_disable_daemon(void);
247extern void ftrace_enable_daemon(void);
Steven Rostedte1c08bd2008-05-12 21:20:44 +0200248#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400249static inline int skip_trace(unsigned long ip) { return 0; }
250static inline int ftrace_force_update(void) { return 0; }
251static inline void ftrace_set_filter(unsigned char *buf, int len, int reset)
252{
253}
254static inline void ftrace_disable_daemon(void) { }
255static inline void ftrace_enable_daemon(void) { }
jolsa@redhat.come7247a12009-10-07 19:00:35 +0200256static inline void ftrace_release_mod(struct module *mod) {}
Steven Rostedtf6180772009-02-14 00:40:25 -0500257static inline int register_ftrace_command(struct ftrace_func_command *cmd)
258{
Ingo Molnar97d0bb82009-02-17 11:47:39 +0100259 return -EINVAL;
Steven Rostedtf6180772009-02-14 00:40:25 -0500260}
261static inline int unregister_ftrace_command(char *cmd_name)
262{
Ingo Molnar97d0bb82009-02-17 11:47:39 +0100263 return -EINVAL;
Steven Rostedtf6180772009-02-14 00:40:25 -0500264}
Masami Hiramatsu2cfa1972010-02-02 16:49:11 -0500265static inline int ftrace_text_reserved(void *start, void *end)
266{
267 return 0;
268}
Abhishek Sagarecea6562008-06-21 23:47:53 +0530269#endif /* CONFIG_DYNAMIC_FTRACE */
Steven Rostedt352ad252008-05-12 21:20:42 +0200270
Ingo Molnaraeaee8a2008-05-12 21:20:49 +0200271/* totally disable ftrace - can not re-enable after this */
272void ftrace_kill(void);
273
Ingo Molnarf43fdad2008-05-12 21:20:43 +0200274static inline void tracer_disable(void)
275{
Steven Rostedt606576c2008-10-06 19:06:12 -0400276#ifdef CONFIG_FUNCTION_TRACER
Ingo Molnarf43fdad2008-05-12 21:20:43 +0200277 ftrace_enabled = 0;
278#endif
279}
280
Huang Ying37002732008-08-18 16:24:56 +0800281/*
282 * Ftrace disable/restore without lock. Some synchronization mechanism
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700283 * must be used to prevent ftrace_enabled to be changed between
Huang Ying37002732008-08-18 16:24:56 +0800284 * disable/restore.
285 */
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700286static inline int __ftrace_enabled_save(void)
287{
Steven Rostedt606576c2008-10-06 19:06:12 -0400288#ifdef CONFIG_FUNCTION_TRACER
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700289 int saved_ftrace_enabled = ftrace_enabled;
290 ftrace_enabled = 0;
291 return saved_ftrace_enabled;
292#else
293 return 0;
294#endif
295}
296
297static inline void __ftrace_enabled_restore(int enabled)
298{
Steven Rostedt606576c2008-10-06 19:06:12 -0400299#ifdef CONFIG_FUNCTION_TRACER
Huang Ying9bdeb7b2008-08-15 00:40:25 -0700300 ftrace_enabled = enabled;
301#endif
302}
303
Uwe Kleine-Koenigc79a61f2009-02-27 21:30:03 +0100304#ifndef HAVE_ARCH_CALLER_ADDR
305# ifdef CONFIG_FRAME_POINTER
306# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
307# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
308# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
309# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
310# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
311# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
312# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
313# else
314# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
315# define CALLER_ADDR1 0UL
316# define CALLER_ADDR2 0UL
317# define CALLER_ADDR3 0UL
318# define CALLER_ADDR4 0UL
319# define CALLER_ADDR5 0UL
320# define CALLER_ADDR6 0UL
321# endif
322#endif /* ifndef HAVE_ARCH_CALLER_ADDR */
Steven Rostedt352ad252008-05-12 21:20:42 +0200323
Steven Rostedt81d68a92008-05-12 21:20:42 +0200324#ifdef CONFIG_IRQSOFF_TRACER
Ingo Molnar489f1392008-02-25 13:38:05 +0100325 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
326 extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200327#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400328 static inline void time_hardirqs_on(unsigned long a0, unsigned long a1) { }
329 static inline void time_hardirqs_off(unsigned long a0, unsigned long a1) { }
Steven Rostedt81d68a92008-05-12 21:20:42 +0200330#endif
331
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200332#ifdef CONFIG_PREEMPT_TRACER
Ingo Molnar489f1392008-02-25 13:38:05 +0100333 extern void trace_preempt_on(unsigned long a0, unsigned long a1);
334 extern void trace_preempt_off(unsigned long a0, unsigned long a1);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200335#else
Steven Rostedt4dbf6bc2010-05-04 11:24:01 -0400336 static inline void trace_preempt_on(unsigned long a0, unsigned long a1) { }
337 static inline void trace_preempt_off(unsigned long a0, unsigned long a1) { }
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200338#endif
339
Steven Rostedt68bf21a2008-08-14 15:45:08 -0400340#ifdef CONFIG_FTRACE_MCOUNT_RECORD
341extern void ftrace_init(void);
342#else
343static inline void ftrace_init(void) { }
344#endif
345
Frederic Weisbecker71566a02008-10-31 12:57:20 +0100346/*
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100347 * Structure that defines an entry function trace.
348 */
349struct ftrace_graph_ent {
350 unsigned long func; /* Current function */
351 int depth;
352};
Steven Rostedtdd0e5452008-08-01 12:26:41 -0400353
Frederic Weisbecker71566a02008-10-31 12:57:20 +0100354/*
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100355 * Structure that defines a return function trace.
356 */
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100357struct ftrace_graph_ret {
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100358 unsigned long func; /* Current function */
359 unsigned long long calltime;
360 unsigned long long rettime;
Frederic Weisbecker02310222008-11-17 03:22:41 +0100361 /* Number of functions that overran the depth limit for current task */
362 unsigned long overrun;
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100363 int depth;
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100364};
365
Jiri Olsa62b915f2010-04-02 19:01:22 +0200366/* Type of the callback handlers for tracing function graph*/
367typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
368typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
369
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100370#ifdef CONFIG_FUNCTION_GRAPH_TRACER
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100371
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400372/* for init task */
Tetsuo Handaf876d342009-04-08 14:05:43 +0900373#define INIT_FTRACE_GRAPH .ret_stack = NULL,
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400374
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100375/*
Steven Rostedt712406a2009-02-09 10:54:03 -0800376 * Stack of return addresses for functions
377 * of a thread.
378 * Used in struct thread_info
379 */
380struct ftrace_ret_stack {
381 unsigned long ret;
382 unsigned long func;
383 unsigned long long calltime;
Steven Rostedta2a16d62009-03-24 23:17:58 -0400384 unsigned long long subtime;
Steven Rostedt71e308a2009-06-18 12:45:08 -0400385 unsigned long fp;
Steven Rostedt712406a2009-02-09 10:54:03 -0800386};
387
388/*
389 * Primary handler of a function return.
390 * It relays on ftrace_return_to_handler.
391 * Defined in entry_32/64.S
392 */
393extern void return_to_handler(void);
394
395extern int
Steven Rostedt71e308a2009-06-18 12:45:08 -0400396ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
397 unsigned long frame_pointer);
Steven Rostedt712406a2009-02-09 10:54:03 -0800398
399/*
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100400 * Sometimes we don't want to trace a function with the function
401 * graph tracer but we want them to keep traced by the usual function
402 * tracer if the function graph tracer is not configured.
403 */
404#define __notrace_funcgraph notrace
405
Frederic Weisbeckerbcbc4f22008-12-09 23:54:20 +0100406/*
407 * We want to which function is an entrypoint of a hardirq.
408 * That will help us to put a signal on output.
409 */
410#define __irq_entry __attribute__((__section__(".irqentry.text")))
411
412/* Limits of hardirq entrypoints */
413extern char __irqentry_text_start[];
414extern char __irqentry_text_end[];
415
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100416#define FTRACE_RETFUNC_DEPTH 50
417#define FTRACE_RETSTACK_ALLOC_SIZE 32
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100418extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
419 trace_func_graph_ent_t entryfunc);
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100420
Steven Rostedt14a866c2008-12-02 23:50:02 -0500421extern void ftrace_graph_stop(void);
422
Frederic Weisbecker287b6e62008-11-26 00:57:25 +0100423/* The current handlers in use */
424extern trace_func_graph_ret_t ftrace_graph_return;
425extern trace_func_graph_ent_t ftrace_graph_entry;
426
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100427extern void unregister_ftrace_graph(void);
Frederic Weisbeckerf201ae22008-11-23 06:22:56 +0100428
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100429extern void ftrace_graph_init_task(struct task_struct *t);
430extern void ftrace_graph_exit_task(struct task_struct *t);
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100431
432static inline int task_curr_ret_stack(struct task_struct *t)
433{
434 return t->curr_ret_stack;
435}
Frederic Weisbecker380c4b12008-12-06 03:43:41 +0100436
437static inline void pause_graph_tracing(void)
438{
439 atomic_inc(&current->tracing_graph_pause);
440}
441
442static inline void unpause_graph_tracing(void)
443{
444 atomic_dec(&current->tracing_graph_pause);
445}
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400446#else /* !CONFIG_FUNCTION_GRAPH_TRACER */
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100447
448#define __notrace_funcgraph
Frederic Weisbeckerbcbc4f22008-12-09 23:54:20 +0100449#define __irq_entry
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400450#define INIT_FTRACE_GRAPH
Frederic Weisbecker8b96f012008-12-06 03:40:00 +0100451
Frederic Weisbeckerfb526072008-11-25 21:07:04 +0100452static inline void ftrace_graph_init_task(struct task_struct *t) { }
453static inline void ftrace_graph_exit_task(struct task_struct *t) { }
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100454
Jiri Olsa62b915f2010-04-02 19:01:22 +0200455static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc,
456 trace_func_graph_ent_t entryfunc)
457{
458 return -1;
459}
460static inline void unregister_ftrace_graph(void) { }
461
Frederic Weisbecker21a8c462008-12-04 23:51:23 +0100462static inline int task_curr_ret_stack(struct task_struct *tsk)
463{
464 return -1;
465}
Frederic Weisbecker380c4b12008-12-06 03:43:41 +0100466
467static inline void pause_graph_tracing(void) { }
468static inline void unpause_graph_tracing(void) { }
Steven Rostedt5ac9f622009-03-25 20:55:00 -0400469#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
Frederic Weisbeckercaf4b322008-11-11 07:03:45 +0100470
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500471#ifdef CONFIG_TRACING
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500472
473/* flags for current->trace */
474enum {
475 TSK_TRACE_FL_TRACE_BIT = 0,
476 TSK_TRACE_FL_GRAPH_BIT = 1,
477};
478enum {
479 TSK_TRACE_FL_TRACE = 1 << TSK_TRACE_FL_TRACE_BIT,
480 TSK_TRACE_FL_GRAPH = 1 << TSK_TRACE_FL_GRAPH_BIT,
481};
482
483static inline void set_tsk_trace_trace(struct task_struct *tsk)
484{
485 set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
486}
487
488static inline void clear_tsk_trace_trace(struct task_struct *tsk)
489{
490 clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
491}
492
493static inline int test_tsk_trace_trace(struct task_struct *tsk)
494{
495 return tsk->trace & TSK_TRACE_FL_TRACE;
496}
497
498static inline void set_tsk_trace_graph(struct task_struct *tsk)
499{
500 set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
501}
502
503static inline void clear_tsk_trace_graph(struct task_struct *tsk)
504{
505 clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
506}
507
508static inline int test_tsk_trace_graph(struct task_struct *tsk)
509{
510 return tsk->trace & TSK_TRACE_FL_GRAPH;
511}
512
Frederic Weisbeckercecbca92010-04-18 19:08:41 +0200513enum ftrace_dump_mode;
514
515extern enum ftrace_dump_mode ftrace_dump_on_oops;
Ingo Molnar526211b2009-03-05 10:28:45 +0100516
Steven Rostedt261842b2009-04-16 21:41:52 -0400517#ifdef CONFIG_PREEMPT
518#define INIT_TRACE_RECURSION .trace_recursion = 0,
519#endif
520
Steven Rostedtea4e2bc2008-12-03 15:36:57 -0500521#endif /* CONFIG_TRACING */
522
Steven Rostedt261842b2009-04-16 21:41:52 -0400523#ifndef INIT_TRACE_RECURSION
524#define INIT_TRACE_RECURSION
525#endif
Markus Metzgerb1818742009-01-19 10:31:01 +0100526
Mike Frysingere7b8e672010-01-26 04:40:03 -0500527#ifdef CONFIG_FTRACE_SYSCALLS
528
529unsigned long arch_syscall_addr(int nr);
530
531#endif /* CONFIG_FTRACE_SYSCALLS */
532
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +0200533#endif /* _LINUX_FTRACE_H */