tracing/fastboot: change the printing of boot tracer according to bootgraph.pl
[safe/jmp/linux-2.6] / include / linux / ftrace.h
1 #ifndef _LINUX_FTRACE_H
2 #define _LINUX_FTRACE_H
3
4 #ifdef CONFIG_FTRACE
5
6 #include <linux/linkage.h>
7 #include <linux/fs.h>
8 #include <linux/init.h>
9 #include <linux/types.h>
10
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
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);
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)
41 static inline void ftrace_kill_atomic(void) { }
42 #endif /* CONFIG_FTRACE */
43
44 #ifdef CONFIG_DYNAMIC_FTRACE
45 # define FTRACE_HASHBITS        10
46 # define FTRACE_HASHSIZE        (1<<FTRACE_HASHBITS)
47
48 enum {
49         FTRACE_FL_FREE          = (1 << 0),
50         FTRACE_FL_FAILED        = (1 << 1),
51         FTRACE_FL_FILTER        = (1 << 2),
52         FTRACE_FL_ENABLED       = (1 << 3),
53         FTRACE_FL_NOTRACE       = (1 << 4),
54         FTRACE_FL_CONVERTED     = (1 << 5),
55         FTRACE_FL_FROZEN        = (1 << 6),
56 };
57
58 struct dyn_ftrace {
59         struct hlist_node node;
60         unsigned long     ip; /* address of mcount call-site */
61         unsigned long     flags;
62 };
63
64 int ftrace_force_update(void);
65 void ftrace_set_filter(unsigned char *buf, int len, int reset);
66
67 /* defined in arch */
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);
71 extern int ftrace_dyn_arch_init(void *data);
72 extern int ftrace_mcount_set(unsigned long *data);
73 extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
74                               unsigned char *new_code);
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);
79
80 extern int skip_trace(unsigned long ip);
81
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);
86
87 #else
88 # define skip_trace(ip)                         ({ 0; })
89 # define ftrace_force_update()                  ({ 0; })
90 # define ftrace_set_filter(buf, len, reset)     do { } while (0)
91 # define ftrace_disable_daemon()                do { } while (0)
92 # define ftrace_enable_daemon()                 do { } while (0)
93 static inline void ftrace_release(void *start, unsigned long size) { }
94 #endif /* CONFIG_DYNAMIC_FTRACE */
95
96 /* totally disable ftrace - can not re-enable after this */
97 void ftrace_kill(void);
98 void ftrace_kill_atomic(void);
99
100 static inline void tracer_disable(void)
101 {
102 #ifdef CONFIG_FTRACE
103         ftrace_enabled = 0;
104 #endif
105 }
106
107 /*
108  * Ftrace disable/restore without lock. Some synchronization mechanism
109  * must be used to prevent ftrace_enabled to be changed between
110  * disable/restore.
111  */
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
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))
138 # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
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
146 # define CALLER_ADDR6 0UL
147 #endif
148
149 #ifdef CONFIG_IRQSOFF_TRACER
150   extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
151   extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
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
157 #ifdef CONFIG_PREEMPT_TRACER
158   extern void trace_preempt_on(unsigned long a0, unsigned long a1);
159   extern void trace_preempt_off(unsigned long a0, unsigned long a1);
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
165 #ifdef CONFIG_TRACING
166 extern void
167 ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
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)
186 extern int
187 __ftrace_printk(unsigned long ip, const char *fmt, ...)
188         __attribute__ ((format (printf, 2, 3)));
189 extern void ftrace_dump(void);
190 #else
191 static inline void
192 ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
193 static inline int
194 ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)));
195
196 static inline int
197 ftrace_printk(const char *fmt, ...)
198 {
199         return 0;
200 }
201 static inline void ftrace_dump(void) { }
202 #endif
203
204 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
205 extern void ftrace_init(void);
206 extern void ftrace_init_module(unsigned long *start, unsigned long *end);
207 #else
208 static inline void ftrace_init(void) { }
209 static inline void
210 ftrace_init_module(unsigned long *start, unsigned long *end) { }
211 #endif
212
213
214 struct boot_trace {
215         pid_t                   caller;
216         initcall_t              func;
217         int                     result;
218         unsigned long long      duration;
219         ktime_t                 calltime;
220         ktime_t                 rettime;
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
233 #endif /* _LINUX_FTRACE_H */