]>
Commit | Line | Data |
---|---|---|
16444a8a ACM |
1 | #ifndef _LINUX_FTRACE_H |
2 | #define _LINUX_FTRACE_H | |
3 | ||
4 | #ifdef CONFIG_FTRACE | |
5 | ||
6 | #include <linux/linkage.h> | |
d49dbf33 | 7 | #include <linux/fs.h> |
d13744cd FW |
8 | #include <linux/init.h> |
9 | #include <linux/types.h> | |
16444a8a | 10 | |
b0fc494f SR |
11 | extern int ftrace_enabled; |
12 | extern int | |
13 | ftrace_enable_sysctl(struct ctl_table *table, int write, | |
14 | struct file *filp, void __user *buffer, size_t *lenp, | |
15 | loff_t *ppos); | |
16 | ||
16444a8a ACM |
17 | typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip); |
18 | ||
19 | struct ftrace_ops { | |
20 | ftrace_func_t func; | |
21 | struct ftrace_ops *next; | |
22 | }; | |
23 | ||
24 | /* | |
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. | |
30 | */ | |
31 | int register_ftrace_function(struct ftrace_ops *ops); | |
32 | int unregister_ftrace_function(struct ftrace_ops *ops); | |
33 | void clear_ftrace_function(void); | |
34 | ||
35 | extern void ftrace_stub(unsigned long a0, unsigned long a1); | |
16444a8a ACM |
36 | |
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) | |
c5131ad6 | 41 | static inline void ftrace_kill_atomic(void) { } |
16444a8a | 42 | #endif /* CONFIG_FTRACE */ |
352ad25a | 43 | |
3d083395 SR |
44 | #ifdef CONFIG_DYNAMIC_FTRACE |
45 | # define FTRACE_HASHBITS 10 | |
46 | # define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS) | |
47 | ||
3c1720f0 | 48 | enum { |
37ad5084 SR |
49 | FTRACE_FL_FREE = (1 << 0), |
50 | FTRACE_FL_FAILED = (1 << 1), | |
51 | FTRACE_FL_FILTER = (1 << 2), | |
52 | FTRACE_FL_ENABLED = (1 << 3), | |
41c52c0d | 53 | FTRACE_FL_NOTRACE = (1 << 4), |
0eb96701 | 54 | FTRACE_FL_CONVERTED = (1 << 5), |
ecea656d | 55 | FTRACE_FL_FROZEN = (1 << 6), |
3c1720f0 SR |
56 | }; |
57 | ||
3d083395 SR |
58 | struct dyn_ftrace { |
59 | struct hlist_node node; | |
395a59d0 | 60 | unsigned long ip; /* address of mcount call-site */ |
3c1720f0 | 61 | unsigned long flags; |
3d083395 SR |
62 | }; |
63 | ||
e1c08bdd | 64 | int ftrace_force_update(void); |
77a2b37d | 65 | void ftrace_set_filter(unsigned char *buf, int len, int reset); |
e1c08bdd | 66 | |
3d083395 | 67 | /* defined in arch */ |
3c1720f0 SR |
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); | |
d61f82d0 SR |
71 | extern int ftrace_dyn_arch_init(void *data); |
72 | extern int ftrace_mcount_set(unsigned long *data); | |
3c1720f0 SR |
73 | extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code, |
74 | unsigned char *new_code); | |
d61f82d0 SR |
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); | |
ad90c0e3 | 79 | |
ecea656d AS |
80 | extern int skip_trace(unsigned long ip); |
81 | ||
c0719e5a SR |
82 | extern void ftrace_release(void *start, unsigned long size); |
83 | ||
84 | extern void ftrace_disable_daemon(void); | |
85 | extern void ftrace_enable_daemon(void); | |
ad90c0e3 | 86 | |
e1c08bdd | 87 | #else |
ecea656d | 88 | # define skip_trace(ip) ({ 0; }) |
aeaee8a2 IM |
89 | # define ftrace_force_update() ({ 0; }) |
90 | # define ftrace_set_filter(buf, len, reset) do { } while (0) | |
ad90c0e3 SR |
91 | # define ftrace_disable_daemon() do { } while (0) |
92 | # define ftrace_enable_daemon() do { } while (0) | |
c0719e5a | 93 | static inline void ftrace_release(void *start, unsigned long size) { } |
ecea656d | 94 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
352ad25a | 95 | |
aeaee8a2 IM |
96 | /* totally disable ftrace - can not re-enable after this */ |
97 | void ftrace_kill(void); | |
a2bb6a3d | 98 | void ftrace_kill_atomic(void); |
aeaee8a2 | 99 | |
f43fdad8 IM |
100 | static inline void tracer_disable(void) |
101 | { | |
102 | #ifdef CONFIG_FTRACE | |
103 | ftrace_enabled = 0; | |
104 | #endif | |
105 | } | |
106 | ||
37002735 HY |
107 | /* |
108 | * Ftrace disable/restore without lock. Some synchronization mechanism | |
9bdeb7b5 | 109 | * must be used to prevent ftrace_enabled to be changed between |
37002735 HY |
110 | * disable/restore. |
111 | */ | |
9bdeb7b5 HY |
112 | static inline int __ftrace_enabled_save(void) |
113 | { | |
114 | #ifdef CONFIG_FTRACE | |
115 | int saved_ftrace_enabled = ftrace_enabled; | |
116 | ftrace_enabled = 0; | |
117 | return saved_ftrace_enabled; | |
118 | #else | |
119 | return 0; | |
120 | #endif | |
121 | } | |
122 | ||
123 | static inline void __ftrace_enabled_restore(int enabled) | |
124 | { | |
125 | #ifdef CONFIG_FTRACE | |
126 | ftrace_enabled = enabled; | |
127 | #endif | |
128 | } | |
129 | ||
352ad25a SR |
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)) | |
86387f7e | 138 | # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6)) |
352ad25a SR |
139 | #else |
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 | |
86387f7e | 146 | # define CALLER_ADDR6 0UL |
352ad25a SR |
147 | #endif |
148 | ||
81d68a96 | 149 | #ifdef CONFIG_IRQSOFF_TRACER |
489f1396 IM |
150 | extern void time_hardirqs_on(unsigned long a0, unsigned long a1); |
151 | extern void time_hardirqs_off(unsigned long a0, unsigned long a1); | |
81d68a96 SR |
152 | #else |
153 | # define time_hardirqs_on(a0, a1) do { } while (0) | |
154 | # define time_hardirqs_off(a0, a1) do { } while (0) | |
155 | #endif | |
156 | ||
6cd8a4bb | 157 | #ifdef CONFIG_PREEMPT_TRACER |
489f1396 IM |
158 | extern void trace_preempt_on(unsigned long a0, unsigned long a1); |
159 | extern void trace_preempt_off(unsigned long a0, unsigned long a1); | |
6cd8a4bb SR |
160 | #else |
161 | # define trace_preempt_on(a0, a1) do { } while (0) | |
162 | # define trace_preempt_off(a0, a1) do { } while (0) | |
163 | #endif | |
164 | ||
b1829d27 | 165 | #ifdef CONFIG_TRACING |
74f4e369 IM |
166 | extern void |
167 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); | |
2f2c99db SR |
168 | |
169 | /** | |
170 | * ftrace_printk - printf formatting in the ftrace buffer | |
171 | * @fmt: the printf format for printing | |
172 | * | |
173 | * Note: __ftrace_printk is an internal function for ftrace_printk and | |
174 | * the @ip is passed in via the ftrace_printk macro. | |
175 | * | |
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. | |
180 | * | |
181 | * This is intended as a debugging tool for the developer only. | |
182 | * Please refrain from leaving ftrace_printks scattered around in | |
183 | * your code. | |
184 | */ | |
185 | # define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt) | |
dd0e545f SR |
186 | extern int |
187 | __ftrace_printk(unsigned long ip, const char *fmt, ...) | |
188 | __attribute__ ((format (printf, 2, 3))); | |
3f5a54e3 | 189 | extern void ftrace_dump(void); |
74f4e369 IM |
190 | #else |
191 | static inline void | |
192 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } | |
dd0e545f | 193 | static inline int |
7b928c23 IM |
194 | ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0))); |
195 | ||
196 | static inline int | |
197 | ftrace_printk(const char *fmt, ...) | |
dd0e545f SR |
198 | { |
199 | return 0; | |
200 | } | |
3f5a54e3 | 201 | static inline void ftrace_dump(void) { } |
74f4e369 IM |
202 | #endif |
203 | ||
68bf21aa SR |
204 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
205 | extern void ftrace_init(void); | |
90d595fe | 206 | extern void ftrace_init_module(unsigned long *start, unsigned long *end); |
68bf21aa SR |
207 | #else |
208 | static inline void ftrace_init(void) { } | |
90d595fe SR |
209 | static inline void |
210 | ftrace_init_module(unsigned long *start, unsigned long *end) { } | |
68bf21aa SR |
211 | #endif |
212 | ||
dd0e545f | 213 | |
d13744cd FW |
214 | struct boot_trace { |
215 | pid_t caller; | |
216 | initcall_t func; | |
217 | int result; | |
218 | unsigned long long duration; | |
cb5ab742 FW |
219 | ktime_t calltime; |
220 | ktime_t rettime; | |
d13744cd FW |
221 | }; |
222 | ||
223 | #ifdef CONFIG_BOOT_TRACER | |
224 | extern void trace_boot(struct boot_trace *it); | |
225 | extern void start_boot_trace(void); | |
226 | #else | |
227 | static inline void trace_boot(struct boot_trace *it) { } | |
228 | static inline void start_boot_trace(void) { } | |
229 | #endif | |
230 | ||
231 | ||
232 | ||
16444a8a | 233 | #endif /* _LINUX_FTRACE_H */ |