]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/ftrace.h
tracing/fastboot: change the printing of boot tracer according to bootgraph.pl
[mirror_ubuntu-artful-kernel.git] / include / linux / ftrace.h
CommitLineData
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
11extern int ftrace_enabled;
12extern int
13ftrace_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
17typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
18
19struct 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 */
31int register_ftrace_function(struct ftrace_ops *ops);
32int unregister_ftrace_function(struct ftrace_ops *ops);
33void clear_ftrace_function(void);
34
35extern 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 41static 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 48enum {
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
58struct 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 64int ftrace_force_update(void);
77a2b37d 65void ftrace_set_filter(unsigned char *buf, int len, int reset);
e1c08bdd 66
3d083395 67/* defined in arch */
3c1720f0
SR
68extern int ftrace_ip_converted(unsigned long ip);
69extern unsigned char *ftrace_nop_replace(void);
70extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
d61f82d0
SR
71extern int ftrace_dyn_arch_init(void *data);
72extern int ftrace_mcount_set(unsigned long *data);
3c1720f0
SR
73extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
74 unsigned char *new_code);
d61f82d0
SR
75extern int ftrace_update_ftrace_func(ftrace_func_t func);
76extern void ftrace_caller(void);
77extern void ftrace_call(void);
78extern void mcount_call(void);
ad90c0e3 79
ecea656d
AS
80extern int skip_trace(unsigned long ip);
81
c0719e5a
SR
82extern void ftrace_release(void *start, unsigned long size);
83
84extern void ftrace_disable_daemon(void);
85extern 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 93static 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 */
97void ftrace_kill(void);
a2bb6a3d 98void ftrace_kill_atomic(void);
aeaee8a2 99
f43fdad8
IM
100static 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
112static 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
123static 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
166extern void
167ftrace_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
186extern int
187__ftrace_printk(unsigned long ip, const char *fmt, ...)
188 __attribute__ ((format (printf, 2, 3)));
3f5a54e3 189extern void ftrace_dump(void);
74f4e369
IM
190#else
191static inline void
192ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
dd0e545f 193static inline int
7b928c23
IM
194ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)));
195
196static inline int
197ftrace_printk(const char *fmt, ...)
dd0e545f
SR
198{
199 return 0;
200}
3f5a54e3 201static inline void ftrace_dump(void) { }
74f4e369
IM
202#endif
203
68bf21aa
SR
204#ifdef CONFIG_FTRACE_MCOUNT_RECORD
205extern void ftrace_init(void);
90d595fe 206extern void ftrace_init_module(unsigned long *start, unsigned long *end);
68bf21aa
SR
207#else
208static inline void ftrace_init(void) { }
90d595fe
SR
209static inline void
210ftrace_init_module(unsigned long *start, unsigned long *end) { }
68bf21aa
SR
211#endif
212
dd0e545f 213
d13744cd
FW
214struct 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
224extern void trace_boot(struct boot_trace *it);
225extern void start_boot_trace(void);
226#else
227static inline void trace_boot(struct boot_trace *it) { }
228static inline void start_boot_trace(void) { }
229#endif
230
231
232
16444a8a 233#endif /* _LINUX_FTRACE_H */