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