e4202881fb003843fbb98a5d957df8a052e195d7
[platform/adaptation/renesas_rcar/renesas_kernel.git] / include / linux / ftrace.h
1 /*
2  * Ftrace header.  For implementation details beyond the random comments
3  * scattered below, see: Documentation/trace/ftrace-design.txt
4  */
5
6 #ifndef _LINUX_FTRACE_H
7 #define _LINUX_FTRACE_H
8
9 #include <linux/trace_clock.h>
10 #include <linux/kallsyms.h>
11 #include <linux/linkage.h>
12 #include <linux/bitops.h>
13 #include <linux/ptrace.h>
14 #include <linux/ktime.h>
15 #include <linux/sched.h>
16 #include <linux/types.h>
17 #include <linux/init.h>
18 #include <linux/fs.h>
19
20 #include <asm/ftrace.h>
21
22 /*
23  * If the arch supports passing the variable contents of
24  * function_trace_op as the third parameter back from the
25  * mcount call, then the arch should define this as 1.
26  */
27 #ifndef ARCH_SUPPORTS_FTRACE_OPS
28 #define ARCH_SUPPORTS_FTRACE_OPS 0
29 #endif
30
31 /*
32  * If the arch's mcount caller does not support all of ftrace's
33  * features, then it must call an indirect function that
34  * does. Or at least does enough to prevent any unwelcomed side effects.
35  */
36 #if !defined(CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST) || \
37         !ARCH_SUPPORTS_FTRACE_OPS
38 # define FTRACE_FORCE_LIST_FUNC 1
39 #else
40 # define FTRACE_FORCE_LIST_FUNC 0
41 #endif
42
43
44 struct module;
45 struct ftrace_hash;
46
47 #ifdef CONFIG_FUNCTION_TRACER
48
49 extern int ftrace_enabled;
50 extern int
51 ftrace_enable_sysctl(struct ctl_table *table, int write,
52                      void __user *buffer, size_t *lenp,
53                      loff_t *ppos);
54
55 struct ftrace_ops;
56
57 typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip,
58                               struct ftrace_ops *op, struct pt_regs *regs);
59
60 /*
61  * FTRACE_OPS_FL_* bits denote the state of ftrace_ops struct and are
62  * set in the flags member.
63  *
64  * ENABLED - set/unset when ftrace_ops is registered/unregistered
65  * GLOBAL  - set manualy by ftrace_ops user to denote the ftrace_ops
66  *           is part of the global tracers sharing the same filter
67  *           via set_ftrace_* debugfs files.
68  * DYNAMIC - set when ftrace_ops is registered to denote dynamically
69  *           allocated ftrace_ops which need special care
70  * CONTROL - set manualy by ftrace_ops user to denote the ftrace_ops
71  *           could be controled by following calls:
72  *             ftrace_function_local_enable
73  *             ftrace_function_local_disable
74  */
75 enum {
76         FTRACE_OPS_FL_ENABLED           = 1 << 0,
77         FTRACE_OPS_FL_GLOBAL            = 1 << 1,
78         FTRACE_OPS_FL_DYNAMIC           = 1 << 2,
79         FTRACE_OPS_FL_CONTROL           = 1 << 3,
80 };
81
82 struct ftrace_ops {
83         ftrace_func_t                   func;
84         struct ftrace_ops               *next;
85         unsigned long                   flags;
86         int __percpu                    *disabled;
87 #ifdef CONFIG_DYNAMIC_FTRACE
88         struct ftrace_hash              *notrace_hash;
89         struct ftrace_hash              *filter_hash;
90 #endif
91 };
92
93 extern int function_trace_stop;
94
95 /*
96  * Type of the current tracing.
97  */
98 enum ftrace_tracing_type_t {
99         FTRACE_TYPE_ENTER = 0, /* Hook the call of the function */
100         FTRACE_TYPE_RETURN,     /* Hook the return of the function */
101 };
102
103 /* Current tracing type, default is FTRACE_TYPE_ENTER */
104 extern enum ftrace_tracing_type_t ftrace_tracing_type;
105
106 /**
107  * ftrace_stop - stop function tracer.
108  *
109  * A quick way to stop the function tracer. Note this an on off switch,
110  * it is not something that is recursive like preempt_disable.
111  * This does not disable the calling of mcount, it only stops the
112  * calling of functions from mcount.
113  */
114 static inline void ftrace_stop(void)
115 {
116         function_trace_stop = 1;
117 }
118
119 /**
120  * ftrace_start - start the function tracer.
121  *
122  * This function is the inverse of ftrace_stop. This does not enable
123  * the function tracing if the function tracer is disabled. This only
124  * sets the function tracer flag to continue calling the functions
125  * from mcount.
126  */
127 static inline void ftrace_start(void)
128 {
129         function_trace_stop = 0;
130 }
131
132 /*
133  * The ftrace_ops must be a static and should also
134  * be read_mostly.  These functions do modify read_mostly variables
135  * so use them sparely. Never free an ftrace_op or modify the
136  * next pointer after it has been registered. Even after unregistering
137  * it, the next pointer may still be used internally.
138  */
139 int register_ftrace_function(struct ftrace_ops *ops);
140 int unregister_ftrace_function(struct ftrace_ops *ops);
141 void clear_ftrace_function(void);
142
143 /**
144  * ftrace_function_local_enable - enable controlled ftrace_ops on current cpu
145  *
146  * This function enables tracing on current cpu by decreasing
147  * the per cpu control variable.
148  * It must be called with preemption disabled and only on ftrace_ops
149  * registered with FTRACE_OPS_FL_CONTROL. If called without preemption
150  * disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
151  */
152 static inline void ftrace_function_local_enable(struct ftrace_ops *ops)
153 {
154         if (WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_CONTROL)))
155                 return;
156
157         (*this_cpu_ptr(ops->disabled))--;
158 }
159
160 /**
161  * ftrace_function_local_disable - enable controlled ftrace_ops on current cpu
162  *
163  * This function enables tracing on current cpu by decreasing
164  * the per cpu control variable.
165  * It must be called with preemption disabled and only on ftrace_ops
166  * registered with FTRACE_OPS_FL_CONTROL. If called without preemption
167  * disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
168  */
169 static inline void ftrace_function_local_disable(struct ftrace_ops *ops)
170 {
171         if (WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_CONTROL)))
172                 return;
173
174         (*this_cpu_ptr(ops->disabled))++;
175 }
176
177 /**
178  * ftrace_function_local_disabled - returns ftrace_ops disabled value
179  *                                  on current cpu
180  *
181  * This function returns value of ftrace_ops::disabled on current cpu.
182  * It must be called with preemption disabled and only on ftrace_ops
183  * registered with FTRACE_OPS_FL_CONTROL. If called without preemption
184  * disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
185  */
186 static inline int ftrace_function_local_disabled(struct ftrace_ops *ops)
187 {
188         WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_CONTROL));
189         return *this_cpu_ptr(ops->disabled);
190 }
191
192 extern void ftrace_stub(unsigned long a0, unsigned long a1,
193                         struct ftrace_ops *op, struct pt_regs *regs);
194
195 #else /* !CONFIG_FUNCTION_TRACER */
196 /*
197  * (un)register_ftrace_function must be a macro since the ops parameter
198  * must not be evaluated.
199  */
200 #define register_ftrace_function(ops) ({ 0; })
201 #define unregister_ftrace_function(ops) ({ 0; })
202 static inline void clear_ftrace_function(void) { }
203 static inline void ftrace_kill(void) { }
204 static inline void ftrace_stop(void) { }
205 static inline void ftrace_start(void) { }
206 #endif /* CONFIG_FUNCTION_TRACER */
207
208 #ifdef CONFIG_STACK_TRACER
209 extern int stack_tracer_enabled;
210 int
211 stack_trace_sysctl(struct ctl_table *table, int write,
212                    void __user *buffer, size_t *lenp,
213                    loff_t *ppos);
214 #endif
215
216 struct ftrace_func_command {
217         struct list_head        list;
218         char                    *name;
219         int                     (*func)(struct ftrace_hash *hash,
220                                         char *func, char *cmd,
221                                         char *params, int enable);
222 };
223
224 #ifdef CONFIG_DYNAMIC_FTRACE
225
226 int ftrace_arch_code_modify_prepare(void);
227 int ftrace_arch_code_modify_post_process(void);
228
229 void ftrace_bug(int err, unsigned long ip);
230
231 struct seq_file;
232
233 struct ftrace_probe_ops {
234         void                    (*func)(unsigned long ip,
235                                         unsigned long parent_ip,
236                                         void **data);
237         int                     (*callback)(unsigned long ip, void **data);
238         void                    (*free)(void **data);
239         int                     (*print)(struct seq_file *m,
240                                          unsigned long ip,
241                                          struct ftrace_probe_ops *ops,
242                                          void *data);
243 };
244
245 extern int
246 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
247                               void *data);
248 extern void
249 unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
250                                 void *data);
251 extern void
252 unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops);
253 extern void unregister_ftrace_function_probe_all(char *glob);
254
255 extern int ftrace_text_reserved(void *start, void *end);
256
257 enum {
258         FTRACE_FL_ENABLED       = (1 << 30),
259 };
260
261 #define FTRACE_FL_MASK          (0x3UL << 30)
262 #define FTRACE_REF_MAX          ((1 << 30) - 1)
263
264 struct dyn_ftrace {
265         union {
266                 unsigned long           ip; /* address of mcount call-site */
267                 struct dyn_ftrace       *freelist;
268         };
269         unsigned long           flags;
270         struct dyn_arch_ftrace          arch;
271 };
272
273 int ftrace_force_update(void);
274 int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
275                        int len, int reset);
276 int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
277                         int len, int reset);
278 void ftrace_set_global_filter(unsigned char *buf, int len, int reset);
279 void ftrace_set_global_notrace(unsigned char *buf, int len, int reset);
280 void ftrace_free_filter(struct ftrace_ops *ops);
281
282 int register_ftrace_command(struct ftrace_func_command *cmd);
283 int unregister_ftrace_command(struct ftrace_func_command *cmd);
284
285 enum {
286         FTRACE_UPDATE_CALLS             = (1 << 0),
287         FTRACE_DISABLE_CALLS            = (1 << 1),
288         FTRACE_UPDATE_TRACE_FUNC        = (1 << 2),
289         FTRACE_START_FUNC_RET           = (1 << 3),
290         FTRACE_STOP_FUNC_RET            = (1 << 4),
291 };
292
293 enum {
294         FTRACE_UPDATE_IGNORE,
295         FTRACE_UPDATE_MAKE_CALL,
296         FTRACE_UPDATE_MAKE_NOP,
297 };
298
299 enum {
300         FTRACE_ITER_FILTER      = (1 << 0),
301         FTRACE_ITER_NOTRACE     = (1 << 1),
302         FTRACE_ITER_PRINTALL    = (1 << 2),
303         FTRACE_ITER_DO_HASH     = (1 << 3),
304         FTRACE_ITER_HASH        = (1 << 4),
305         FTRACE_ITER_ENABLED     = (1 << 5),
306 };
307
308 void arch_ftrace_update_code(int command);
309
310 struct ftrace_rec_iter;
311
312 struct ftrace_rec_iter *ftrace_rec_iter_start(void);
313 struct ftrace_rec_iter *ftrace_rec_iter_next(struct ftrace_rec_iter *iter);
314 struct dyn_ftrace *ftrace_rec_iter_record(struct ftrace_rec_iter *iter);
315
316 #define for_ftrace_rec_iter(iter)               \
317         for (iter = ftrace_rec_iter_start();    \
318              iter;                              \
319              iter = ftrace_rec_iter_next(iter))
320
321
322 int ftrace_update_record(struct dyn_ftrace *rec, int enable);
323 int ftrace_test_record(struct dyn_ftrace *rec, int enable);
324 void ftrace_run_stop_machine(int command);
325 unsigned long ftrace_location(unsigned long ip);
326
327 extern ftrace_func_t ftrace_trace_function;
328
329 int ftrace_regex_open(struct ftrace_ops *ops, int flag,
330                   struct inode *inode, struct file *file);
331 ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
332                             size_t cnt, loff_t *ppos);
333 ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
334                              size_t cnt, loff_t *ppos);
335 loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int origin);
336 int ftrace_regex_release(struct inode *inode, struct file *file);
337
338 void __init
339 ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);
340
341 /* defined in arch */
342 extern int ftrace_ip_converted(unsigned long ip);
343 extern int ftrace_dyn_arch_init(void *data);
344 extern void ftrace_replace_code(int enable);
345 extern int ftrace_update_ftrace_func(ftrace_func_t func);
346 extern void ftrace_caller(void);
347 extern void ftrace_call(void);
348 extern void mcount_call(void);
349
350 void ftrace_modify_all_code(int command);
351
352 #ifndef FTRACE_ADDR
353 #define FTRACE_ADDR ((unsigned long)ftrace_caller)
354 #endif
355 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
356 extern void ftrace_graph_caller(void);
357 extern int ftrace_enable_ftrace_graph_caller(void);
358 extern int ftrace_disable_ftrace_graph_caller(void);
359 #else
360 static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; }
361 static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; }
362 #endif
363
364 /**
365  * ftrace_make_nop - convert code into nop
366  * @mod: module structure if called by module load initialization
367  * @rec: the mcount call site record
368  * @addr: the address that the call site should be calling
369  *
370  * This is a very sensitive operation and great care needs
371  * to be taken by the arch.  The operation should carefully
372  * read the location, check to see if what is read is indeed
373  * what we expect it to be, and then on success of the compare,
374  * it should write to the location.
375  *
376  * The code segment at @rec->ip should be a caller to @addr
377  *
378  * Return must be:
379  *  0 on success
380  *  -EFAULT on error reading the location
381  *  -EINVAL on a failed compare of the contents
382  *  -EPERM  on error writing to the location
383  * Any other value will be considered a failure.
384  */
385 extern int ftrace_make_nop(struct module *mod,
386                            struct dyn_ftrace *rec, unsigned long addr);
387
388 /**
389  * ftrace_make_call - convert a nop call site into a call to addr
390  * @rec: the mcount call site record
391  * @addr: the address that the call site should call
392  *
393  * This is a very sensitive operation and great care needs
394  * to be taken by the arch.  The operation should carefully
395  * read the location, check to see if what is read is indeed
396  * what we expect it to be, and then on success of the compare,
397  * it should write to the location.
398  *
399  * The code segment at @rec->ip should be a nop
400  *
401  * Return must be:
402  *  0 on success
403  *  -EFAULT on error reading the location
404  *  -EINVAL on a failed compare of the contents
405  *  -EPERM  on error writing to the location
406  * Any other value will be considered a failure.
407  */
408 extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
409
410 /* May be defined in arch */
411 extern int ftrace_arch_read_dyn_info(char *buf, int size);
412
413 extern int skip_trace(unsigned long ip);
414
415 extern void ftrace_disable_daemon(void);
416 extern void ftrace_enable_daemon(void);
417 #else
418 static inline int skip_trace(unsigned long ip) { return 0; }
419 static inline int ftrace_force_update(void) { return 0; }
420 static inline void ftrace_disable_daemon(void) { }
421 static inline void ftrace_enable_daemon(void) { }
422 static inline void ftrace_release_mod(struct module *mod) {}
423 static inline int register_ftrace_command(struct ftrace_func_command *cmd)
424 {
425         return -EINVAL;
426 }
427 static inline int unregister_ftrace_command(char *cmd_name)
428 {
429         return -EINVAL;
430 }
431 static inline int ftrace_text_reserved(void *start, void *end)
432 {
433         return 0;
434 }
435
436 /*
437  * Again users of functions that have ftrace_ops may not
438  * have them defined when ftrace is not enabled, but these
439  * functions may still be called. Use a macro instead of inline.
440  */
441 #define ftrace_regex_open(ops, flag, inod, file) ({ -ENODEV; })
442 #define ftrace_set_early_filter(ops, buf, enable) do { } while (0)
443 #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; })
444 #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; })
445 #define ftrace_free_filter(ops) do { } while (0)
446
447 static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
448                             size_t cnt, loff_t *ppos) { return -ENODEV; }
449 static inline ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
450                              size_t cnt, loff_t *ppos) { return -ENODEV; }
451 static inline loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int origin)
452 {
453         return -ENODEV;
454 }
455 static inline int
456 ftrace_regex_release(struct inode *inode, struct file *file) { return -ENODEV; }
457 #endif /* CONFIG_DYNAMIC_FTRACE */
458
459 /* totally disable ftrace - can not re-enable after this */
460 void ftrace_kill(void);
461
462 static inline void tracer_disable(void)
463 {
464 #ifdef CONFIG_FUNCTION_TRACER
465         ftrace_enabled = 0;
466 #endif
467 }
468
469 /*
470  * Ftrace disable/restore without lock. Some synchronization mechanism
471  * must be used to prevent ftrace_enabled to be changed between
472  * disable/restore.
473  */
474 static inline int __ftrace_enabled_save(void)
475 {
476 #ifdef CONFIG_FUNCTION_TRACER
477         int saved_ftrace_enabled = ftrace_enabled;
478         ftrace_enabled = 0;
479         return saved_ftrace_enabled;
480 #else
481         return 0;
482 #endif
483 }
484
485 static inline void __ftrace_enabled_restore(int enabled)
486 {
487 #ifdef CONFIG_FUNCTION_TRACER
488         ftrace_enabled = enabled;
489 #endif
490 }
491
492 #ifndef HAVE_ARCH_CALLER_ADDR
493 # ifdef CONFIG_FRAME_POINTER
494 #  define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
495 #  define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
496 #  define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
497 #  define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
498 #  define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
499 #  define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
500 #  define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
501 # else
502 #  define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
503 #  define CALLER_ADDR1 0UL
504 #  define CALLER_ADDR2 0UL
505 #  define CALLER_ADDR3 0UL
506 #  define CALLER_ADDR4 0UL
507 #  define CALLER_ADDR5 0UL
508 #  define CALLER_ADDR6 0UL
509 # endif
510 #endif /* ifndef HAVE_ARCH_CALLER_ADDR */
511
512 #ifdef CONFIG_IRQSOFF_TRACER
513   extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
514   extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
515 #else
516   static inline void time_hardirqs_on(unsigned long a0, unsigned long a1) { }
517   static inline void time_hardirqs_off(unsigned long a0, unsigned long a1) { }
518 #endif
519
520 #ifdef CONFIG_PREEMPT_TRACER
521   extern void trace_preempt_on(unsigned long a0, unsigned long a1);
522   extern void trace_preempt_off(unsigned long a0, unsigned long a1);
523 #else
524 /*
525  * Use defines instead of static inlines because some arches will make code out
526  * of the CALLER_ADDR, when we really want these to be a real nop.
527  */
528 # define trace_preempt_on(a0, a1) do { } while (0)
529 # define trace_preempt_off(a0, a1) do { } while (0)
530 #endif
531
532 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
533 extern void ftrace_init(void);
534 #else
535 static inline void ftrace_init(void) { }
536 #endif
537
538 /*
539  * Structure that defines an entry function trace.
540  */
541 struct ftrace_graph_ent {
542         unsigned long func; /* Current function */
543         int depth;
544 };
545
546 /*
547  * Structure that defines a return function trace.
548  */
549 struct ftrace_graph_ret {
550         unsigned long func; /* Current function */
551         unsigned long long calltime;
552         unsigned long long rettime;
553         /* Number of functions that overran the depth limit for current task */
554         unsigned long overrun;
555         int depth;
556 };
557
558 /* Type of the callback handlers for tracing function graph*/
559 typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
560 typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
561
562 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
563
564 /* for init task */
565 #define INIT_FTRACE_GRAPH               .ret_stack = NULL,
566
567 /*
568  * Stack of return addresses for functions
569  * of a thread.
570  * Used in struct thread_info
571  */
572 struct ftrace_ret_stack {
573         unsigned long ret;
574         unsigned long func;
575         unsigned long long calltime;
576         unsigned long long subtime;
577         unsigned long fp;
578 };
579
580 /*
581  * Primary handler of a function return.
582  * It relays on ftrace_return_to_handler.
583  * Defined in entry_32/64.S
584  */
585 extern void return_to_handler(void);
586
587 extern int
588 ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
589                          unsigned long frame_pointer);
590
591 /*
592  * Sometimes we don't want to trace a function with the function
593  * graph tracer but we want them to keep traced by the usual function
594  * tracer if the function graph tracer is not configured.
595  */
596 #define __notrace_funcgraph             notrace
597
598 /*
599  * We want to which function is an entrypoint of a hardirq.
600  * That will help us to put a signal on output.
601  */
602 #define __irq_entry              __attribute__((__section__(".irqentry.text")))
603
604 /* Limits of hardirq entrypoints */
605 extern char __irqentry_text_start[];
606 extern char __irqentry_text_end[];
607
608 #define FTRACE_RETFUNC_DEPTH 50
609 #define FTRACE_RETSTACK_ALLOC_SIZE 32
610 extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
611                                 trace_func_graph_ent_t entryfunc);
612
613 extern void ftrace_graph_stop(void);
614
615 /* The current handlers in use */
616 extern trace_func_graph_ret_t ftrace_graph_return;
617 extern trace_func_graph_ent_t ftrace_graph_entry;
618
619 extern void unregister_ftrace_graph(void);
620
621 extern void ftrace_graph_init_task(struct task_struct *t);
622 extern void ftrace_graph_exit_task(struct task_struct *t);
623 extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu);
624
625 static inline int task_curr_ret_stack(struct task_struct *t)
626 {
627         return t->curr_ret_stack;
628 }
629
630 static inline void pause_graph_tracing(void)
631 {
632         atomic_inc(&current->tracing_graph_pause);
633 }
634
635 static inline void unpause_graph_tracing(void)
636 {
637         atomic_dec(&current->tracing_graph_pause);
638 }
639 #else /* !CONFIG_FUNCTION_GRAPH_TRACER */
640
641 #define __notrace_funcgraph
642 #define __irq_entry
643 #define INIT_FTRACE_GRAPH
644
645 static inline void ftrace_graph_init_task(struct task_struct *t) { }
646 static inline void ftrace_graph_exit_task(struct task_struct *t) { }
647 static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { }
648
649 static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc,
650                           trace_func_graph_ent_t entryfunc)
651 {
652         return -1;
653 }
654 static inline void unregister_ftrace_graph(void) { }
655
656 static inline int task_curr_ret_stack(struct task_struct *tsk)
657 {
658         return -1;
659 }
660
661 static inline void pause_graph_tracing(void) { }
662 static inline void unpause_graph_tracing(void) { }
663 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
664
665 #ifdef CONFIG_TRACING
666
667 /* flags for current->trace */
668 enum {
669         TSK_TRACE_FL_TRACE_BIT  = 0,
670         TSK_TRACE_FL_GRAPH_BIT  = 1,
671 };
672 enum {
673         TSK_TRACE_FL_TRACE      = 1 << TSK_TRACE_FL_TRACE_BIT,
674         TSK_TRACE_FL_GRAPH      = 1 << TSK_TRACE_FL_GRAPH_BIT,
675 };
676
677 static inline void set_tsk_trace_trace(struct task_struct *tsk)
678 {
679         set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
680 }
681
682 static inline void clear_tsk_trace_trace(struct task_struct *tsk)
683 {
684         clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
685 }
686
687 static inline int test_tsk_trace_trace(struct task_struct *tsk)
688 {
689         return tsk->trace & TSK_TRACE_FL_TRACE;
690 }
691
692 static inline void set_tsk_trace_graph(struct task_struct *tsk)
693 {
694         set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
695 }
696
697 static inline void clear_tsk_trace_graph(struct task_struct *tsk)
698 {
699         clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
700 }
701
702 static inline int test_tsk_trace_graph(struct task_struct *tsk)
703 {
704         return tsk->trace & TSK_TRACE_FL_GRAPH;
705 }
706
707 enum ftrace_dump_mode;
708
709 extern enum ftrace_dump_mode ftrace_dump_on_oops;
710
711 #ifdef CONFIG_PREEMPT
712 #define INIT_TRACE_RECURSION            .trace_recursion = 0,
713 #endif
714
715 #endif /* CONFIG_TRACING */
716
717 #ifndef INIT_TRACE_RECURSION
718 #define INIT_TRACE_RECURSION
719 #endif
720
721 #ifdef CONFIG_FTRACE_SYSCALLS
722
723 unsigned long arch_syscall_addr(int nr);
724
725 #endif /* CONFIG_FTRACE_SYSCALLS */
726
727 #endif /* _LINUX_FTRACE_H */