Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
9849ed4d MF |
2 | /* |
3 | * Ftrace header. For implementation details beyond the random comments | |
5fb94e9c | 4 | * scattered below, see: Documentation/trace/ftrace-design.rst |
9849ed4d MF |
5 | */ |
6 | ||
16444a8a ACM |
7 | #ifndef _LINUX_FTRACE_H |
8 | #define _LINUX_FTRACE_H | |
9 | ||
0012693a | 10 | #include <linux/trace_clock.h> |
5601020f | 11 | #include <linux/kallsyms.h> |
0012693a | 12 | #include <linux/linkage.h> |
ea4e2bc4 | 13 | #include <linux/bitops.h> |
a1e2e31d | 14 | #include <linux/ptrace.h> |
0012693a | 15 | #include <linux/ktime.h> |
21a8c466 | 16 | #include <linux/sched.h> |
0012693a FW |
17 | #include <linux/types.h> |
18 | #include <linux/init.h> | |
19 | #include <linux/fs.h> | |
16444a8a | 20 | |
c79a61f5 UKK |
21 | #include <asm/ftrace.h> |
22 | ||
2f5f6ad9 SR |
23 | /* |
24 | * If the arch supports passing the variable contents of | |
25 | * function_trace_op as the third parameter back from the | |
26 | * mcount call, then the arch should define this as 1. | |
27 | */ | |
28 | #ifndef ARCH_SUPPORTS_FTRACE_OPS | |
29 | #define ARCH_SUPPORTS_FTRACE_OPS 0 | |
30 | #endif | |
31 | ||
ccf3672d SR |
32 | /* |
33 | * If the arch's mcount caller does not support all of ftrace's | |
34 | * features, then it must call an indirect function that | |
35 | * does. Or at least does enough to prevent any unwelcomed side effects. | |
36 | */ | |
7544256a | 37 | #if !ARCH_SUPPORTS_FTRACE_OPS |
ccf3672d SR |
38 | # define FTRACE_FORCE_LIST_FUNC 1 |
39 | #else | |
40 | # define FTRACE_FORCE_LIST_FUNC 0 | |
41 | #endif | |
42 | ||
5f893b26 SRRH |
43 | /* Main tracing buffer and events set up */ |
44 | #ifdef CONFIG_TRACING | |
45 | void trace_init(void); | |
e725c731 | 46 | void early_trace_init(void); |
5f893b26 SRRH |
47 | #else |
48 | static inline void trace_init(void) { } | |
e725c731 | 49 | static inline void early_trace_init(void) { } |
5f893b26 | 50 | #endif |
ccf3672d | 51 | |
de477254 | 52 | struct module; |
04da85b8 | 53 | struct ftrace_hash; |
013bf0da | 54 | struct ftrace_direct_func; |
04da85b8 | 55 | |
aba4b5c2 SRV |
56 | #if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_MODULES) && \ |
57 | defined(CONFIG_DYNAMIC_FTRACE) | |
58 | const char * | |
59 | ftrace_mod_address_lookup(unsigned long addr, unsigned long *size, | |
60 | unsigned long *off, char **modname, char *sym); | |
6171a031 SRV |
61 | int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value, |
62 | char *type, char *name, | |
63 | char *module_name, int *exported); | |
aba4b5c2 SRV |
64 | #else |
65 | static inline const char * | |
66 | ftrace_mod_address_lookup(unsigned long addr, unsigned long *size, | |
67 | unsigned long *off, char **modname, char *sym) | |
68 | { | |
69 | return NULL; | |
70 | } | |
6171a031 SRV |
71 | static inline int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value, |
72 | char *type, char *name, | |
73 | char *module_name, int *exported) | |
74 | { | |
75 | return -1; | |
76 | } | |
aba4b5c2 SRV |
77 | #endif |
78 | ||
79 | ||
606576ce | 80 | #ifdef CONFIG_FUNCTION_TRACER |
3e1932ad | 81 | |
b0fc494f SR |
82 | extern int ftrace_enabled; |
83 | extern int | |
84 | ftrace_enable_sysctl(struct ctl_table *table, int write, | |
8d65af78 | 85 | void __user *buffer, size_t *lenp, |
b0fc494f SR |
86 | loff_t *ppos); |
87 | ||
2f5f6ad9 SR |
88 | struct ftrace_ops; |
89 | ||
90 | typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip, | |
a1e2e31d | 91 | struct ftrace_ops *op, struct pt_regs *regs); |
16444a8a | 92 | |
87354059 SRRH |
93 | ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops); |
94 | ||
e248491a JO |
95 | /* |
96 | * FTRACE_OPS_FL_* bits denote the state of ftrace_ops struct and are | |
97 | * set in the flags member. | |
f8b8be8a MH |
98 | * CONTROL, SAVE_REGS, SAVE_REGS_IF_SUPPORTED, RECURSION_SAFE, STUB and |
99 | * IPMODIFY are a kind of attribute flags which can be set only before | |
100 | * registering the ftrace_ops, and can not be modified while registered. | |
ad61dd30 | 101 | * Changing those attribute flags after registering ftrace_ops will |
f8b8be8a | 102 | * cause unexpected results. |
e248491a JO |
103 | * |
104 | * ENABLED - set/unset when ftrace_ops is registered/unregistered | |
e248491a JO |
105 | * DYNAMIC - set when ftrace_ops is registered to denote dynamically |
106 | * allocated ftrace_ops which need special care | |
08f6fba5 SR |
107 | * SAVE_REGS - The ftrace_ops wants regs saved at each function called |
108 | * and passed to the callback. If this flag is set, but the | |
109 | * architecture does not support passing regs | |
06aeaaea | 110 | * (CONFIG_DYNAMIC_FTRACE_WITH_REGS is not defined), then the |
08f6fba5 SR |
111 | * ftrace_ops will fail to register, unless the next flag |
112 | * is set. | |
113 | * SAVE_REGS_IF_SUPPORTED - This is the same as SAVE_REGS, but if the | |
114 | * handler can handle an arch that does not save regs | |
115 | * (the handler tests if regs == NULL), then it can set | |
116 | * this flag instead. It will not fail registering the ftrace_ops | |
117 | * but, the regs field will be NULL if the arch does not support | |
118 | * passing regs to the handler. | |
119 | * Note, if this flag is set, the SAVE_REGS flag will automatically | |
120 | * get set upon registering the ftrace_ops, if the arch supports it. | |
4740974a SR |
121 | * RECURSION_SAFE - The ftrace_ops can set this to tell the ftrace infrastructure |
122 | * that the call back has its own recursion protection. If it does | |
123 | * not set this, then the ftrace infrastructure will add recursion | |
124 | * protection for the caller. | |
395b97a3 | 125 | * STUB - The ftrace_ops is just a place holder. |
f04f24fb MH |
126 | * INITIALIZED - The ftrace_ops has already been initialized (first use time |
127 | * register_ftrace_function() is called, it will initialized the ops) | |
591dffda | 128 | * DELETED - The ops are being deleted, do not let them be registered again. |
e1effa01 SRRH |
129 | * ADDING - The ops is in the process of being added. |
130 | * REMOVING - The ops is in the process of being removed. | |
131 | * MODIFYING - The ops is in the process of changing its filter functions. | |
f3bea491 SRRH |
132 | * ALLOC_TRAMP - A dynamic trampoline was allocated by the core code. |
133 | * The arch specific code sets this flag when it allocated a | |
134 | * trampoline. This lets the arch know that it can update the | |
135 | * trampoline in case the callback function changes. | |
136 | * The ftrace_ops trampoline can be set by the ftrace users, and | |
137 | * in such cases the arch must not modify it. Only the arch ftrace | |
138 | * core code should set this flag. | |
f8b8be8a MH |
139 | * IPMODIFY - The ops can modify the IP register. This can only be set with |
140 | * SAVE_REGS. If another ops with this flag set is already registered | |
141 | * for any of the functions that this ops will be registered for, then | |
142 | * this ops will fail to register or set_filter_ip. | |
e3eea140 | 143 | * PID - Is affected by set_ftrace_pid (allows filtering on those pids) |
d0ba52f1 | 144 | * RCU - Set when the ops can only be called when RCU is watching. |
8c08f0d5 | 145 | * TRACE_ARRAY - The ops->private points to a trace_array descriptor. |
7162431d MB |
146 | * PERMANENT - Set when the ops is permanent and should not be affected by |
147 | * ftrace_enabled. | |
763e34e7 SRV |
148 | * DIRECT - Used by the direct ftrace_ops helper for direct functions |
149 | * (internal ftrace only, should not be used by others) | |
e248491a | 150 | */ |
b848914c | 151 | enum { |
08f6fba5 | 152 | FTRACE_OPS_FL_ENABLED = 1 << 0, |
4104d326 | 153 | FTRACE_OPS_FL_DYNAMIC = 1 << 1, |
b3a88803 PZ |
154 | FTRACE_OPS_FL_SAVE_REGS = 1 << 2, |
155 | FTRACE_OPS_FL_SAVE_REGS_IF_SUPPORTED = 1 << 3, | |
156 | FTRACE_OPS_FL_RECURSION_SAFE = 1 << 4, | |
157 | FTRACE_OPS_FL_STUB = 1 << 5, | |
158 | FTRACE_OPS_FL_INITIALIZED = 1 << 6, | |
159 | FTRACE_OPS_FL_DELETED = 1 << 7, | |
160 | FTRACE_OPS_FL_ADDING = 1 << 8, | |
161 | FTRACE_OPS_FL_REMOVING = 1 << 9, | |
162 | FTRACE_OPS_FL_MODIFYING = 1 << 10, | |
163 | FTRACE_OPS_FL_ALLOC_TRAMP = 1 << 11, | |
164 | FTRACE_OPS_FL_IPMODIFY = 1 << 12, | |
165 | FTRACE_OPS_FL_PID = 1 << 13, | |
166 | FTRACE_OPS_FL_RCU = 1 << 14, | |
167 | FTRACE_OPS_FL_TRACE_ARRAY = 1 << 15, | |
7162431d | 168 | FTRACE_OPS_FL_PERMANENT = 1 << 16, |
763e34e7 | 169 | FTRACE_OPS_FL_DIRECT = 1 << 17, |
b848914c SR |
170 | }; |
171 | ||
33b7f99c SRRH |
172 | #ifdef CONFIG_DYNAMIC_FTRACE |
173 | /* The hash used to know what functions callbacks trace */ | |
174 | struct ftrace_ops_hash { | |
f86f4180 CZ |
175 | struct ftrace_hash __rcu *notrace_hash; |
176 | struct ftrace_hash __rcu *filter_hash; | |
33b7f99c SRRH |
177 | struct mutex regex_lock; |
178 | }; | |
42c269c8 | 179 | |
b80f0f6c | 180 | void ftrace_free_init_mem(void); |
aba4b5c2 | 181 | void ftrace_free_mem(struct module *mod, void *start, void *end); |
42c269c8 | 182 | #else |
b80f0f6c | 183 | static inline void ftrace_free_init_mem(void) { } |
aba4b5c2 | 184 | static inline void ftrace_free_mem(struct module *mod, void *start, void *end) { } |
33b7f99c SRRH |
185 | #endif |
186 | ||
b7e00a6c | 187 | /* |
ba27f2bc SRRH |
188 | * Note, ftrace_ops can be referenced outside of RCU protection, unless |
189 | * the RCU flag is set. If ftrace_ops is allocated and not part of kernel | |
190 | * core data, the unregistering of it will perform a scheduling on all CPUs | |
191 | * to make sure that there are no more users. Depending on the load of the | |
192 | * system that may take a bit of time. | |
b7e00a6c SRRH |
193 | * |
194 | * Any private data added must also take care not to be freed and if private | |
195 | * data is added to a ftrace_ops that is in core code, the user of the | |
196 | * ftrace_ops must perform a schedule_on_each_cpu() before freeing it. | |
197 | */ | |
16444a8a | 198 | struct ftrace_ops { |
f45948e8 | 199 | ftrace_func_t func; |
f86f4180 | 200 | struct ftrace_ops __rcu *next; |
b848914c | 201 | unsigned long flags; |
b7e00a6c | 202 | void *private; |
e3eea140 | 203 | ftrace_func_t saved_func; |
f45948e8 | 204 | #ifdef CONFIG_DYNAMIC_FTRACE |
33b7f99c SRRH |
205 | struct ftrace_ops_hash local_hash; |
206 | struct ftrace_ops_hash *func_hash; | |
fef5aeee | 207 | struct ftrace_ops_hash old_hash; |
79922b80 | 208 | unsigned long trampoline; |
aec0be2d | 209 | unsigned long trampoline_size; |
f45948e8 | 210 | #endif |
16444a8a ACM |
211 | }; |
212 | ||
e7d3737e FW |
213 | /* |
214 | * Type of the current tracing. | |
215 | */ | |
216 | enum ftrace_tracing_type_t { | |
217 | FTRACE_TYPE_ENTER = 0, /* Hook the call of the function */ | |
218 | FTRACE_TYPE_RETURN, /* Hook the return of the function */ | |
219 | }; | |
220 | ||
221 | /* Current tracing type, default is FTRACE_TYPE_ENTER */ | |
222 | extern enum ftrace_tracing_type_t ftrace_tracing_type; | |
223 | ||
16444a8a ACM |
224 | /* |
225 | * The ftrace_ops must be a static and should also | |
226 | * be read_mostly. These functions do modify read_mostly variables | |
227 | * so use them sparely. Never free an ftrace_op or modify the | |
228 | * next pointer after it has been registered. Even after unregistering | |
229 | * it, the next pointer may still be used internally. | |
230 | */ | |
231 | int register_ftrace_function(struct ftrace_ops *ops); | |
232 | int unregister_ftrace_function(struct ftrace_ops *ops); | |
16444a8a | 233 | |
a1e2e31d SR |
234 | extern void ftrace_stub(unsigned long a0, unsigned long a1, |
235 | struct ftrace_ops *op, struct pt_regs *regs); | |
16444a8a | 236 | |
606576ce | 237 | #else /* !CONFIG_FUNCTION_TRACER */ |
4dbf6bc2 SR |
238 | /* |
239 | * (un)register_ftrace_function must be a macro since the ops parameter | |
240 | * must not be evaluated. | |
241 | */ | |
242 | #define register_ftrace_function(ops) ({ 0; }) | |
243 | #define unregister_ftrace_function(ops) ({ 0; }) | |
81adbdc0 | 244 | static inline void ftrace_kill(void) { } |
b80f0f6c | 245 | static inline void ftrace_free_init_mem(void) { } |
aba4b5c2 | 246 | static inline void ftrace_free_mem(struct module *mod, void *start, void *end) { } |
606576ce | 247 | #endif /* CONFIG_FUNCTION_TRACER */ |
352ad25a | 248 | |
763e34e7 | 249 | #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS |
a3ad1a7e | 250 | extern int ftrace_direct_func_count; |
763e34e7 SRV |
251 | int register_ftrace_direct(unsigned long ip, unsigned long addr); |
252 | int unregister_ftrace_direct(unsigned long ip, unsigned long addr); | |
013bf0da | 253 | struct ftrace_direct_func *ftrace_find_direct_func(unsigned long addr); |
763e34e7 | 254 | #else |
a3ad1a7e | 255 | # define ftrace_direct_func_count 0 |
763e34e7 SRV |
256 | static inline int register_ftrace_direct(unsigned long ip, unsigned long addr) |
257 | { | |
258 | return -ENODEV; | |
259 | } | |
260 | static inline int unregister_ftrace_direct(unsigned long ip, unsigned long addr) | |
261 | { | |
262 | return -ENODEV; | |
263 | } | |
013bf0da SRV |
264 | static inline struct ftrace_direct_func *ftrace_find_direct_func(unsigned long addr) |
265 | { | |
266 | return NULL; | |
267 | } | |
763e34e7 SRV |
268 | #endif /* CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */ |
269 | ||
270 | #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS | |
271 | /* | |
272 | * This must be implemented by the architecture. | |
273 | * It is the way the ftrace direct_ops helper, when called | |
274 | * via ftrace (because there's other callbacks besides the | |
275 | * direct call), can inform the architecture's trampoline that this | |
276 | * routine has a direct caller, and what the caller is. | |
562955fe SRV |
277 | * |
278 | * For example, in x86, it returns the direct caller | |
279 | * callback function via the regs->orig_ax parameter. | |
280 | * Then in the ftrace trampoline, if this is set, it makes | |
281 | * the return from the trampoline jump to the direct caller | |
282 | * instead of going back to the function it just traced. | |
763e34e7 SRV |
283 | */ |
284 | static inline void arch_ftrace_set_direct_caller(struct pt_regs *regs, | |
285 | unsigned long addr) { } | |
286 | #endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */ | |
287 | ||
f38f1d2a | 288 | #ifdef CONFIG_STACK_TRACER |
bb99d8cc | 289 | |
f38f1d2a | 290 | extern int stack_tracer_enabled; |
3d9a8072 TG |
291 | |
292 | int stack_trace_sysctl(struct ctl_table *table, int write, | |
293 | void __user *buffer, size_t *lenp, | |
294 | loff_t *ppos); | |
5367278c | 295 | |
8aaf1ee7 SRV |
296 | /* DO NOT MODIFY THIS VARIABLE DIRECTLY! */ |
297 | DECLARE_PER_CPU(int, disable_stack_tracer); | |
298 | ||
299 | /** | |
300 | * stack_tracer_disable - temporarily disable the stack tracer | |
301 | * | |
302 | * There's a few locations (namely in RCU) where stack tracing | |
303 | * cannot be executed. This function is used to disable stack | |
304 | * tracing during those critical sections. | |
305 | * | |
306 | * This function must be called with preemption or interrupts | |
307 | * disabled and stack_tracer_enable() must be called shortly after | |
308 | * while preemption or interrupts are still disabled. | |
309 | */ | |
310 | static inline void stack_tracer_disable(void) | |
311 | { | |
312 | /* Preemption or interupts must be disabled */ | |
60361e12 | 313 | if (IS_ENABLED(CONFIG_DEBUG_PREEMPT)) |
8aaf1ee7 SRV |
314 | WARN_ON_ONCE(!preempt_count() || !irqs_disabled()); |
315 | this_cpu_inc(disable_stack_tracer); | |
316 | } | |
317 | ||
318 | /** | |
319 | * stack_tracer_enable - re-enable the stack tracer | |
320 | * | |
321 | * After stack_tracer_disable() is called, stack_tracer_enable() | |
322 | * must be called shortly afterward. | |
323 | */ | |
324 | static inline void stack_tracer_enable(void) | |
325 | { | |
60361e12 | 326 | if (IS_ENABLED(CONFIG_DEBUG_PREEMPT)) |
8aaf1ee7 SRV |
327 | WARN_ON_ONCE(!preempt_count() || !irqs_disabled()); |
328 | this_cpu_dec(disable_stack_tracer); | |
329 | } | |
5367278c SRV |
330 | #else |
331 | static inline void stack_tracer_disable(void) { } | |
332 | static inline void stack_tracer_enable(void) { } | |
f38f1d2a SR |
333 | #endif |
334 | ||
3d083395 | 335 | #ifdef CONFIG_DYNAMIC_FTRACE |
31e88909 | 336 | |
000ab691 SR |
337 | int ftrace_arch_code_modify_prepare(void); |
338 | int ftrace_arch_code_modify_post_process(void); | |
339 | ||
4fd3279b SRRH |
340 | struct dyn_ftrace; |
341 | ||
02a392a0 SRRH |
342 | enum ftrace_bug_type { |
343 | FTRACE_BUG_UNKNOWN, | |
344 | FTRACE_BUG_INIT, | |
345 | FTRACE_BUG_NOP, | |
346 | FTRACE_BUG_CALL, | |
347 | FTRACE_BUG_UPDATE, | |
348 | }; | |
349 | extern enum ftrace_bug_type ftrace_bug_type; | |
350 | ||
b05086c7 SRRH |
351 | /* |
352 | * Archs can set this to point to a variable that holds the value that was | |
353 | * expected at the call site before calling ftrace_bug(). | |
354 | */ | |
355 | extern const void *ftrace_expected; | |
356 | ||
4fd3279b | 357 | void ftrace_bug(int err, struct dyn_ftrace *rec); |
c88fd863 | 358 | |
809dcf29 SR |
359 | struct seq_file; |
360 | ||
d88471cb | 361 | extern int ftrace_text_reserved(const void *start, const void *end); |
2cfa1978 | 362 | |
6be7fa3c SRV |
363 | struct ftrace_ops *ftrace_ops_trampoline(unsigned long addr); |
364 | ||
aec0be2d SRRH |
365 | bool is_ftrace_trampoline(unsigned long addr); |
366 | ||
08f6fba5 SR |
367 | /* |
368 | * The dyn_ftrace record's flags field is split into two parts. | |
369 | * the first part which is '0-FTRACE_REF_MAX' is a counter of | |
370 | * the number of callbacks that have registered the function that | |
371 | * the dyn_ftrace descriptor represents. | |
372 | * | |
373 | * The second part is a mask: | |
374 | * ENABLED - the function is being traced | |
375 | * REGS - the record wants the function to save regs | |
376 | * REGS_EN - the function is set up to save regs. | |
f8b8be8a | 377 | * IPMODIFY - the record allows for the IP address to be changed. |
b7ffffbb | 378 | * DISABLED - the record is not ready to be touched yet |
763e34e7 | 379 | * DIRECT - there is a direct function to call |
08f6fba5 SR |
380 | * |
381 | * When a new ftrace_ops is registered and wants a function to save | |
382 | * pt_regs, the rec->flag REGS is set. When the function has been | |
383 | * set up to save regs, the REG_EN flag is set. Once a function | |
384 | * starts saving regs it will do so until all ftrace_ops are removed | |
385 | * from tracing that function. | |
386 | */ | |
3c1720f0 | 387 | enum { |
79922b80 | 388 | FTRACE_FL_ENABLED = (1UL << 31), |
08f6fba5 | 389 | FTRACE_FL_REGS = (1UL << 30), |
79922b80 SRRH |
390 | FTRACE_FL_REGS_EN = (1UL << 29), |
391 | FTRACE_FL_TRAMP = (1UL << 28), | |
392 | FTRACE_FL_TRAMP_EN = (1UL << 27), | |
f8b8be8a | 393 | FTRACE_FL_IPMODIFY = (1UL << 26), |
b7ffffbb | 394 | FTRACE_FL_DISABLED = (1UL << 25), |
763e34e7 SRV |
395 | FTRACE_FL_DIRECT = (1UL << 24), |
396 | FTRACE_FL_DIRECT_EN = (1UL << 23), | |
3c1720f0 SR |
397 | }; |
398 | ||
763e34e7 SRV |
399 | #define FTRACE_REF_MAX_SHIFT 23 |
400 | #define FTRACE_FL_BITS 9 | |
cf2cb0b2 SRRH |
401 | #define FTRACE_FL_MASKED_BITS ((1UL << FTRACE_FL_BITS) - 1) |
402 | #define FTRACE_FL_MASK (FTRACE_FL_MASKED_BITS << FTRACE_REF_MAX_SHIFT) | |
403 | #define FTRACE_REF_MAX ((1UL << FTRACE_REF_MAX_SHIFT) - 1) | |
ed926f9b | 404 | |
0376bde1 SRRH |
405 | #define ftrace_rec_count(rec) ((rec)->flags & ~FTRACE_FL_MASK) |
406 | ||
3d083395 | 407 | struct dyn_ftrace { |
a762782d | 408 | unsigned long ip; /* address of mcount call-site */ |
85ae32ae | 409 | unsigned long flags; |
a762782d | 410 | struct dyn_arch_ftrace arch; |
3d083395 SR |
411 | }; |
412 | ||
e1c08bdd | 413 | int ftrace_force_update(void); |
647664ea MH |
414 | int ftrace_set_filter_ip(struct ftrace_ops *ops, unsigned long ip, |
415 | int remove, int reset); | |
ac483c44 | 416 | int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf, |
936e074b | 417 | int len, int reset); |
ac483c44 | 418 | int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf, |
936e074b SR |
419 | int len, int reset); |
420 | void ftrace_set_global_filter(unsigned char *buf, int len, int reset); | |
421 | void ftrace_set_global_notrace(unsigned char *buf, int len, int reset); | |
5500fa51 | 422 | void ftrace_free_filter(struct ftrace_ops *ops); |
d032ae89 | 423 | void ftrace_ops_set_global_filter(struct ftrace_ops *ops); |
e1c08bdd | 424 | |
c88fd863 SR |
425 | enum { |
426 | FTRACE_UPDATE_CALLS = (1 << 0), | |
427 | FTRACE_DISABLE_CALLS = (1 << 1), | |
428 | FTRACE_UPDATE_TRACE_FUNC = (1 << 2), | |
429 | FTRACE_START_FUNC_RET = (1 << 3), | |
430 | FTRACE_STOP_FUNC_RET = (1 << 4), | |
a0572f68 | 431 | FTRACE_MAY_SLEEP = (1 << 5), |
c88fd863 SR |
432 | }; |
433 | ||
08f6fba5 SR |
434 | /* |
435 | * The FTRACE_UPDATE_* enum is used to pass information back | |
436 | * from the ftrace_update_record() and ftrace_test_record() | |
437 | * functions. These are called by the code update routines | |
438 | * to find out what is to be done for a given function. | |
439 | * | |
440 | * IGNORE - The function is already what we want it to be | |
441 | * MAKE_CALL - Start tracing the function | |
442 | * MODIFY_CALL - Stop saving regs for the function | |
08f6fba5 SR |
443 | * MAKE_NOP - Stop tracing the function |
444 | */ | |
c88fd863 SR |
445 | enum { |
446 | FTRACE_UPDATE_IGNORE, | |
447 | FTRACE_UPDATE_MAKE_CALL, | |
08f6fba5 | 448 | FTRACE_UPDATE_MODIFY_CALL, |
c88fd863 SR |
449 | FTRACE_UPDATE_MAKE_NOP, |
450 | }; | |
451 | ||
fc13cb0c SR |
452 | enum { |
453 | FTRACE_ITER_FILTER = (1 << 0), | |
454 | FTRACE_ITER_NOTRACE = (1 << 1), | |
455 | FTRACE_ITER_PRINTALL = (1 << 2), | |
eee8ded1 SRV |
456 | FTRACE_ITER_DO_PROBES = (1 << 3), |
457 | FTRACE_ITER_PROBE = (1 << 4), | |
5985ea8b SRV |
458 | FTRACE_ITER_MOD = (1 << 5), |
459 | FTRACE_ITER_ENABLED = (1 << 6), | |
fc13cb0c SR |
460 | }; |
461 | ||
c88fd863 | 462 | void arch_ftrace_update_code(int command); |
89f579ce YW |
463 | void arch_ftrace_update_trampoline(struct ftrace_ops *ops); |
464 | void *arch_ftrace_trampoline_func(struct ftrace_ops *ops, struct dyn_ftrace *rec); | |
465 | void arch_ftrace_trampoline_free(struct ftrace_ops *ops); | |
c88fd863 SR |
466 | |
467 | struct ftrace_rec_iter; | |
468 | ||
469 | struct ftrace_rec_iter *ftrace_rec_iter_start(void); | |
470 | struct ftrace_rec_iter *ftrace_rec_iter_next(struct ftrace_rec_iter *iter); | |
471 | struct dyn_ftrace *ftrace_rec_iter_record(struct ftrace_rec_iter *iter); | |
472 | ||
08d636b6 SR |
473 | #define for_ftrace_rec_iter(iter) \ |
474 | for (iter = ftrace_rec_iter_start(); \ | |
475 | iter; \ | |
476 | iter = ftrace_rec_iter_next(iter)) | |
477 | ||
478 | ||
7375dca1 SRV |
479 | int ftrace_update_record(struct dyn_ftrace *rec, bool enable); |
480 | int ftrace_test_record(struct dyn_ftrace *rec, bool enable); | |
c88fd863 | 481 | void ftrace_run_stop_machine(int command); |
f0cf973a | 482 | unsigned long ftrace_location(unsigned long ip); |
04cf31a7 | 483 | unsigned long ftrace_location_range(unsigned long start, unsigned long end); |
7413af1f SRRH |
484 | unsigned long ftrace_get_addr_new(struct dyn_ftrace *rec); |
485 | unsigned long ftrace_get_addr_curr(struct dyn_ftrace *rec); | |
c88fd863 SR |
486 | |
487 | extern ftrace_func_t ftrace_trace_function; | |
488 | ||
fc13cb0c SR |
489 | int ftrace_regex_open(struct ftrace_ops *ops, int flag, |
490 | struct inode *inode, struct file *file); | |
491 | ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf, | |
492 | size_t cnt, loff_t *ppos); | |
493 | ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf, | |
494 | size_t cnt, loff_t *ppos); | |
fc13cb0c SR |
495 | int ftrace_regex_release(struct inode *inode, struct file *file); |
496 | ||
2a85a37f SR |
497 | void __init |
498 | ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable); | |
499 | ||
3d083395 | 500 | /* defined in arch */ |
3c1720f0 | 501 | extern int ftrace_ip_converted(unsigned long ip); |
3a36cb11 | 502 | extern int ftrace_dyn_arch_init(void); |
e4f5d544 | 503 | extern void ftrace_replace_code(int enable); |
d61f82d0 SR |
504 | extern int ftrace_update_ftrace_func(ftrace_func_t func); |
505 | extern void ftrace_caller(void); | |
08f6fba5 | 506 | extern void ftrace_regs_caller(void); |
d61f82d0 | 507 | extern void ftrace_call(void); |
08f6fba5 | 508 | extern void ftrace_regs_call(void); |
d61f82d0 | 509 | extern void mcount_call(void); |
f0001207 | 510 | |
8ed3e2cf SR |
511 | void ftrace_modify_all_code(int command); |
512 | ||
f0001207 SL |
513 | #ifndef FTRACE_ADDR |
514 | #define FTRACE_ADDR ((unsigned long)ftrace_caller) | |
515 | #endif | |
08f6fba5 | 516 | |
79922b80 SRRH |
517 | #ifndef FTRACE_GRAPH_ADDR |
518 | #define FTRACE_GRAPH_ADDR ((unsigned long)ftrace_graph_caller) | |
519 | #endif | |
520 | ||
08f6fba5 | 521 | #ifndef FTRACE_REGS_ADDR |
06aeaaea | 522 | #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS |
08f6fba5 SR |
523 | # define FTRACE_REGS_ADDR ((unsigned long)ftrace_regs_caller) |
524 | #else | |
525 | # define FTRACE_REGS_ADDR FTRACE_ADDR | |
526 | #endif | |
527 | #endif | |
528 | ||
646d7043 SRRH |
529 | /* |
530 | * If an arch would like functions that are only traced | |
531 | * by the function graph tracer to jump directly to its own | |
532 | * trampoline, then they can define FTRACE_GRAPH_TRAMP_ADDR | |
533 | * to be that address to jump to. | |
534 | */ | |
535 | #ifndef FTRACE_GRAPH_TRAMP_ADDR | |
536 | #define FTRACE_GRAPH_TRAMP_ADDR ((unsigned long) 0) | |
537 | #endif | |
538 | ||
fb52607a FW |
539 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
540 | extern void ftrace_graph_caller(void); | |
5a45cfe1 SR |
541 | extern int ftrace_enable_ftrace_graph_caller(void); |
542 | extern int ftrace_disable_ftrace_graph_caller(void); | |
543 | #else | |
544 | static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; } | |
545 | static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; } | |
e7d3737e | 546 | #endif |
ad90c0e3 | 547 | |
31e88909 | 548 | /** |
57794a9d | 549 | * ftrace_make_nop - convert code into nop |
31e88909 SR |
550 | * @mod: module structure if called by module load initialization |
551 | * @rec: the mcount call site record | |
552 | * @addr: the address that the call site should be calling | |
553 | * | |
554 | * This is a very sensitive operation and great care needs | |
555 | * to be taken by the arch. The operation should carefully | |
556 | * read the location, check to see if what is read is indeed | |
557 | * what we expect it to be, and then on success of the compare, | |
558 | * it should write to the location. | |
559 | * | |
560 | * The code segment at @rec->ip should be a caller to @addr | |
561 | * | |
562 | * Return must be: | |
563 | * 0 on success | |
564 | * -EFAULT on error reading the location | |
565 | * -EINVAL on a failed compare of the contents | |
566 | * -EPERM on error writing to the location | |
567 | * Any other value will be considered a failure. | |
568 | */ | |
569 | extern int ftrace_make_nop(struct module *mod, | |
570 | struct dyn_ftrace *rec, unsigned long addr); | |
a26a2a27 | 571 | |
593eb8a2 | 572 | /** |
31e88909 SR |
573 | * ftrace_make_call - convert a nop call site into a call to addr |
574 | * @rec: the mcount call site record | |
575 | * @addr: the address that the call site should call | |
593eb8a2 SR |
576 | * |
577 | * This is a very sensitive operation and great care needs | |
578 | * to be taken by the arch. The operation should carefully | |
579 | * read the location, check to see if what is read is indeed | |
580 | * what we expect it to be, and then on success of the compare, | |
581 | * it should write to the location. | |
582 | * | |
31e88909 SR |
583 | * The code segment at @rec->ip should be a nop |
584 | * | |
593eb8a2 SR |
585 | * Return must be: |
586 | * 0 on success | |
587 | * -EFAULT on error reading the location | |
588 | * -EINVAL on a failed compare of the contents | |
589 | * -EPERM on error writing to the location | |
590 | * Any other value will be considered a failure. | |
591 | */ | |
31e88909 SR |
592 | extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr); |
593 | ||
06aeaaea | 594 | #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS |
08f6fba5 SR |
595 | /** |
596 | * ftrace_modify_call - convert from one addr to another (no nop) | |
597 | * @rec: the mcount call site record | |
598 | * @old_addr: the address expected to be currently called to | |
599 | * @addr: the address to change to | |
600 | * | |
601 | * This is a very sensitive operation and great care needs | |
602 | * to be taken by the arch. The operation should carefully | |
603 | * read the location, check to see if what is read is indeed | |
604 | * what we expect it to be, and then on success of the compare, | |
605 | * it should write to the location. | |
606 | * | |
607 | * The code segment at @rec->ip should be a caller to @old_addr | |
608 | * | |
609 | * Return must be: | |
610 | * 0 on success | |
611 | * -EFAULT on error reading the location | |
612 | * -EINVAL on a failed compare of the contents | |
613 | * -EPERM on error writing to the location | |
614 | * Any other value will be considered a failure. | |
615 | */ | |
616 | extern int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, | |
617 | unsigned long addr); | |
618 | #else | |
619 | /* Should never be called */ | |
620 | static inline int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, | |
621 | unsigned long addr) | |
622 | { | |
623 | return -EINVAL; | |
624 | } | |
625 | #endif | |
626 | ||
31e88909 SR |
627 | /* May be defined in arch */ |
628 | extern int ftrace_arch_read_dyn_info(char *buf, int size); | |
593eb8a2 | 629 | |
ecea656d | 630 | extern int skip_trace(unsigned long ip); |
a949ae56 | 631 | extern void ftrace_module_init(struct module *mod); |
7dcd182b | 632 | extern void ftrace_module_enable(struct module *mod); |
049fb9bd | 633 | extern void ftrace_release_mod(struct module *mod); |
ecea656d | 634 | |
c0719e5a SR |
635 | extern void ftrace_disable_daemon(void); |
636 | extern void ftrace_enable_daemon(void); | |
4dc93676 | 637 | #else /* CONFIG_DYNAMIC_FTRACE */ |
4dbf6bc2 SR |
638 | static inline int skip_trace(unsigned long ip) { return 0; } |
639 | static inline int ftrace_force_update(void) { return 0; } | |
4dbf6bc2 SR |
640 | static inline void ftrace_disable_daemon(void) { } |
641 | static inline void ftrace_enable_daemon(void) { } | |
7dcd182b JY |
642 | static inline void ftrace_module_init(struct module *mod) { } |
643 | static inline void ftrace_module_enable(struct module *mod) { } | |
644 | static inline void ftrace_release_mod(struct module *mod) { } | |
d88471cb | 645 | static inline int ftrace_text_reserved(const void *start, const void *end) |
2cfa1978 MH |
646 | { |
647 | return 0; | |
648 | } | |
4dc93676 SR |
649 | static inline unsigned long ftrace_location(unsigned long ip) |
650 | { | |
651 | return 0; | |
652 | } | |
fc13cb0c SR |
653 | |
654 | /* | |
655 | * Again users of functions that have ftrace_ops may not | |
656 | * have them defined when ftrace is not enabled, but these | |
657 | * functions may still be called. Use a macro instead of inline. | |
658 | */ | |
659 | #define ftrace_regex_open(ops, flag, inod, file) ({ -ENODEV; }) | |
96de37b6 | 660 | #define ftrace_set_early_filter(ops, buf, enable) do { } while (0) |
647664ea | 661 | #define ftrace_set_filter_ip(ops, ip, remove, reset) ({ -ENODEV; }) |
5500fa51 JO |
662 | #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; }) |
663 | #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; }) | |
664 | #define ftrace_free_filter(ops) do { } while (0) | |
d032ae89 | 665 | #define ftrace_ops_set_global_filter(ops) do { } while (0) |
fc13cb0c SR |
666 | |
667 | static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf, | |
668 | size_t cnt, loff_t *ppos) { return -ENODEV; } | |
669 | static inline ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf, | |
670 | size_t cnt, loff_t *ppos) { return -ENODEV; } | |
fc13cb0c SR |
671 | static inline int |
672 | ftrace_regex_release(struct inode *inode, struct file *file) { return -ENODEV; } | |
aec0be2d SRRH |
673 | |
674 | static inline bool is_ftrace_trampoline(unsigned long addr) | |
675 | { | |
676 | return false; | |
677 | } | |
ecea656d | 678 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
352ad25a | 679 | |
aeaee8a2 IM |
680 | /* totally disable ftrace - can not re-enable after this */ |
681 | void ftrace_kill(void); | |
682 | ||
f43fdad8 IM |
683 | static inline void tracer_disable(void) |
684 | { | |
606576ce | 685 | #ifdef CONFIG_FUNCTION_TRACER |
f43fdad8 IM |
686 | ftrace_enabled = 0; |
687 | #endif | |
688 | } | |
689 | ||
37002735 HY |
690 | /* |
691 | * Ftrace disable/restore without lock. Some synchronization mechanism | |
9bdeb7b5 | 692 | * must be used to prevent ftrace_enabled to be changed between |
37002735 HY |
693 | * disable/restore. |
694 | */ | |
9bdeb7b5 HY |
695 | static inline int __ftrace_enabled_save(void) |
696 | { | |
606576ce | 697 | #ifdef CONFIG_FUNCTION_TRACER |
9bdeb7b5 HY |
698 | int saved_ftrace_enabled = ftrace_enabled; |
699 | ftrace_enabled = 0; | |
700 | return saved_ftrace_enabled; | |
701 | #else | |
702 | return 0; | |
703 | #endif | |
704 | } | |
705 | ||
706 | static inline void __ftrace_enabled_restore(int enabled) | |
707 | { | |
606576ce | 708 | #ifdef CONFIG_FUNCTION_TRACER |
9bdeb7b5 HY |
709 | ftrace_enabled = enabled; |
710 | #endif | |
711 | } | |
712 | ||
eed542d6 AT |
713 | /* All archs should have this, but we define it for consistency */ |
714 | #ifndef ftrace_return_address0 | |
715 | # define ftrace_return_address0 __builtin_return_address(0) | |
716 | #endif | |
717 | ||
718 | /* Archs may use other ways for ADDR1 and beyond */ | |
719 | #ifndef ftrace_return_address | |
c79a61f5 | 720 | # ifdef CONFIG_FRAME_POINTER |
eed542d6 | 721 | # define ftrace_return_address(n) __builtin_return_address(n) |
c79a61f5 | 722 | # else |
eed542d6 | 723 | # define ftrace_return_address(n) 0UL |
c79a61f5 | 724 | # endif |
eed542d6 AT |
725 | #endif |
726 | ||
727 | #define CALLER_ADDR0 ((unsigned long)ftrace_return_address0) | |
728 | #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) | |
729 | #define CALLER_ADDR2 ((unsigned long)ftrace_return_address(2)) | |
730 | #define CALLER_ADDR3 ((unsigned long)ftrace_return_address(3)) | |
731 | #define CALLER_ADDR4 ((unsigned long)ftrace_return_address(4)) | |
732 | #define CALLER_ADDR5 ((unsigned long)ftrace_return_address(5)) | |
733 | #define CALLER_ADDR6 ((unsigned long)ftrace_return_address(6)) | |
352ad25a | 734 | |
f904f582 SAS |
735 | static inline unsigned long get_lock_parent_ip(void) |
736 | { | |
737 | unsigned long addr = CALLER_ADDR0; | |
738 | ||
739 | if (!in_lock_functions(addr)) | |
740 | return addr; | |
741 | addr = CALLER_ADDR1; | |
742 | if (!in_lock_functions(addr)) | |
743 | return addr; | |
744 | return CALLER_ADDR2; | |
745 | } | |
746 | ||
c3bc8fd6 | 747 | #ifdef CONFIG_TRACE_PREEMPT_TOGGLE |
489f1396 IM |
748 | extern void trace_preempt_on(unsigned long a0, unsigned long a1); |
749 | extern void trace_preempt_off(unsigned long a0, unsigned long a1); | |
6cd8a4bb | 750 | #else |
b02ee9a3 MB |
751 | /* |
752 | * Use defines instead of static inlines because some arches will make code out | |
753 | * of the CALLER_ADDR, when we really want these to be a real nop. | |
754 | */ | |
755 | # define trace_preempt_on(a0, a1) do { } while (0) | |
756 | # define trace_preempt_off(a0, a1) do { } while (0) | |
6cd8a4bb SR |
757 | #endif |
758 | ||
68bf21aa SR |
759 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
760 | extern void ftrace_init(void); | |
761 | #else | |
762 | static inline void ftrace_init(void) { } | |
763 | #endif | |
764 | ||
287b6e68 FW |
765 | /* |
766 | * Structure that defines an entry function trace. | |
a4a551b8 NK |
767 | * It's already packed but the attribute "packed" is needed |
768 | * to remove extra padding at the end. | |
287b6e68 FW |
769 | */ |
770 | struct ftrace_graph_ent { | |
771 | unsigned long func; /* Current function */ | |
772 | int depth; | |
a4a551b8 | 773 | } __packed; |
dd0e545f | 774 | |
caf4b323 FW |
775 | /* |
776 | * Structure that defines a return function trace. | |
a4a551b8 NK |
777 | * It's already packed but the attribute "packed" is needed |
778 | * to remove extra padding at the end. | |
caf4b323 | 779 | */ |
fb52607a | 780 | struct ftrace_graph_ret { |
caf4b323 | 781 | unsigned long func; /* Current function */ |
0231022c FW |
782 | /* Number of functions that overran the depth limit for current task */ |
783 | unsigned long overrun; | |
a4a551b8 NK |
784 | unsigned long long calltime; |
785 | unsigned long long rettime; | |
287b6e68 | 786 | int depth; |
a4a551b8 | 787 | } __packed; |
caf4b323 | 788 | |
62b915f1 JO |
789 | /* Type of the callback handlers for tracing function graph*/ |
790 | typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */ | |
791 | typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */ | |
792 | ||
e8025bab SRV |
793 | extern int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace); |
794 | ||
fb52607a | 795 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
8b96f011 | 796 | |
688f7089 SRV |
797 | struct fgraph_ops { |
798 | trace_func_graph_ent_t entryfunc; | |
799 | trace_func_graph_ret_t retfunc; | |
800 | }; | |
801 | ||
712406a6 SR |
802 | /* |
803 | * Stack of return addresses for functions | |
804 | * of a thread. | |
805 | * Used in struct thread_info | |
806 | */ | |
807 | struct ftrace_ret_stack { | |
808 | unsigned long ret; | |
809 | unsigned long func; | |
810 | unsigned long long calltime; | |
8861dd30 | 811 | #ifdef CONFIG_FUNCTION_PROFILER |
a2a16d6a | 812 | unsigned long long subtime; |
8861dd30 | 813 | #endif |
daa460a8 | 814 | #ifdef HAVE_FUNCTION_GRAPH_FP_TEST |
71e308a2 | 815 | unsigned long fp; |
daa460a8 | 816 | #endif |
9a7c348b JP |
817 | #ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR |
818 | unsigned long *retp; | |
819 | #endif | |
712406a6 SR |
820 | }; |
821 | ||
822 | /* | |
823 | * Primary handler of a function return. | |
824 | * It relays on ftrace_return_to_handler. | |
825 | * Defined in entry_32/64.S | |
826 | */ | |
827 | extern void return_to_handler(void); | |
828 | ||
829 | extern int | |
8114865f SRV |
830 | function_graph_enter(unsigned long ret, unsigned long func, |
831 | unsigned long frame_pointer, unsigned long *retp); | |
712406a6 | 832 | |
b0e21a61 SRV |
833 | struct ftrace_ret_stack * |
834 | ftrace_graph_get_ret_stack(struct task_struct *task, int idx); | |
835 | ||
223918e3 JP |
836 | unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx, |
837 | unsigned long ret, unsigned long *retp); | |
838 | ||
8b96f011 FW |
839 | /* |
840 | * Sometimes we don't want to trace a function with the function | |
841 | * graph tracer but we want them to keep traced by the usual function | |
842 | * tracer if the function graph tracer is not configured. | |
843 | */ | |
844 | #define __notrace_funcgraph notrace | |
845 | ||
f201ae23 FW |
846 | #define FTRACE_RETFUNC_DEPTH 50 |
847 | #define FTRACE_RETSTACK_ALLOC_SIZE 32 | |
688f7089 SRV |
848 | |
849 | extern int register_ftrace_graph(struct fgraph_ops *ops); | |
850 | extern void unregister_ftrace_graph(struct fgraph_ops *ops); | |
287b6e68 | 851 | |
1b2f121c | 852 | extern bool ftrace_graph_is_dead(void); |
14a866c5 SR |
853 | extern void ftrace_graph_stop(void); |
854 | ||
287b6e68 FW |
855 | /* The current handlers in use */ |
856 | extern trace_func_graph_ret_t ftrace_graph_return; | |
857 | extern trace_func_graph_ent_t ftrace_graph_entry; | |
caf4b323 | 858 | |
fb52607a FW |
859 | extern void ftrace_graph_init_task(struct task_struct *t); |
860 | extern void ftrace_graph_exit_task(struct task_struct *t); | |
868baf07 | 861 | extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu); |
21a8c466 | 862 | |
380c4b14 FW |
863 | static inline void pause_graph_tracing(void) |
864 | { | |
865 | atomic_inc(¤t->tracing_graph_pause); | |
866 | } | |
867 | ||
868 | static inline void unpause_graph_tracing(void) | |
869 | { | |
870 | atomic_dec(¤t->tracing_graph_pause); | |
871 | } | |
5ac9f622 | 872 | #else /* !CONFIG_FUNCTION_GRAPH_TRACER */ |
8b96f011 FW |
873 | |
874 | #define __notrace_funcgraph | |
875 | ||
fb52607a FW |
876 | static inline void ftrace_graph_init_task(struct task_struct *t) { } |
877 | static inline void ftrace_graph_exit_task(struct task_struct *t) { } | |
868baf07 | 878 | static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { } |
21a8c466 | 879 | |
688f7089 SRV |
880 | /* Define as macros as fgraph_ops may not be defined */ |
881 | #define register_ftrace_graph(ops) ({ -1; }) | |
882 | #define unregister_ftrace_graph(ops) do { } while (0) | |
380c4b14 | 883 | |
223918e3 JP |
884 | static inline unsigned long |
885 | ftrace_graph_ret_addr(struct task_struct *task, int *idx, unsigned long ret, | |
886 | unsigned long *retp) | |
887 | { | |
888 | return ret; | |
889 | } | |
890 | ||
380c4b14 FW |
891 | static inline void pause_graph_tracing(void) { } |
892 | static inline void unpause_graph_tracing(void) { } | |
5ac9f622 | 893 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ |
caf4b323 | 894 | |
ea4e2bc4 | 895 | #ifdef CONFIG_TRACING |
ea4e2bc4 SR |
896 | |
897 | /* flags for current->trace */ | |
898 | enum { | |
899 | TSK_TRACE_FL_TRACE_BIT = 0, | |
900 | TSK_TRACE_FL_GRAPH_BIT = 1, | |
901 | }; | |
902 | enum { | |
903 | TSK_TRACE_FL_TRACE = 1 << TSK_TRACE_FL_TRACE_BIT, | |
904 | TSK_TRACE_FL_GRAPH = 1 << TSK_TRACE_FL_GRAPH_BIT, | |
905 | }; | |
906 | ||
907 | static inline void set_tsk_trace_trace(struct task_struct *tsk) | |
908 | { | |
909 | set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace); | |
910 | } | |
911 | ||
912 | static inline void clear_tsk_trace_trace(struct task_struct *tsk) | |
913 | { | |
914 | clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace); | |
915 | } | |
916 | ||
917 | static inline int test_tsk_trace_trace(struct task_struct *tsk) | |
918 | { | |
919 | return tsk->trace & TSK_TRACE_FL_TRACE; | |
920 | } | |
921 | ||
922 | static inline void set_tsk_trace_graph(struct task_struct *tsk) | |
923 | { | |
924 | set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace); | |
925 | } | |
926 | ||
927 | static inline void clear_tsk_trace_graph(struct task_struct *tsk) | |
928 | { | |
929 | clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace); | |
930 | } | |
931 | ||
932 | static inline int test_tsk_trace_graph(struct task_struct *tsk) | |
933 | { | |
934 | return tsk->trace & TSK_TRACE_FL_GRAPH; | |
935 | } | |
936 | ||
cecbca96 FW |
937 | enum ftrace_dump_mode; |
938 | ||
939 | extern enum ftrace_dump_mode ftrace_dump_on_oops; | |
0daa2302 | 940 | extern int tracepoint_printk; |
526211bc | 941 | |
de7edd31 SRRH |
942 | extern void disable_trace_on_warning(void); |
943 | extern int __disable_trace_on_warning; | |
944 | ||
42391745 SRRH |
945 | int tracepoint_printk_sysctl(struct ctl_table *table, int write, |
946 | void __user *buffer, size_t *lenp, | |
947 | loff_t *ppos); | |
948 | ||
de7edd31 SRRH |
949 | #else /* CONFIG_TRACING */ |
950 | static inline void disable_trace_on_warning(void) { } | |
ea4e2bc4 SR |
951 | #endif /* CONFIG_TRACING */ |
952 | ||
e7b8e675 MF |
953 | #ifdef CONFIG_FTRACE_SYSCALLS |
954 | ||
955 | unsigned long arch_syscall_addr(int nr); | |
956 | ||
957 | #endif /* CONFIG_FTRACE_SYSCALLS */ | |
958 | ||
16444a8a | 959 | #endif /* _LINUX_FTRACE_H */ |