diff options
Diffstat (limited to 'include/linux/ftrace.h')
-rw-r--r-- | include/linux/ftrace.h | 138 |
1 files changed, 110 insertions, 28 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 703eb53cfa2b..f7ba4ea5e128 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
@@ -23,6 +23,45 @@ struct ftrace_ops { | |||
23 | struct ftrace_ops *next; | 23 | struct ftrace_ops *next; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | extern int function_trace_stop; | ||
27 | |||
28 | /* | ||
29 | * Type of the current tracing. | ||
30 | */ | ||
31 | enum ftrace_tracing_type_t { | ||
32 | FTRACE_TYPE_ENTER = 0, /* Hook the call of the function */ | ||
33 | FTRACE_TYPE_RETURN, /* Hook the return of the function */ | ||
34 | }; | ||
35 | |||
36 | /* Current tracing type, default is FTRACE_TYPE_ENTER */ | ||
37 | extern enum ftrace_tracing_type_t ftrace_tracing_type; | ||
38 | |||
39 | /** | ||
40 | * ftrace_stop - stop function tracer. | ||
41 | * | ||
42 | * A quick way to stop the function tracer. Note this an on off switch, | ||
43 | * it is not something that is recursive like preempt_disable. | ||
44 | * This does not disable the calling of mcount, it only stops the | ||
45 | * calling of functions from mcount. | ||
46 | */ | ||
47 | static inline void ftrace_stop(void) | ||
48 | { | ||
49 | function_trace_stop = 1; | ||
50 | } | ||
51 | |||
52 | /** | ||
53 | * ftrace_start - start the function tracer. | ||
54 | * | ||
55 | * This function is the inverse of ftrace_stop. This does not enable | ||
56 | * the function tracing if the function tracer is disabled. This only | ||
57 | * sets the function tracer flag to continue calling the functions | ||
58 | * from mcount. | ||
59 | */ | ||
60 | static inline void ftrace_start(void) | ||
61 | { | ||
62 | function_trace_stop = 0; | ||
63 | } | ||
64 | |||
26 | /* | 65 | /* |
27 | * The ftrace_ops must be a static and should also | 66 | * The ftrace_ops must be a static and should also |
28 | * be read_mostly. These functions do modify read_mostly variables | 67 | * be read_mostly. These functions do modify read_mostly variables |
@@ -41,9 +80,13 @@ extern void ftrace_stub(unsigned long a0, unsigned long a1); | |||
41 | # define unregister_ftrace_function(ops) do { } while (0) | 80 | # define unregister_ftrace_function(ops) do { } while (0) |
42 | # define clear_ftrace_function(ops) do { } while (0) | 81 | # define clear_ftrace_function(ops) do { } while (0) |
43 | static inline void ftrace_kill(void) { } | 82 | static inline void ftrace_kill(void) { } |
83 | static inline void ftrace_stop(void) { } | ||
84 | static inline void ftrace_start(void) { } | ||
44 | #endif /* CONFIG_FUNCTION_TRACER */ | 85 | #endif /* CONFIG_FUNCTION_TRACER */ |
45 | 86 | ||
46 | #ifdef CONFIG_DYNAMIC_FTRACE | 87 | #ifdef CONFIG_DYNAMIC_FTRACE |
88 | /* asm/ftrace.h must be defined for archs supporting dynamic ftrace */ | ||
89 | #include <asm/ftrace.h> | ||
47 | 90 | ||
48 | enum { | 91 | enum { |
49 | FTRACE_FL_FREE = (1 << 0), | 92 | FTRACE_FL_FREE = (1 << 0), |
@@ -59,6 +102,7 @@ struct dyn_ftrace { | |||
59 | struct list_head list; | 102 | struct list_head list; |
60 | unsigned long ip; /* address of mcount call-site */ | 103 | unsigned long ip; /* address of mcount call-site */ |
61 | unsigned long flags; | 104 | unsigned long flags; |
105 | struct dyn_arch_ftrace arch; | ||
62 | }; | 106 | }; |
63 | 107 | ||
64 | int ftrace_force_update(void); | 108 | int ftrace_force_update(void); |
@@ -66,19 +110,43 @@ void ftrace_set_filter(unsigned char *buf, int len, int reset); | |||
66 | 110 | ||
67 | /* defined in arch */ | 111 | /* defined in arch */ |
68 | extern int ftrace_ip_converted(unsigned long ip); | 112 | 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); | 113 | extern int ftrace_dyn_arch_init(void *data); |
72 | extern int ftrace_update_ftrace_func(ftrace_func_t func); | 114 | extern int ftrace_update_ftrace_func(ftrace_func_t func); |
73 | extern void ftrace_caller(void); | 115 | extern void ftrace_caller(void); |
74 | extern void ftrace_call(void); | 116 | extern void ftrace_call(void); |
75 | extern void mcount_call(void); | 117 | extern void mcount_call(void); |
118 | #ifdef CONFIG_FUNCTION_RET_TRACER | ||
119 | extern void ftrace_return_caller(void); | ||
120 | #endif | ||
121 | |||
122 | /** | ||
123 | * ftrace_make_nop - convert code into top | ||
124 | * @mod: module structure if called by module load initialization | ||
125 | * @rec: the mcount call site record | ||
126 | * @addr: the address that the call site should be calling | ||
127 | * | ||
128 | * This is a very sensitive operation and great care needs | ||
129 | * to be taken by the arch. The operation should carefully | ||
130 | * read the location, check to see if what is read is indeed | ||
131 | * what we expect it to be, and then on success of the compare, | ||
132 | * it should write to the location. | ||
133 | * | ||
134 | * The code segment at @rec->ip should be a caller to @addr | ||
135 | * | ||
136 | * Return must be: | ||
137 | * 0 on success | ||
138 | * -EFAULT on error reading the location | ||
139 | * -EINVAL on a failed compare of the contents | ||
140 | * -EPERM on error writing to the location | ||
141 | * Any other value will be considered a failure. | ||
142 | */ | ||
143 | extern int ftrace_make_nop(struct module *mod, | ||
144 | struct dyn_ftrace *rec, unsigned long addr); | ||
76 | 145 | ||
77 | /** | 146 | /** |
78 | * ftrace_modify_code - modify code segment | 147 | * ftrace_make_call - convert a nop call site into a call to addr |
79 | * @ip: the address of the code segment | 148 | * @rec: the mcount call site record |
80 | * @old_code: the contents of what is expected to be there | 149 | * @addr: the address that the call site should call |
81 | * @new_code: the code to patch in | ||
82 | * | 150 | * |
83 | * This is a very sensitive operation and great care needs | 151 | * This is a very sensitive operation and great care needs |
84 | * to be taken by the arch. The operation should carefully | 152 | * to be taken by the arch. The operation should carefully |
@@ -86,6 +154,8 @@ extern void mcount_call(void); | |||
86 | * what we expect it to be, and then on success of the compare, | 154 | * what we expect it to be, and then on success of the compare, |
87 | * it should write to the location. | 155 | * it should write to the location. |
88 | * | 156 | * |
157 | * The code segment at @rec->ip should be a nop | ||
158 | * | ||
89 | * Return must be: | 159 | * Return must be: |
90 | * 0 on success | 160 | * 0 on success |
91 | * -EFAULT on error reading the location | 161 | * -EFAULT on error reading the location |
@@ -93,8 +163,11 @@ extern void mcount_call(void); | |||
93 | * -EPERM on error writing to the location | 163 | * -EPERM on error writing to the location |
94 | * Any other value will be considered a failure. | 164 | * Any other value will be considered a failure. |
95 | */ | 165 | */ |
96 | extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code, | 166 | extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr); |
97 | unsigned char *new_code); | 167 | |
168 | |||
169 | /* May be defined in arch */ | ||
170 | extern int ftrace_arch_read_dyn_info(char *buf, int size); | ||
98 | 171 | ||
99 | extern int skip_trace(unsigned long ip); | 172 | extern int skip_trace(unsigned long ip); |
100 | 173 | ||
@@ -102,7 +175,6 @@ extern void ftrace_release(void *start, unsigned long size); | |||
102 | 175 | ||
103 | extern void ftrace_disable_daemon(void); | 176 | extern void ftrace_disable_daemon(void); |
104 | extern void ftrace_enable_daemon(void); | 177 | extern void ftrace_enable_daemon(void); |
105 | |||
106 | #else | 178 | #else |
107 | # define skip_trace(ip) ({ 0; }) | 179 | # define skip_trace(ip) ({ 0; }) |
108 | # define ftrace_force_update() ({ 0; }) | 180 | # define ftrace_force_update() ({ 0; }) |
@@ -181,6 +253,11 @@ static inline void __ftrace_enabled_restore(int enabled) | |||
181 | #endif | 253 | #endif |
182 | 254 | ||
183 | #ifdef CONFIG_TRACING | 255 | #ifdef CONFIG_TRACING |
256 | extern int ftrace_dump_on_oops; | ||
257 | |||
258 | extern void tracing_start(void); | ||
259 | extern void tracing_stop(void); | ||
260 | |||
184 | extern void | 261 | extern void |
185 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); | 262 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); |
186 | 263 | ||
@@ -211,6 +288,8 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } | |||
211 | static inline int | 288 | static inline int |
212 | ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0))); | 289 | ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0))); |
213 | 290 | ||
291 | static inline void tracing_start(void) { } | ||
292 | static inline void tracing_stop(void) { } | ||
214 | static inline int | 293 | static inline int |
215 | ftrace_printk(const char *fmt, ...) | 294 | ftrace_printk(const char *fmt, ...) |
216 | { | 295 | { |
@@ -221,33 +300,36 @@ static inline void ftrace_dump(void) { } | |||
221 | 300 | ||
222 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD | 301 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
223 | extern void ftrace_init(void); | 302 | extern void ftrace_init(void); |
224 | extern void ftrace_init_module(unsigned long *start, unsigned long *end); | 303 | extern void ftrace_init_module(struct module *mod, |
304 | unsigned long *start, unsigned long *end); | ||
225 | #else | 305 | #else |
226 | static inline void ftrace_init(void) { } | 306 | static inline void ftrace_init(void) { } |
227 | static inline void | 307 | static inline void |
228 | ftrace_init_module(unsigned long *start, unsigned long *end) { } | 308 | ftrace_init_module(struct module *mod, |
309 | unsigned long *start, unsigned long *end) { } | ||
229 | #endif | 310 | #endif |
230 | 311 | ||
231 | 312 | ||
232 | struct boot_trace { | 313 | /* |
233 | pid_t caller; | 314 | * Structure that defines a return function trace. |
234 | char func[KSYM_NAME_LEN]; | 315 | */ |
235 | int result; | 316 | struct ftrace_retfunc { |
236 | unsigned long long duration; /* usecs */ | 317 | unsigned long ret; /* Return address */ |
237 | ktime_t calltime; | 318 | unsigned long func; /* Current function */ |
238 | ktime_t rettime; | 319 | unsigned long long calltime; |
320 | unsigned long long rettime; | ||
321 | /* Number of functions that overran the depth limit for current task */ | ||
322 | unsigned long overrun; | ||
239 | }; | 323 | }; |
240 | 324 | ||
241 | #ifdef CONFIG_BOOT_TRACER | 325 | #ifdef CONFIG_FUNCTION_RET_TRACER |
242 | extern void trace_boot(struct boot_trace *it, initcall_t fn); | 326 | /* Type of a callback handler of tracing return function */ |
243 | extern void start_boot_trace(void); | 327 | typedef void (*trace_function_return_t)(struct ftrace_retfunc *); |
244 | extern void stop_boot_trace(void); | ||
245 | #else | ||
246 | static inline void trace_boot(struct boot_trace *it, initcall_t fn) { } | ||
247 | static inline void start_boot_trace(void) { } | ||
248 | static inline void stop_boot_trace(void) { } | ||
249 | #endif | ||
250 | |||
251 | 328 | ||
329 | extern int register_ftrace_return(trace_function_return_t func); | ||
330 | /* The current handler in use */ | ||
331 | extern trace_function_return_t ftrace_function_return; | ||
332 | extern void unregister_ftrace_return(void); | ||
333 | #endif | ||
252 | 334 | ||
253 | #endif /* _LINUX_FTRACE_H */ | 335 | #endif /* _LINUX_FTRACE_H */ |