1 #ifndef _LINUX_FTRACE_H
2 #define _LINUX_FTRACE_H
6 #include <linux/linkage.h>
8 #include <linux/init.h>
9 #include <linux/types.h>
11 extern int ftrace_enabled;
13 ftrace_enable_sysctl(struct ctl_table *table, int write,
14 struct file *filp, void __user *buffer, size_t *lenp,
17 typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
21 struct ftrace_ops *next;
25 * The ftrace_ops must be a static and should also
26 * be read_mostly. These functions do modify read_mostly variables
27 * so use them sparely. Never free an ftrace_op or modify the
28 * next pointer after it has been registered. Even after unregistering
29 * it, the next pointer may still be used internally.
31 int register_ftrace_function(struct ftrace_ops *ops);
32 int unregister_ftrace_function(struct ftrace_ops *ops);
33 void clear_ftrace_function(void);
35 extern void ftrace_stub(unsigned long a0, unsigned long a1);
37 #else /* !CONFIG_FTRACE */
38 # define register_ftrace_function(ops) do { } while (0)
39 # define unregister_ftrace_function(ops) do { } while (0)
40 # define clear_ftrace_function(ops) do { } while (0)
41 static inline void ftrace_kill_atomic(void) { }
42 #endif /* CONFIG_FTRACE */
44 #ifdef CONFIG_DYNAMIC_FTRACE
45 # define FTRACE_HASHBITS 10
46 # define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS)
49 FTRACE_FL_FREE = (1 << 0),
50 FTRACE_FL_FAILED = (1 << 1),
51 FTRACE_FL_FILTER = (1 << 2),
52 FTRACE_FL_ENABLED = (1 << 3),
53 FTRACE_FL_NOTRACE = (1 << 4),
54 FTRACE_FL_CONVERTED = (1 << 5),
55 FTRACE_FL_FROZEN = (1 << 6),
59 struct hlist_node node;
60 unsigned long ip; /* address of mcount call-site */
64 int ftrace_force_update(void);
65 void ftrace_set_filter(unsigned char *buf, int len, int reset);
68 extern int ftrace_ip_converted(unsigned long ip);
69 extern unsigned char *ftrace_nop_replace(void);
70 extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
71 extern int ftrace_dyn_arch_init(void *data);
72 extern int ftrace_mcount_set(unsigned long *data);
73 extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
74 unsigned char *new_code);
75 extern int ftrace_update_ftrace_func(ftrace_func_t func);
76 extern void ftrace_caller(void);
77 extern void ftrace_call(void);
78 extern void mcount_call(void);
80 extern int skip_trace(unsigned long ip);
82 extern void ftrace_release(void *start, unsigned long size);
84 extern void ftrace_disable_daemon(void);
85 extern void ftrace_enable_daemon(void);
88 # define skip_trace(ip) ({ 0; })
89 # define ftrace_force_update() ({ 0; })
90 # define ftrace_set_filter(buf, len, reset) do { } while (0)
91 # define ftrace_disable_daemon() do { } while (0)
92 # define ftrace_enable_daemon() do { } while (0)
93 static inline void ftrace_release(void *start, unsigned long size) { }
94 #endif /* CONFIG_DYNAMIC_FTRACE */
96 /* totally disable ftrace - can not re-enable after this */
97 void ftrace_kill(void);
98 void ftrace_kill_atomic(void);
100 static inline void tracer_disable(void)
108 * Ftrace disable/restore without lock. Some synchronization mechanism
109 * must be used to prevent ftrace_enabled to be changed between
112 static inline int __ftrace_enabled_save(void)
115 int saved_ftrace_enabled = ftrace_enabled;
117 return saved_ftrace_enabled;
123 static inline void __ftrace_enabled_restore(int enabled)
126 ftrace_enabled = enabled;
130 #ifdef CONFIG_FRAME_POINTER
131 /* TODO: need to fix this for ARM */
132 # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
133 # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
134 # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
135 # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
136 # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
137 # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
138 # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
140 # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
141 # define CALLER_ADDR1 0UL
142 # define CALLER_ADDR2 0UL
143 # define CALLER_ADDR3 0UL
144 # define CALLER_ADDR4 0UL
145 # define CALLER_ADDR5 0UL
146 # define CALLER_ADDR6 0UL
149 #ifdef CONFIG_IRQSOFF_TRACER
150 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
151 extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
153 # define time_hardirqs_on(a0, a1) do { } while (0)
154 # define time_hardirqs_off(a0, a1) do { } while (0)
157 #ifdef CONFIG_PREEMPT_TRACER
158 extern void trace_preempt_on(unsigned long a0, unsigned long a1);
159 extern void trace_preempt_off(unsigned long a0, unsigned long a1);
161 # define trace_preempt_on(a0, a1) do { } while (0)
162 # define trace_preempt_off(a0, a1) do { } while (0)
165 #ifdef CONFIG_TRACING
167 ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
170 * ftrace_printk - printf formatting in the ftrace buffer
171 * @fmt: the printf format for printing
173 * Note: __ftrace_printk is an internal function for ftrace_printk and
174 * the @ip is passed in via the ftrace_printk macro.
176 * This function allows a kernel developer to debug fast path sections
177 * that printk is not appropriate for. By scattering in various
178 * printk like tracing in the code, a developer can quickly see
179 * where problems are occurring.
181 * This is intended as a debugging tool for the developer only.
182 * Please refrain from leaving ftrace_printks scattered around in
185 # define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt)
187 __ftrace_printk(unsigned long ip, const char *fmt, ...)
188 __attribute__ ((format (printf, 2, 3)));
189 extern void ftrace_dump(void);
192 ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
194 ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)));
197 ftrace_printk(const char *fmt, ...)
201 static inline void ftrace_dump(void) { }
204 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
205 extern void ftrace_init(void);
206 extern void ftrace_init_module(unsigned long *start, unsigned long *end);
208 static inline void ftrace_init(void) { }
210 ftrace_init_module(unsigned long *start, unsigned long *end) { }
218 unsigned long long duration;
221 #ifdef CONFIG_BOOT_TRACER
222 extern void trace_boot(struct boot_trace *it);
223 extern void start_boot_trace(void);
225 static inline void trace_boot(struct boot_trace *it) { }
226 static inline void start_boot_trace(void) { }
231 #endif /* _LINUX_FTRACE_H */