tracing/fastboot: get the initcall name before it disappears
[linux-2.6-block.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>
5601020f 10#include <linux/kallsyms.h>
16444a8a 11
b0fc494f
SR
12extern int ftrace_enabled;
13extern int
14ftrace_enable_sysctl(struct ctl_table *table, int write,
15 struct file *filp, void __user *buffer, size_t *lenp,
16 loff_t *ppos);
17
16444a8a
ACM
18typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
19
20struct ftrace_ops {
21 ftrace_func_t func;
22 struct ftrace_ops *next;
23};
24
25/*
26 * The ftrace_ops must be a static and should also
27 * be read_mostly. These functions do modify read_mostly variables
28 * so use them sparely. Never free an ftrace_op or modify the
29 * next pointer after it has been registered. Even after unregistering
30 * it, the next pointer may still be used internally.
31 */
32int register_ftrace_function(struct ftrace_ops *ops);
33int unregister_ftrace_function(struct ftrace_ops *ops);
34void clear_ftrace_function(void);
35
36extern void ftrace_stub(unsigned long a0, unsigned long a1);
16444a8a
ACM
37
38#else /* !CONFIG_FTRACE */
39# define register_ftrace_function(ops) do { } while (0)
40# define unregister_ftrace_function(ops) do { } while (0)
41# define clear_ftrace_function(ops) do { } while (0)
c5131ad6 42static inline void ftrace_kill_atomic(void) { }
16444a8a 43#endif /* CONFIG_FTRACE */
352ad25a 44
3d083395
SR
45#ifdef CONFIG_DYNAMIC_FTRACE
46# define FTRACE_HASHBITS 10
47# define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS)
48
3c1720f0 49enum {
37ad5084
SR
50 FTRACE_FL_FREE = (1 << 0),
51 FTRACE_FL_FAILED = (1 << 1),
52 FTRACE_FL_FILTER = (1 << 2),
53 FTRACE_FL_ENABLED = (1 << 3),
41c52c0d 54 FTRACE_FL_NOTRACE = (1 << 4),
0eb96701 55 FTRACE_FL_CONVERTED = (1 << 5),
ecea656d 56 FTRACE_FL_FROZEN = (1 << 6),
3c1720f0
SR
57};
58
3d083395
SR
59struct dyn_ftrace {
60 struct hlist_node node;
395a59d0 61 unsigned long ip; /* address of mcount call-site */
3c1720f0 62 unsigned long flags;
3d083395
SR
63};
64
e1c08bdd 65int ftrace_force_update(void);
77a2b37d 66void ftrace_set_filter(unsigned char *buf, int len, int reset);
e1c08bdd 67
3d083395 68/* defined in arch */
3c1720f0
SR
69extern int ftrace_ip_converted(unsigned long ip);
70extern unsigned char *ftrace_nop_replace(void);
71extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
d61f82d0
SR
72extern int ftrace_dyn_arch_init(void *data);
73extern int ftrace_mcount_set(unsigned long *data);
3c1720f0
SR
74extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
75 unsigned char *new_code);
d61f82d0
SR
76extern int ftrace_update_ftrace_func(ftrace_func_t func);
77extern void ftrace_caller(void);
78extern void ftrace_call(void);
79extern void mcount_call(void);
ad90c0e3 80
ecea656d
AS
81extern int skip_trace(unsigned long ip);
82
c0719e5a
SR
83extern void ftrace_release(void *start, unsigned long size);
84
85extern void ftrace_disable_daemon(void);
86extern void ftrace_enable_daemon(void);
ad90c0e3 87
e1c08bdd 88#else
ecea656d 89# define skip_trace(ip) ({ 0; })
aeaee8a2
IM
90# define ftrace_force_update() ({ 0; })
91# define ftrace_set_filter(buf, len, reset) do { } while (0)
ad90c0e3
SR
92# define ftrace_disable_daemon() do { } while (0)
93# define ftrace_enable_daemon() do { } while (0)
c0719e5a 94static inline void ftrace_release(void *start, unsigned long size) { }
ecea656d 95#endif /* CONFIG_DYNAMIC_FTRACE */
352ad25a 96
aeaee8a2
IM
97/* totally disable ftrace - can not re-enable after this */
98void ftrace_kill(void);
a2bb6a3d 99void ftrace_kill_atomic(void);
aeaee8a2 100
f43fdad8
IM
101static inline void tracer_disable(void)
102{
103#ifdef CONFIG_FTRACE
104 ftrace_enabled = 0;
105#endif
106}
107
37002735
HY
108/*
109 * Ftrace disable/restore without lock. Some synchronization mechanism
9bdeb7b5 110 * must be used to prevent ftrace_enabled to be changed between
37002735
HY
111 * disable/restore.
112 */
9bdeb7b5
HY
113static inline int __ftrace_enabled_save(void)
114{
115#ifdef CONFIG_FTRACE
116 int saved_ftrace_enabled = ftrace_enabled;
117 ftrace_enabled = 0;
118 return saved_ftrace_enabled;
119#else
120 return 0;
121#endif
122}
123
124static inline void __ftrace_enabled_restore(int enabled)
125{
126#ifdef CONFIG_FTRACE
127 ftrace_enabled = enabled;
128#endif
129}
130
352ad25a
SR
131#ifdef CONFIG_FRAME_POINTER
132/* TODO: need to fix this for ARM */
133# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
134# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
135# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
136# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
137# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
138# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
86387f7e 139# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
352ad25a
SR
140#else
141# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
142# define CALLER_ADDR1 0UL
143# define CALLER_ADDR2 0UL
144# define CALLER_ADDR3 0UL
145# define CALLER_ADDR4 0UL
146# define CALLER_ADDR5 0UL
86387f7e 147# define CALLER_ADDR6 0UL
352ad25a
SR
148#endif
149
81d68a96 150#ifdef CONFIG_IRQSOFF_TRACER
489f1396
IM
151 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
152 extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
81d68a96
SR
153#else
154# define time_hardirqs_on(a0, a1) do { } while (0)
155# define time_hardirqs_off(a0, a1) do { } while (0)
156#endif
157
6cd8a4bb 158#ifdef CONFIG_PREEMPT_TRACER
489f1396
IM
159 extern void trace_preempt_on(unsigned long a0, unsigned long a1);
160 extern void trace_preempt_off(unsigned long a0, unsigned long a1);
6cd8a4bb
SR
161#else
162# define trace_preempt_on(a0, a1) do { } while (0)
163# define trace_preempt_off(a0, a1) do { } while (0)
164#endif
165
b1829d27 166#ifdef CONFIG_TRACING
74f4e369
IM
167extern void
168ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
2f2c99db
SR
169
170/**
171 * ftrace_printk - printf formatting in the ftrace buffer
172 * @fmt: the printf format for printing
173 *
174 * Note: __ftrace_printk is an internal function for ftrace_printk and
175 * the @ip is passed in via the ftrace_printk macro.
176 *
177 * This function allows a kernel developer to debug fast path sections
178 * that printk is not appropriate for. By scattering in various
179 * printk like tracing in the code, a developer can quickly see
180 * where problems are occurring.
181 *
182 * This is intended as a debugging tool for the developer only.
183 * Please refrain from leaving ftrace_printks scattered around in
184 * your code.
185 */
186# define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt)
dd0e545f
SR
187extern int
188__ftrace_printk(unsigned long ip, const char *fmt, ...)
189 __attribute__ ((format (printf, 2, 3)));
3f5a54e3 190extern void ftrace_dump(void);
74f4e369
IM
191#else
192static inline void
193ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
dd0e545f 194static inline int
7b928c23
IM
195ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)));
196
197static inline int
198ftrace_printk(const char *fmt, ...)
dd0e545f
SR
199{
200 return 0;
201}
3f5a54e3 202static inline void ftrace_dump(void) { }
74f4e369
IM
203#endif
204
68bf21aa
SR
205#ifdef CONFIG_FTRACE_MCOUNT_RECORD
206extern void ftrace_init(void);
90d595fe 207extern void ftrace_init_module(unsigned long *start, unsigned long *end);
68bf21aa
SR
208#else
209static inline void ftrace_init(void) { }
90d595fe
SR
210static inline void
211ftrace_init_module(unsigned long *start, unsigned long *end) { }
68bf21aa
SR
212#endif
213
dd0e545f 214
d13744cd
FW
215struct boot_trace {
216 pid_t caller;
5601020f 217 char func[KSYM_NAME_LEN];
d13744cd
FW
218 int result;
219 unsigned long long duration;
cb5ab742
FW
220 ktime_t calltime;
221 ktime_t rettime;
d13744cd
FW
222};
223
224#ifdef CONFIG_BOOT_TRACER
5601020f 225extern void trace_boot(struct boot_trace *it, initcall_t fn);
d13744cd
FW
226extern void start_boot_trace(void);
227#else
5601020f 228static inline void trace_boot(struct boot_trace *it, initcall_t fn) { }
d13744cd
FW
229static inline void start_boot_trace(void) { }
230#endif
231
232
233
16444a8a 234#endif /* _LINUX_FTRACE_H */