]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/ftrace.h
ftrace: mcount call site on boot nops core
[net-next-2.6.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>
16444a8a 8
b0fc494f
SR
9extern int ftrace_enabled;
10extern int
11ftrace_enable_sysctl(struct ctl_table *table, int write,
12 struct file *filp, void __user *buffer, size_t *lenp,
13 loff_t *ppos);
14
16444a8a
ACM
15typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
16
17struct 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 */
29int register_ftrace_function(struct ftrace_ops *ops);
30int unregister_ftrace_function(struct ftrace_ops *ops);
31void clear_ftrace_function(void);
32
33extern void ftrace_stub(unsigned long a0, unsigned long a1);
16444a8a
ACM
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#endif /* CONFIG_FTRACE */
352ad25a 40
3d083395
SR
41#ifdef CONFIG_DYNAMIC_FTRACE
42# define FTRACE_HASHBITS 10
43# define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS)
44
3c1720f0 45enum {
37ad5084
SR
46 FTRACE_FL_FREE = (1 << 0),
47 FTRACE_FL_FAILED = (1 << 1),
48 FTRACE_FL_FILTER = (1 << 2),
49 FTRACE_FL_ENABLED = (1 << 3),
41c52c0d 50 FTRACE_FL_NOTRACE = (1 << 4),
0eb96701 51 FTRACE_FL_CONVERTED = (1 << 5),
ecea656d 52 FTRACE_FL_FROZEN = (1 << 6),
3c1720f0
SR
53};
54
3d083395
SR
55struct dyn_ftrace {
56 struct hlist_node node;
395a59d0 57 unsigned long ip; /* address of mcount call-site */
3c1720f0 58 unsigned long flags;
3d083395
SR
59};
60
e1c08bdd 61int ftrace_force_update(void);
77a2b37d 62void ftrace_set_filter(unsigned char *buf, int len, int reset);
e1c08bdd 63
3d083395 64/* defined in arch */
3c1720f0
SR
65extern int ftrace_ip_converted(unsigned long ip);
66extern unsigned char *ftrace_nop_replace(void);
67extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
d61f82d0
SR
68extern int ftrace_dyn_arch_init(void *data);
69extern int ftrace_mcount_set(unsigned long *data);
3c1720f0
SR
70extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
71 unsigned char *new_code);
d61f82d0
SR
72extern int ftrace_update_ftrace_func(ftrace_func_t func);
73extern void ftrace_caller(void);
74extern void ftrace_call(void);
75extern void mcount_call(void);
ad90c0e3 76
ecea656d
AS
77extern int skip_trace(unsigned long ip);
78
ad90c0e3
SR
79void ftrace_disable_daemon(void);
80void ftrace_enable_daemon(void);
81
e1c08bdd 82#else
ecea656d 83# define skip_trace(ip) ({ 0; })
aeaee8a2
IM
84# define ftrace_force_update() ({ 0; })
85# define ftrace_set_filter(buf, len, reset) do { } while (0)
ad90c0e3
SR
86# define ftrace_disable_daemon() do { } while (0)
87# define ftrace_enable_daemon() do { } while (0)
ecea656d 88#endif /* CONFIG_DYNAMIC_FTRACE */
352ad25a 89
aeaee8a2
IM
90/* totally disable ftrace - can not re-enable after this */
91void ftrace_kill(void);
a2bb6a3d 92void ftrace_kill_atomic(void);
aeaee8a2 93
f43fdad8
IM
94static inline void tracer_disable(void)
95{
96#ifdef CONFIG_FTRACE
97 ftrace_enabled = 0;
98#endif
99}
100
9bdeb7b5
HY
101/* Ftrace disable/restore without lock. Some synchronization mechanism
102 * must be used to prevent ftrace_enabled to be changed between
103 * disable/restore. */
104static inline int __ftrace_enabled_save(void)
105{
106#ifdef CONFIG_FTRACE
107 int saved_ftrace_enabled = ftrace_enabled;
108 ftrace_enabled = 0;
109 return saved_ftrace_enabled;
110#else
111 return 0;
112#endif
113}
114
115static inline void __ftrace_enabled_restore(int enabled)
116{
117#ifdef CONFIG_FTRACE
118 ftrace_enabled = enabled;
119#endif
120}
121
352ad25a
SR
122#ifdef CONFIG_FRAME_POINTER
123/* TODO: need to fix this for ARM */
124# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
125# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
126# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
127# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
128# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
129# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
86387f7e 130# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
352ad25a
SR
131#else
132# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
133# define CALLER_ADDR1 0UL
134# define CALLER_ADDR2 0UL
135# define CALLER_ADDR3 0UL
136# define CALLER_ADDR4 0UL
137# define CALLER_ADDR5 0UL
86387f7e 138# define CALLER_ADDR6 0UL
352ad25a
SR
139#endif
140
81d68a96 141#ifdef CONFIG_IRQSOFF_TRACER
489f1396
IM
142 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
143 extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
81d68a96
SR
144#else
145# define time_hardirqs_on(a0, a1) do { } while (0)
146# define time_hardirqs_off(a0, a1) do { } while (0)
147#endif
148
6cd8a4bb 149#ifdef CONFIG_PREEMPT_TRACER
489f1396
IM
150 extern void trace_preempt_on(unsigned long a0, unsigned long a1);
151 extern void trace_preempt_off(unsigned long a0, unsigned long a1);
6cd8a4bb
SR
152#else
153# define trace_preempt_on(a0, a1) do { } while (0)
154# define trace_preempt_off(a0, a1) do { } while (0)
155#endif
156
b1829d27 157#ifdef CONFIG_TRACING
74f4e369
IM
158extern void
159ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
160#else
161static inline void
162ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
163#endif
164
68bf21aa
SR
165#ifdef CONFIG_FTRACE_MCOUNT_RECORD
166extern void ftrace_init(void);
167#else
168static inline void ftrace_init(void) { }
169#endif
170
16444a8a 171#endif /* _LINUX_FTRACE_H */