diff options
Diffstat (limited to 'include/linux/ftrace.h')
-rw-r--r-- | include/linux/ftrace.h | 101 |
1 files changed, 97 insertions, 4 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index f368d041e02d..a3d46151be19 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
@@ -1,10 +1,14 @@ | |||
1 | #ifndef _LINUX_FTRACE_H | 1 | #ifndef _LINUX_FTRACE_H |
2 | #define _LINUX_FTRACE_H | 2 | #define _LINUX_FTRACE_H |
3 | 3 | ||
4 | #ifdef CONFIG_FTRACE | ||
5 | |||
6 | #include <linux/linkage.h> | 4 | #include <linux/linkage.h> |
7 | #include <linux/fs.h> | 5 | #include <linux/fs.h> |
6 | #include <linux/ktime.h> | ||
7 | #include <linux/init.h> | ||
8 | #include <linux/types.h> | ||
9 | #include <linux/kallsyms.h> | ||
10 | |||
11 | #ifdef CONFIG_FTRACE | ||
8 | 12 | ||
9 | extern int ftrace_enabled; | 13 | extern int ftrace_enabled; |
10 | extern int | 14 | extern int |
@@ -36,6 +40,7 @@ extern void ftrace_stub(unsigned long a0, unsigned long a1); | |||
36 | # define register_ftrace_function(ops) do { } while (0) | 40 | # define register_ftrace_function(ops) do { } while (0) |
37 | # define unregister_ftrace_function(ops) do { } while (0) | 41 | # define unregister_ftrace_function(ops) do { } while (0) |
38 | # define clear_ftrace_function(ops) do { } while (0) | 42 | # define clear_ftrace_function(ops) do { } while (0) |
43 | static inline void ftrace_kill_atomic(void) { } | ||
39 | #endif /* CONFIG_FTRACE */ | 44 | #endif /* CONFIG_FTRACE */ |
40 | 45 | ||
41 | #ifdef CONFIG_DYNAMIC_FTRACE | 46 | #ifdef CONFIG_DYNAMIC_FTRACE |
@@ -76,8 +81,10 @@ extern void mcount_call(void); | |||
76 | 81 | ||
77 | extern int skip_trace(unsigned long ip); | 82 | extern int skip_trace(unsigned long ip); |
78 | 83 | ||
79 | void ftrace_disable_daemon(void); | 84 | extern void ftrace_release(void *start, unsigned long size); |
80 | void ftrace_enable_daemon(void); | 85 | |
86 | extern void ftrace_disable_daemon(void); | ||
87 | extern void ftrace_enable_daemon(void); | ||
81 | 88 | ||
82 | #else | 89 | #else |
83 | # define skip_trace(ip) ({ 0; }) | 90 | # define skip_trace(ip) ({ 0; }) |
@@ -85,6 +92,7 @@ void ftrace_enable_daemon(void); | |||
85 | # define ftrace_set_filter(buf, len, reset) do { } while (0) | 92 | # define ftrace_set_filter(buf, len, reset) do { } while (0) |
86 | # define ftrace_disable_daemon() do { } while (0) | 93 | # define ftrace_disable_daemon() do { } while (0) |
87 | # define ftrace_enable_daemon() do { } while (0) | 94 | # define ftrace_enable_daemon() do { } while (0) |
95 | static inline void ftrace_release(void *start, unsigned long size) { } | ||
88 | #endif /* CONFIG_DYNAMIC_FTRACE */ | 96 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
89 | 97 | ||
90 | /* totally disable ftrace - can not re-enable after this */ | 98 | /* totally disable ftrace - can not re-enable after this */ |
@@ -98,6 +106,29 @@ static inline void tracer_disable(void) | |||
98 | #endif | 106 | #endif |
99 | } | 107 | } |
100 | 108 | ||
109 | /* | ||
110 | * Ftrace disable/restore without lock. Some synchronization mechanism | ||
111 | * must be used to prevent ftrace_enabled to be changed between | ||
112 | * disable/restore. | ||
113 | */ | ||
114 | static inline int __ftrace_enabled_save(void) | ||
115 | { | ||
116 | #ifdef CONFIG_FTRACE | ||
117 | int saved_ftrace_enabled = ftrace_enabled; | ||
118 | ftrace_enabled = 0; | ||
119 | return saved_ftrace_enabled; | ||
120 | #else | ||
121 | return 0; | ||
122 | #endif | ||
123 | } | ||
124 | |||
125 | static inline void __ftrace_enabled_restore(int enabled) | ||
126 | { | ||
127 | #ifdef CONFIG_FTRACE | ||
128 | ftrace_enabled = enabled; | ||
129 | #endif | ||
130 | } | ||
131 | |||
101 | #ifdef CONFIG_FRAME_POINTER | 132 | #ifdef CONFIG_FRAME_POINTER |
102 | /* TODO: need to fix this for ARM */ | 133 | /* TODO: need to fix this for ARM */ |
103 | # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) | 134 | # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) |
@@ -136,9 +167,71 @@ static inline void tracer_disable(void) | |||
136 | #ifdef CONFIG_TRACING | 167 | #ifdef CONFIG_TRACING |
137 | extern void | 168 | extern void |
138 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); | 169 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); |
170 | |||
171 | /** | ||
172 | * ftrace_printk - printf formatting in the ftrace buffer | ||
173 | * @fmt: the printf format for printing | ||
174 | * | ||
175 | * Note: __ftrace_printk is an internal function for ftrace_printk and | ||
176 | * the @ip is passed in via the ftrace_printk macro. | ||
177 | * | ||
178 | * This function allows a kernel developer to debug fast path sections | ||
179 | * that printk is not appropriate for. By scattering in various | ||
180 | * printk like tracing in the code, a developer can quickly see | ||
181 | * where problems are occurring. | ||
182 | * | ||
183 | * This is intended as a debugging tool for the developer only. | ||
184 | * Please refrain from leaving ftrace_printks scattered around in | ||
185 | * your code. | ||
186 | */ | ||
187 | # define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt) | ||
188 | extern int | ||
189 | __ftrace_printk(unsigned long ip, const char *fmt, ...) | ||
190 | __attribute__ ((format (printf, 2, 3))); | ||
191 | extern void ftrace_dump(void); | ||
139 | #else | 192 | #else |
140 | static inline void | 193 | static inline void |
141 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } | 194 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } |
195 | static inline int | ||
196 | ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0))); | ||
197 | |||
198 | static inline int | ||
199 | ftrace_printk(const char *fmt, ...) | ||
200 | { | ||
201 | return 0; | ||
202 | } | ||
203 | static inline void ftrace_dump(void) { } | ||
204 | #endif | ||
205 | |||
206 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD | ||
207 | extern void ftrace_init(void); | ||
208 | extern void ftrace_init_module(unsigned long *start, unsigned long *end); | ||
209 | #else | ||
210 | static inline void ftrace_init(void) { } | ||
211 | static inline void | ||
212 | ftrace_init_module(unsigned long *start, unsigned long *end) { } | ||
142 | #endif | 213 | #endif |
143 | 214 | ||
215 | |||
216 | struct boot_trace { | ||
217 | pid_t caller; | ||
218 | char func[KSYM_NAME_LEN]; | ||
219 | int result; | ||
220 | unsigned long long duration; /* usecs */ | ||
221 | ktime_t calltime; | ||
222 | ktime_t rettime; | ||
223 | }; | ||
224 | |||
225 | #ifdef CONFIG_BOOT_TRACER | ||
226 | extern void trace_boot(struct boot_trace *it, initcall_t fn); | ||
227 | extern void start_boot_trace(void); | ||
228 | extern void stop_boot_trace(void); | ||
229 | #else | ||
230 | static inline void trace_boot(struct boot_trace *it, initcall_t fn) { } | ||
231 | static inline void start_boot_trace(void) { } | ||
232 | static inline void stop_boot_trace(void) { } | ||
233 | #endif | ||
234 | |||
235 | |||
236 | |||
144 | #endif /* _LINUX_FTRACE_H */ | 237 | #endif /* _LINUX_FTRACE_H */ |