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