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