Commit | Line | Data |
---|---|---|
16444a8a ACM |
1 | /* |
2 | * Infrastructure for profiling code inserted by 'gcc -pg'. | |
3 | * | |
4 | * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com> | |
5 | * Copyright (C) 2004-2008 Ingo Molnar <mingo@redhat.com> | |
6 | * | |
7 | * Originally ported from the -rt patch by: | |
8 | * Copyright (C) 2007 Arnaldo Carvalho de Melo <acme@redhat.com> | |
9 | * | |
10 | * Based on code in the latency_tracer, that is: | |
11 | * | |
12 | * Copyright (C) 2004-2006 Ingo Molnar | |
13 | * Copyright (C) 2004 William Lee Irwin III | |
14 | */ | |
15 | ||
3d083395 SR |
16 | #include <linux/stop_machine.h> |
17 | #include <linux/clocksource.h> | |
18 | #include <linux/kallsyms.h> | |
5072c59f | 19 | #include <linux/seq_file.h> |
4a2b8dda | 20 | #include <linux/suspend.h> |
5072c59f | 21 | #include <linux/debugfs.h> |
3d083395 | 22 | #include <linux/hardirq.h> |
2d8b820b | 23 | #include <linux/kthread.h> |
5072c59f | 24 | #include <linux/uaccess.h> |
f22f9a89 | 25 | #include <linux/kprobes.h> |
2d8b820b | 26 | #include <linux/ftrace.h> |
b0fc494f | 27 | #include <linux/sysctl.h> |
5072c59f | 28 | #include <linux/ctype.h> |
3d083395 | 29 | #include <linux/list.h> |
59df055f | 30 | #include <linux/hash.h> |
3d083395 | 31 | |
8aef2d28 SR |
32 | #include <trace/sched.h> |
33 | ||
395a59d0 AS |
34 | #include <asm/ftrace.h> |
35 | ||
3d083395 | 36 | #include "trace.h" |
16444a8a | 37 | |
6912896e SR |
38 | #define FTRACE_WARN_ON(cond) \ |
39 | do { \ | |
40 | if (WARN_ON(cond)) \ | |
41 | ftrace_kill(); \ | |
42 | } while (0) | |
43 | ||
44 | #define FTRACE_WARN_ON_ONCE(cond) \ | |
45 | do { \ | |
46 | if (WARN_ON_ONCE(cond)) \ | |
47 | ftrace_kill(); \ | |
48 | } while (0) | |
49 | ||
8fc0c701 SR |
50 | /* hash bits for specific function selection */ |
51 | #define FTRACE_HASH_BITS 7 | |
52 | #define FTRACE_FUNC_HASHSIZE (1 << FTRACE_HASH_BITS) | |
53 | ||
4eebcc81 SR |
54 | /* ftrace_enabled is a method to turn ftrace on or off */ |
55 | int ftrace_enabled __read_mostly; | |
d61f82d0 | 56 | static int last_ftrace_enabled; |
b0fc494f | 57 | |
60a7ecf4 SR |
58 | /* Quick disabling of function tracer. */ |
59 | int function_trace_stop; | |
60 | ||
4eebcc81 SR |
61 | /* |
62 | * ftrace_disabled is set when an anomaly is discovered. | |
63 | * ftrace_disabled is much stronger than ftrace_enabled. | |
64 | */ | |
65 | static int ftrace_disabled __read_mostly; | |
66 | ||
52baf119 | 67 | static DEFINE_MUTEX(ftrace_lock); |
b0fc494f | 68 | |
16444a8a ACM |
69 | static struct ftrace_ops ftrace_list_end __read_mostly = |
70 | { | |
71 | .func = ftrace_stub, | |
72 | }; | |
73 | ||
74 | static struct ftrace_ops *ftrace_list __read_mostly = &ftrace_list_end; | |
75 | ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub; | |
60a7ecf4 | 76 | ftrace_func_t __ftrace_trace_function __read_mostly = ftrace_stub; |
df4fc315 | 77 | ftrace_func_t ftrace_pid_function __read_mostly = ftrace_stub; |
16444a8a | 78 | |
f2252935 | 79 | static void ftrace_list_func(unsigned long ip, unsigned long parent_ip) |
16444a8a ACM |
80 | { |
81 | struct ftrace_ops *op = ftrace_list; | |
82 | ||
83 | /* in case someone actually ports this to alpha! */ | |
84 | read_barrier_depends(); | |
85 | ||
86 | while (op != &ftrace_list_end) { | |
87 | /* silly alpha */ | |
88 | read_barrier_depends(); | |
89 | op->func(ip, parent_ip); | |
90 | op = op->next; | |
91 | }; | |
92 | } | |
93 | ||
df4fc315 SR |
94 | static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip) |
95 | { | |
0ef8cde5 | 96 | if (!test_tsk_trace_trace(current)) |
df4fc315 SR |
97 | return; |
98 | ||
99 | ftrace_pid_function(ip, parent_ip); | |
100 | } | |
101 | ||
102 | static void set_ftrace_pid_function(ftrace_func_t func) | |
103 | { | |
104 | /* do not set ftrace_pid_function to itself! */ | |
105 | if (func != ftrace_pid_func) | |
106 | ftrace_pid_function = func; | |
107 | } | |
108 | ||
16444a8a | 109 | /** |
3d083395 | 110 | * clear_ftrace_function - reset the ftrace function |
16444a8a | 111 | * |
3d083395 SR |
112 | * This NULLs the ftrace function and in essence stops |
113 | * tracing. There may be lag | |
16444a8a | 114 | */ |
3d083395 | 115 | void clear_ftrace_function(void) |
16444a8a | 116 | { |
3d083395 | 117 | ftrace_trace_function = ftrace_stub; |
60a7ecf4 | 118 | __ftrace_trace_function = ftrace_stub; |
df4fc315 | 119 | ftrace_pid_function = ftrace_stub; |
3d083395 SR |
120 | } |
121 | ||
60a7ecf4 SR |
122 | #ifndef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST |
123 | /* | |
124 | * For those archs that do not test ftrace_trace_stop in their | |
125 | * mcount call site, we need to do it from C. | |
126 | */ | |
127 | static void ftrace_test_stop_func(unsigned long ip, unsigned long parent_ip) | |
128 | { | |
129 | if (function_trace_stop) | |
130 | return; | |
131 | ||
132 | __ftrace_trace_function(ip, parent_ip); | |
133 | } | |
134 | #endif | |
135 | ||
e309b41d | 136 | static int __register_ftrace_function(struct ftrace_ops *ops) |
3d083395 | 137 | { |
16444a8a ACM |
138 | ops->next = ftrace_list; |
139 | /* | |
140 | * We are entering ops into the ftrace_list but another | |
141 | * CPU might be walking that list. We need to make sure | |
142 | * the ops->next pointer is valid before another CPU sees | |
143 | * the ops pointer included into the ftrace_list. | |
144 | */ | |
145 | smp_wmb(); | |
146 | ftrace_list = ops; | |
3d083395 | 147 | |
b0fc494f | 148 | if (ftrace_enabled) { |
df4fc315 SR |
149 | ftrace_func_t func; |
150 | ||
151 | if (ops->next == &ftrace_list_end) | |
152 | func = ops->func; | |
153 | else | |
154 | func = ftrace_list_func; | |
155 | ||
978f3a45 | 156 | if (ftrace_pid_trace) { |
df4fc315 SR |
157 | set_ftrace_pid_function(func); |
158 | func = ftrace_pid_func; | |
159 | } | |
160 | ||
b0fc494f SR |
161 | /* |
162 | * For one func, simply call it directly. | |
163 | * For more than one func, call the chain. | |
164 | */ | |
60a7ecf4 | 165 | #ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST |
df4fc315 | 166 | ftrace_trace_function = func; |
60a7ecf4 | 167 | #else |
df4fc315 | 168 | __ftrace_trace_function = func; |
60a7ecf4 SR |
169 | ftrace_trace_function = ftrace_test_stop_func; |
170 | #endif | |
b0fc494f | 171 | } |
3d083395 | 172 | |
16444a8a ACM |
173 | return 0; |
174 | } | |
175 | ||
e309b41d | 176 | static int __unregister_ftrace_function(struct ftrace_ops *ops) |
16444a8a | 177 | { |
16444a8a | 178 | struct ftrace_ops **p; |
16444a8a ACM |
179 | |
180 | /* | |
3d083395 SR |
181 | * If we are removing the last function, then simply point |
182 | * to the ftrace_stub. | |
16444a8a ACM |
183 | */ |
184 | if (ftrace_list == ops && ops->next == &ftrace_list_end) { | |
185 | ftrace_trace_function = ftrace_stub; | |
186 | ftrace_list = &ftrace_list_end; | |
e6ea44e9 | 187 | return 0; |
16444a8a ACM |
188 | } |
189 | ||
190 | for (p = &ftrace_list; *p != &ftrace_list_end; p = &(*p)->next) | |
191 | if (*p == ops) | |
192 | break; | |
193 | ||
e6ea44e9 SR |
194 | if (*p != ops) |
195 | return -1; | |
16444a8a ACM |
196 | |
197 | *p = (*p)->next; | |
198 | ||
b0fc494f SR |
199 | if (ftrace_enabled) { |
200 | /* If we only have one func left, then call that directly */ | |
df4fc315 SR |
201 | if (ftrace_list->next == &ftrace_list_end) { |
202 | ftrace_func_t func = ftrace_list->func; | |
203 | ||
978f3a45 | 204 | if (ftrace_pid_trace) { |
df4fc315 SR |
205 | set_ftrace_pid_function(func); |
206 | func = ftrace_pid_func; | |
207 | } | |
208 | #ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST | |
209 | ftrace_trace_function = func; | |
210 | #else | |
211 | __ftrace_trace_function = func; | |
212 | #endif | |
213 | } | |
b0fc494f | 214 | } |
16444a8a | 215 | |
e6ea44e9 | 216 | return 0; |
3d083395 SR |
217 | } |
218 | ||
df4fc315 SR |
219 | static void ftrace_update_pid_func(void) |
220 | { | |
221 | ftrace_func_t func; | |
222 | ||
df4fc315 | 223 | if (ftrace_trace_function == ftrace_stub) |
10dd3ebe | 224 | return; |
df4fc315 SR |
225 | |
226 | func = ftrace_trace_function; | |
227 | ||
978f3a45 | 228 | if (ftrace_pid_trace) { |
df4fc315 SR |
229 | set_ftrace_pid_function(func); |
230 | func = ftrace_pid_func; | |
231 | } else { | |
66eafebc LW |
232 | if (func == ftrace_pid_func) |
233 | func = ftrace_pid_function; | |
df4fc315 SR |
234 | } |
235 | ||
236 | #ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST | |
237 | ftrace_trace_function = func; | |
238 | #else | |
239 | __ftrace_trace_function = func; | |
240 | #endif | |
df4fc315 SR |
241 | } |
242 | ||
73d3fd96 IM |
243 | /* set when tracing only a pid */ |
244 | struct pid *ftrace_pid_trace; | |
245 | static struct pid * const ftrace_swapper_pid = &init_struct_pid; | |
246 | ||
3d083395 | 247 | #ifdef CONFIG_DYNAMIC_FTRACE |
73d3fd96 | 248 | |
99ecdc43 | 249 | #ifndef CONFIG_FTRACE_MCOUNT_RECORD |
cb7be3b2 | 250 | # error Dynamic ftrace depends on MCOUNT_RECORD |
99ecdc43 SR |
251 | #endif |
252 | ||
8fc0c701 SR |
253 | static struct hlist_head ftrace_func_hash[FTRACE_FUNC_HASHSIZE] __read_mostly; |
254 | ||
b6887d79 | 255 | struct ftrace_func_probe { |
8fc0c701 | 256 | struct hlist_node node; |
b6887d79 | 257 | struct ftrace_probe_ops *ops; |
8fc0c701 SR |
258 | unsigned long flags; |
259 | unsigned long ip; | |
260 | void *data; | |
261 | struct rcu_head rcu; | |
262 | }; | |
263 | ||
264 | ||
d61f82d0 SR |
265 | enum { |
266 | FTRACE_ENABLE_CALLS = (1 << 0), | |
267 | FTRACE_DISABLE_CALLS = (1 << 1), | |
268 | FTRACE_UPDATE_TRACE_FUNC = (1 << 2), | |
269 | FTRACE_ENABLE_MCOUNT = (1 << 3), | |
270 | FTRACE_DISABLE_MCOUNT = (1 << 4), | |
5a45cfe1 SR |
271 | FTRACE_START_FUNC_RET = (1 << 5), |
272 | FTRACE_STOP_FUNC_RET = (1 << 6), | |
d61f82d0 SR |
273 | }; |
274 | ||
5072c59f SR |
275 | static int ftrace_filtered; |
276 | ||
e94142a6 | 277 | static struct dyn_ftrace *ftrace_new_addrs; |
3d083395 | 278 | |
41c52c0d | 279 | static DEFINE_MUTEX(ftrace_regex_lock); |
3d083395 | 280 | |
3c1720f0 SR |
281 | struct ftrace_page { |
282 | struct ftrace_page *next; | |
431aa3fb | 283 | int index; |
3c1720f0 | 284 | struct dyn_ftrace records[]; |
aa5e5cea | 285 | }; |
3c1720f0 SR |
286 | |
287 | #define ENTRIES_PER_PAGE \ | |
288 | ((PAGE_SIZE - sizeof(struct ftrace_page)) / sizeof(struct dyn_ftrace)) | |
289 | ||
290 | /* estimate from running different kernels */ | |
291 | #define NR_TO_INIT 10000 | |
292 | ||
293 | static struct ftrace_page *ftrace_pages_start; | |
294 | static struct ftrace_page *ftrace_pages; | |
295 | ||
37ad5084 SR |
296 | static struct dyn_ftrace *ftrace_free_records; |
297 | ||
265c831c SR |
298 | /* |
299 | * This is a double for. Do not use 'break' to break out of the loop, | |
300 | * you must use a goto. | |
301 | */ | |
302 | #define do_for_each_ftrace_rec(pg, rec) \ | |
303 | for (pg = ftrace_pages_start; pg; pg = pg->next) { \ | |
304 | int _____i; \ | |
305 | for (_____i = 0; _____i < pg->index; _____i++) { \ | |
306 | rec = &pg->records[_____i]; | |
307 | ||
308 | #define while_for_each_ftrace_rec() \ | |
309 | } \ | |
310 | } | |
ecea656d AS |
311 | |
312 | #ifdef CONFIG_KPROBES | |
f17845e5 IM |
313 | |
314 | static int frozen_record_count; | |
315 | ||
ecea656d AS |
316 | static inline void freeze_record(struct dyn_ftrace *rec) |
317 | { | |
318 | if (!(rec->flags & FTRACE_FL_FROZEN)) { | |
319 | rec->flags |= FTRACE_FL_FROZEN; | |
320 | frozen_record_count++; | |
321 | } | |
322 | } | |
323 | ||
324 | static inline void unfreeze_record(struct dyn_ftrace *rec) | |
325 | { | |
326 | if (rec->flags & FTRACE_FL_FROZEN) { | |
327 | rec->flags &= ~FTRACE_FL_FROZEN; | |
328 | frozen_record_count--; | |
329 | } | |
330 | } | |
331 | ||
332 | static inline int record_frozen(struct dyn_ftrace *rec) | |
333 | { | |
334 | return rec->flags & FTRACE_FL_FROZEN; | |
335 | } | |
336 | #else | |
337 | # define freeze_record(rec) ({ 0; }) | |
338 | # define unfreeze_record(rec) ({ 0; }) | |
339 | # define record_frozen(rec) ({ 0; }) | |
340 | #endif /* CONFIG_KPROBES */ | |
341 | ||
e309b41d | 342 | static void ftrace_free_rec(struct dyn_ftrace *rec) |
37ad5084 | 343 | { |
37ad5084 SR |
344 | rec->ip = (unsigned long)ftrace_free_records; |
345 | ftrace_free_records = rec; | |
346 | rec->flags |= FTRACE_FL_FREE; | |
347 | } | |
348 | ||
fed1939c SR |
349 | void ftrace_release(void *start, unsigned long size) |
350 | { | |
351 | struct dyn_ftrace *rec; | |
352 | struct ftrace_page *pg; | |
353 | unsigned long s = (unsigned long)start; | |
354 | unsigned long e = s + size; | |
fed1939c | 355 | |
00fd61ae | 356 | if (ftrace_disabled || !start) |
fed1939c SR |
357 | return; |
358 | ||
52baf119 | 359 | mutex_lock(&ftrace_lock); |
265c831c | 360 | do_for_each_ftrace_rec(pg, rec) { |
b00f0b6d Z |
361 | if ((rec->ip >= s) && (rec->ip < e) && |
362 | !(rec->flags & FTRACE_FL_FREE)) | |
265c831c SR |
363 | ftrace_free_rec(rec); |
364 | } while_for_each_ftrace_rec(); | |
52baf119 | 365 | mutex_unlock(&ftrace_lock); |
fed1939c SR |
366 | } |
367 | ||
e309b41d | 368 | static struct dyn_ftrace *ftrace_alloc_dyn_node(unsigned long ip) |
3c1720f0 | 369 | { |
37ad5084 SR |
370 | struct dyn_ftrace *rec; |
371 | ||
372 | /* First check for freed records */ | |
373 | if (ftrace_free_records) { | |
374 | rec = ftrace_free_records; | |
375 | ||
37ad5084 | 376 | if (unlikely(!(rec->flags & FTRACE_FL_FREE))) { |
6912896e | 377 | FTRACE_WARN_ON_ONCE(1); |
37ad5084 SR |
378 | ftrace_free_records = NULL; |
379 | return NULL; | |
380 | } | |
381 | ||
382 | ftrace_free_records = (void *)rec->ip; | |
383 | memset(rec, 0, sizeof(*rec)); | |
384 | return rec; | |
385 | } | |
386 | ||
3c1720f0 | 387 | if (ftrace_pages->index == ENTRIES_PER_PAGE) { |
08f5ac90 SR |
388 | if (!ftrace_pages->next) { |
389 | /* allocate another page */ | |
390 | ftrace_pages->next = | |
391 | (void *)get_zeroed_page(GFP_KERNEL); | |
392 | if (!ftrace_pages->next) | |
393 | return NULL; | |
394 | } | |
3c1720f0 SR |
395 | ftrace_pages = ftrace_pages->next; |
396 | } | |
397 | ||
398 | return &ftrace_pages->records[ftrace_pages->index++]; | |
399 | } | |
400 | ||
08f5ac90 | 401 | static struct dyn_ftrace * |
d61f82d0 | 402 | ftrace_record_ip(unsigned long ip) |
3d083395 | 403 | { |
08f5ac90 | 404 | struct dyn_ftrace *rec; |
3d083395 | 405 | |
f3c7ac40 | 406 | if (ftrace_disabled) |
08f5ac90 | 407 | return NULL; |
3d083395 | 408 | |
08f5ac90 SR |
409 | rec = ftrace_alloc_dyn_node(ip); |
410 | if (!rec) | |
411 | return NULL; | |
3d083395 | 412 | |
08f5ac90 | 413 | rec->ip = ip; |
e94142a6 LJ |
414 | rec->flags = (unsigned long)ftrace_new_addrs; |
415 | ftrace_new_addrs = rec; | |
3d083395 | 416 | |
08f5ac90 | 417 | return rec; |
3d083395 SR |
418 | } |
419 | ||
b17e8a37 SR |
420 | static void print_ip_ins(const char *fmt, unsigned char *p) |
421 | { | |
422 | int i; | |
423 | ||
424 | printk(KERN_CONT "%s", fmt); | |
425 | ||
426 | for (i = 0; i < MCOUNT_INSN_SIZE; i++) | |
427 | printk(KERN_CONT "%s%02x", i ? ":" : "", p[i]); | |
428 | } | |
429 | ||
31e88909 | 430 | static void ftrace_bug(int failed, unsigned long ip) |
b17e8a37 SR |
431 | { |
432 | switch (failed) { | |
433 | case -EFAULT: | |
434 | FTRACE_WARN_ON_ONCE(1); | |
435 | pr_info("ftrace faulted on modifying "); | |
436 | print_ip_sym(ip); | |
437 | break; | |
438 | case -EINVAL: | |
439 | FTRACE_WARN_ON_ONCE(1); | |
440 | pr_info("ftrace failed to modify "); | |
441 | print_ip_sym(ip); | |
b17e8a37 | 442 | print_ip_ins(" actual: ", (unsigned char *)ip); |
b17e8a37 SR |
443 | printk(KERN_CONT "\n"); |
444 | break; | |
445 | case -EPERM: | |
446 | FTRACE_WARN_ON_ONCE(1); | |
447 | pr_info("ftrace faulted on writing "); | |
448 | print_ip_sym(ip); | |
449 | break; | |
450 | default: | |
451 | FTRACE_WARN_ON_ONCE(1); | |
452 | pr_info("ftrace faulted on unknown error "); | |
453 | print_ip_sym(ip); | |
454 | } | |
455 | } | |
456 | ||
3c1720f0 | 457 | |
0eb96701 | 458 | static int |
31e88909 | 459 | __ftrace_replace_code(struct dyn_ftrace *rec, int enable) |
5072c59f | 460 | { |
e7d3737e | 461 | unsigned long ftrace_addr; |
6a24a244 | 462 | unsigned long ip, fl; |
e7d3737e | 463 | |
f0001207 | 464 | ftrace_addr = (unsigned long)FTRACE_ADDR; |
5072c59f SR |
465 | |
466 | ip = rec->ip; | |
467 | ||
982c350b SR |
468 | /* |
469 | * If this record is not to be traced and | |
470 | * it is not enabled then do nothing. | |
471 | * | |
472 | * If this record is not to be traced and | |
57794a9d | 473 | * it is enabled then disable it. |
982c350b SR |
474 | * |
475 | */ | |
476 | if (rec->flags & FTRACE_FL_NOTRACE) { | |
477 | if (rec->flags & FTRACE_FL_ENABLED) | |
478 | rec->flags &= ~FTRACE_FL_ENABLED; | |
479 | else | |
480 | return 0; | |
481 | ||
482 | } else if (ftrace_filtered && enable) { | |
5072c59f | 483 | /* |
982c350b | 484 | * Filtering is on: |
5072c59f | 485 | */ |
a4500b84 | 486 | |
982c350b | 487 | fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_ENABLED); |
5072c59f | 488 | |
982c350b SR |
489 | /* Record is filtered and enabled, do nothing */ |
490 | if (fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED)) | |
0eb96701 | 491 | return 0; |
5072c59f | 492 | |
57794a9d | 493 | /* Record is not filtered or enabled, do nothing */ |
982c350b SR |
494 | if (!fl) |
495 | return 0; | |
496 | ||
497 | /* Record is not filtered but enabled, disable it */ | |
498 | if (fl == FTRACE_FL_ENABLED) | |
5072c59f | 499 | rec->flags &= ~FTRACE_FL_ENABLED; |
982c350b SR |
500 | else |
501 | /* Otherwise record is filtered but not enabled, enable it */ | |
5072c59f | 502 | rec->flags |= FTRACE_FL_ENABLED; |
5072c59f | 503 | } else { |
982c350b | 504 | /* Disable or not filtered */ |
5072c59f | 505 | |
41c52c0d | 506 | if (enable) { |
982c350b | 507 | /* if record is enabled, do nothing */ |
5072c59f | 508 | if (rec->flags & FTRACE_FL_ENABLED) |
0eb96701 | 509 | return 0; |
982c350b | 510 | |
5072c59f | 511 | rec->flags |= FTRACE_FL_ENABLED; |
982c350b | 512 | |
5072c59f | 513 | } else { |
982c350b | 514 | |
57794a9d | 515 | /* if record is not enabled, do nothing */ |
5072c59f | 516 | if (!(rec->flags & FTRACE_FL_ENABLED)) |
0eb96701 | 517 | return 0; |
982c350b | 518 | |
5072c59f SR |
519 | rec->flags &= ~FTRACE_FL_ENABLED; |
520 | } | |
521 | } | |
522 | ||
982c350b | 523 | if (rec->flags & FTRACE_FL_ENABLED) |
e7d3737e | 524 | return ftrace_make_call(rec, ftrace_addr); |
31e88909 | 525 | else |
e7d3737e | 526 | return ftrace_make_nop(NULL, rec, ftrace_addr); |
5072c59f SR |
527 | } |
528 | ||
e309b41d | 529 | static void ftrace_replace_code(int enable) |
3c1720f0 | 530 | { |
3c1720f0 SR |
531 | struct dyn_ftrace *rec; |
532 | struct ftrace_page *pg; | |
6a24a244 | 533 | int failed; |
3c1720f0 | 534 | |
265c831c SR |
535 | do_for_each_ftrace_rec(pg, rec) { |
536 | /* | |
fa9d13cf Z |
537 | * Skip over free records, records that have |
538 | * failed and not converted. | |
265c831c SR |
539 | */ |
540 | if (rec->flags & FTRACE_FL_FREE || | |
fa9d13cf | 541 | rec->flags & FTRACE_FL_FAILED || |
03303549 | 542 | !(rec->flags & FTRACE_FL_CONVERTED)) |
265c831c SR |
543 | continue; |
544 | ||
545 | /* ignore updates to this record's mcount site */ | |
546 | if (get_kprobe((void *)rec->ip)) { | |
547 | freeze_record(rec); | |
548 | continue; | |
549 | } else { | |
550 | unfreeze_record(rec); | |
551 | } | |
f22f9a89 | 552 | |
265c831c | 553 | failed = __ftrace_replace_code(rec, enable); |
fa9d13cf | 554 | if (failed) { |
265c831c SR |
555 | rec->flags |= FTRACE_FL_FAILED; |
556 | if ((system_state == SYSTEM_BOOTING) || | |
557 | !core_kernel_text(rec->ip)) { | |
558 | ftrace_free_rec(rec); | |
4377245a | 559 | } else { |
265c831c | 560 | ftrace_bug(failed, rec->ip); |
4377245a SR |
561 | /* Stop processing */ |
562 | return; | |
563 | } | |
3c1720f0 | 564 | } |
265c831c | 565 | } while_for_each_ftrace_rec(); |
3c1720f0 SR |
566 | } |
567 | ||
492a7ea5 | 568 | static int |
31e88909 | 569 | ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec) |
3c1720f0 SR |
570 | { |
571 | unsigned long ip; | |
593eb8a2 | 572 | int ret; |
3c1720f0 SR |
573 | |
574 | ip = rec->ip; | |
575 | ||
25aac9dc | 576 | ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR); |
593eb8a2 | 577 | if (ret) { |
31e88909 | 578 | ftrace_bug(ret, ip); |
3c1720f0 | 579 | rec->flags |= FTRACE_FL_FAILED; |
492a7ea5 | 580 | return 0; |
37ad5084 | 581 | } |
492a7ea5 | 582 | return 1; |
3c1720f0 SR |
583 | } |
584 | ||
000ab691 SR |
585 | /* |
586 | * archs can override this function if they must do something | |
587 | * before the modifying code is performed. | |
588 | */ | |
589 | int __weak ftrace_arch_code_modify_prepare(void) | |
590 | { | |
591 | return 0; | |
592 | } | |
593 | ||
594 | /* | |
595 | * archs can override this function if they must do something | |
596 | * after the modifying code is performed. | |
597 | */ | |
598 | int __weak ftrace_arch_code_modify_post_process(void) | |
599 | { | |
600 | return 0; | |
601 | } | |
602 | ||
e309b41d | 603 | static int __ftrace_modify_code(void *data) |
3d083395 | 604 | { |
d61f82d0 SR |
605 | int *command = data; |
606 | ||
a3583244 | 607 | if (*command & FTRACE_ENABLE_CALLS) |
d61f82d0 | 608 | ftrace_replace_code(1); |
a3583244 | 609 | else if (*command & FTRACE_DISABLE_CALLS) |
d61f82d0 SR |
610 | ftrace_replace_code(0); |
611 | ||
612 | if (*command & FTRACE_UPDATE_TRACE_FUNC) | |
613 | ftrace_update_ftrace_func(ftrace_trace_function); | |
614 | ||
5a45cfe1 SR |
615 | if (*command & FTRACE_START_FUNC_RET) |
616 | ftrace_enable_ftrace_graph_caller(); | |
617 | else if (*command & FTRACE_STOP_FUNC_RET) | |
618 | ftrace_disable_ftrace_graph_caller(); | |
619 | ||
d61f82d0 | 620 | return 0; |
3d083395 SR |
621 | } |
622 | ||
e309b41d | 623 | static void ftrace_run_update_code(int command) |
3d083395 | 624 | { |
000ab691 SR |
625 | int ret; |
626 | ||
627 | ret = ftrace_arch_code_modify_prepare(); | |
628 | FTRACE_WARN_ON(ret); | |
629 | if (ret) | |
630 | return; | |
631 | ||
784e2d76 | 632 | stop_machine(__ftrace_modify_code, &command, NULL); |
000ab691 SR |
633 | |
634 | ret = ftrace_arch_code_modify_post_process(); | |
635 | FTRACE_WARN_ON(ret); | |
3d083395 SR |
636 | } |
637 | ||
d61f82d0 | 638 | static ftrace_func_t saved_ftrace_func; |
60a7ecf4 | 639 | static int ftrace_start_up; |
df4fc315 SR |
640 | |
641 | static void ftrace_startup_enable(int command) | |
642 | { | |
643 | if (saved_ftrace_func != ftrace_trace_function) { | |
644 | saved_ftrace_func = ftrace_trace_function; | |
645 | command |= FTRACE_UPDATE_TRACE_FUNC; | |
646 | } | |
647 | ||
648 | if (!command || !ftrace_enabled) | |
649 | return; | |
650 | ||
651 | ftrace_run_update_code(command); | |
652 | } | |
d61f82d0 | 653 | |
5a45cfe1 | 654 | static void ftrace_startup(int command) |
3d083395 | 655 | { |
4eebcc81 SR |
656 | if (unlikely(ftrace_disabled)) |
657 | return; | |
658 | ||
60a7ecf4 | 659 | ftrace_start_up++; |
982c350b | 660 | command |= FTRACE_ENABLE_CALLS; |
d61f82d0 | 661 | |
df4fc315 | 662 | ftrace_startup_enable(command); |
3d083395 SR |
663 | } |
664 | ||
5a45cfe1 | 665 | static void ftrace_shutdown(int command) |
3d083395 | 666 | { |
4eebcc81 SR |
667 | if (unlikely(ftrace_disabled)) |
668 | return; | |
669 | ||
60a7ecf4 SR |
670 | ftrace_start_up--; |
671 | if (!ftrace_start_up) | |
d61f82d0 | 672 | command |= FTRACE_DISABLE_CALLS; |
3d083395 | 673 | |
d61f82d0 SR |
674 | if (saved_ftrace_func != ftrace_trace_function) { |
675 | saved_ftrace_func = ftrace_trace_function; | |
676 | command |= FTRACE_UPDATE_TRACE_FUNC; | |
677 | } | |
3d083395 | 678 | |
d61f82d0 | 679 | if (!command || !ftrace_enabled) |
e6ea44e9 | 680 | return; |
d61f82d0 SR |
681 | |
682 | ftrace_run_update_code(command); | |
3d083395 SR |
683 | } |
684 | ||
e309b41d | 685 | static void ftrace_startup_sysctl(void) |
b0fc494f | 686 | { |
d61f82d0 SR |
687 | int command = FTRACE_ENABLE_MCOUNT; |
688 | ||
4eebcc81 SR |
689 | if (unlikely(ftrace_disabled)) |
690 | return; | |
691 | ||
d61f82d0 SR |
692 | /* Force update next time */ |
693 | saved_ftrace_func = NULL; | |
60a7ecf4 SR |
694 | /* ftrace_start_up is true if we want ftrace running */ |
695 | if (ftrace_start_up) | |
d61f82d0 SR |
696 | command |= FTRACE_ENABLE_CALLS; |
697 | ||
698 | ftrace_run_update_code(command); | |
b0fc494f SR |
699 | } |
700 | ||
e309b41d | 701 | static void ftrace_shutdown_sysctl(void) |
b0fc494f | 702 | { |
d61f82d0 SR |
703 | int command = FTRACE_DISABLE_MCOUNT; |
704 | ||
4eebcc81 SR |
705 | if (unlikely(ftrace_disabled)) |
706 | return; | |
707 | ||
60a7ecf4 SR |
708 | /* ftrace_start_up is true if ftrace is running */ |
709 | if (ftrace_start_up) | |
d61f82d0 SR |
710 | command |= FTRACE_DISABLE_CALLS; |
711 | ||
712 | ftrace_run_update_code(command); | |
b0fc494f SR |
713 | } |
714 | ||
3d083395 SR |
715 | static cycle_t ftrace_update_time; |
716 | static unsigned long ftrace_update_cnt; | |
717 | unsigned long ftrace_update_tot_cnt; | |
718 | ||
31e88909 | 719 | static int ftrace_update_code(struct module *mod) |
3d083395 | 720 | { |
e94142a6 | 721 | struct dyn_ftrace *p; |
f22f9a89 | 722 | cycle_t start, stop; |
3d083395 | 723 | |
750ed1a4 | 724 | start = ftrace_now(raw_smp_processor_id()); |
3d083395 SR |
725 | ftrace_update_cnt = 0; |
726 | ||
e94142a6 | 727 | while (ftrace_new_addrs) { |
3d083395 | 728 | |
08f5ac90 SR |
729 | /* If something went wrong, bail without enabling anything */ |
730 | if (unlikely(ftrace_disabled)) | |
731 | return -1; | |
f22f9a89 | 732 | |
e94142a6 LJ |
733 | p = ftrace_new_addrs; |
734 | ftrace_new_addrs = (struct dyn_ftrace *)p->flags; | |
735 | p->flags = 0L; | |
f22f9a89 | 736 | |
08f5ac90 | 737 | /* convert record (i.e, patch mcount-call with NOP) */ |
31e88909 | 738 | if (ftrace_code_disable(mod, p)) { |
08f5ac90 SR |
739 | p->flags |= FTRACE_FL_CONVERTED; |
740 | ftrace_update_cnt++; | |
741 | } else | |
742 | ftrace_free_rec(p); | |
3d083395 SR |
743 | } |
744 | ||
750ed1a4 | 745 | stop = ftrace_now(raw_smp_processor_id()); |
3d083395 SR |
746 | ftrace_update_time = stop - start; |
747 | ftrace_update_tot_cnt += ftrace_update_cnt; | |
748 | ||
16444a8a ACM |
749 | return 0; |
750 | } | |
751 | ||
68bf21aa | 752 | static int __init ftrace_dyn_table_alloc(unsigned long num_to_init) |
3c1720f0 SR |
753 | { |
754 | struct ftrace_page *pg; | |
755 | int cnt; | |
756 | int i; | |
3c1720f0 SR |
757 | |
758 | /* allocate a few pages */ | |
759 | ftrace_pages_start = (void *)get_zeroed_page(GFP_KERNEL); | |
760 | if (!ftrace_pages_start) | |
761 | return -1; | |
762 | ||
763 | /* | |
764 | * Allocate a few more pages. | |
765 | * | |
766 | * TODO: have some parser search vmlinux before | |
767 | * final linking to find all calls to ftrace. | |
768 | * Then we can: | |
769 | * a) know how many pages to allocate. | |
770 | * and/or | |
771 | * b) set up the table then. | |
772 | * | |
773 | * The dynamic code is still necessary for | |
774 | * modules. | |
775 | */ | |
776 | ||
777 | pg = ftrace_pages = ftrace_pages_start; | |
778 | ||
68bf21aa | 779 | cnt = num_to_init / ENTRIES_PER_PAGE; |
08f5ac90 | 780 | pr_info("ftrace: allocating %ld entries in %d pages\n", |
5821e1b7 | 781 | num_to_init, cnt + 1); |
3c1720f0 SR |
782 | |
783 | for (i = 0; i < cnt; i++) { | |
784 | pg->next = (void *)get_zeroed_page(GFP_KERNEL); | |
785 | ||
786 | /* If we fail, we'll try later anyway */ | |
787 | if (!pg->next) | |
788 | break; | |
789 | ||
790 | pg = pg->next; | |
791 | } | |
792 | ||
793 | return 0; | |
794 | } | |
795 | ||
5072c59f SR |
796 | enum { |
797 | FTRACE_ITER_FILTER = (1 << 0), | |
798 | FTRACE_ITER_CONT = (1 << 1), | |
41c52c0d | 799 | FTRACE_ITER_NOTRACE = (1 << 2), |
eb9a7bf0 | 800 | FTRACE_ITER_FAILURES = (1 << 3), |
0c75a3ed | 801 | FTRACE_ITER_PRINTALL = (1 << 4), |
8fc0c701 | 802 | FTRACE_ITER_HASH = (1 << 5), |
5072c59f SR |
803 | }; |
804 | ||
805 | #define FTRACE_BUFF_MAX (KSYM_SYMBOL_LEN+4) /* room for wildcards */ | |
806 | ||
807 | struct ftrace_iterator { | |
5072c59f | 808 | struct ftrace_page *pg; |
8fc0c701 | 809 | int hidx; |
431aa3fb | 810 | int idx; |
5072c59f SR |
811 | unsigned flags; |
812 | unsigned char buffer[FTRACE_BUFF_MAX+1]; | |
813 | unsigned buffer_idx; | |
814 | unsigned filtered; | |
815 | }; | |
816 | ||
8fc0c701 SR |
817 | static void * |
818 | t_hash_next(struct seq_file *m, void *v, loff_t *pos) | |
819 | { | |
820 | struct ftrace_iterator *iter = m->private; | |
821 | struct hlist_node *hnd = v; | |
822 | struct hlist_head *hhd; | |
823 | ||
824 | WARN_ON(!(iter->flags & FTRACE_ITER_HASH)); | |
825 | ||
826 | (*pos)++; | |
827 | ||
828 | retry: | |
829 | if (iter->hidx >= FTRACE_FUNC_HASHSIZE) | |
830 | return NULL; | |
831 | ||
832 | hhd = &ftrace_func_hash[iter->hidx]; | |
833 | ||
834 | if (hlist_empty(hhd)) { | |
835 | iter->hidx++; | |
836 | hnd = NULL; | |
837 | goto retry; | |
838 | } | |
839 | ||
840 | if (!hnd) | |
841 | hnd = hhd->first; | |
842 | else { | |
843 | hnd = hnd->next; | |
844 | if (!hnd) { | |
845 | iter->hidx++; | |
846 | goto retry; | |
847 | } | |
848 | } | |
849 | ||
850 | return hnd; | |
851 | } | |
852 | ||
853 | static void *t_hash_start(struct seq_file *m, loff_t *pos) | |
854 | { | |
855 | struct ftrace_iterator *iter = m->private; | |
856 | void *p = NULL; | |
857 | ||
858 | iter->flags |= FTRACE_ITER_HASH; | |
859 | ||
860 | return t_hash_next(m, p, pos); | |
861 | } | |
862 | ||
863 | static int t_hash_show(struct seq_file *m, void *v) | |
864 | { | |
b6887d79 | 865 | struct ftrace_func_probe *rec; |
8fc0c701 SR |
866 | struct hlist_node *hnd = v; |
867 | char str[KSYM_SYMBOL_LEN]; | |
868 | ||
b6887d79 | 869 | rec = hlist_entry(hnd, struct ftrace_func_probe, node); |
8fc0c701 | 870 | |
809dcf29 SR |
871 | if (rec->ops->print) |
872 | return rec->ops->print(m, rec->ip, rec->ops, rec->data); | |
873 | ||
8fc0c701 SR |
874 | kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); |
875 | seq_printf(m, "%s:", str); | |
876 | ||
877 | kallsyms_lookup((unsigned long)rec->ops->func, NULL, NULL, NULL, str); | |
878 | seq_printf(m, "%s", str); | |
879 | ||
880 | if (rec->data) | |
881 | seq_printf(m, ":%p", rec->data); | |
882 | seq_putc(m, '\n'); | |
883 | ||
884 | return 0; | |
885 | } | |
886 | ||
e309b41d | 887 | static void * |
5072c59f SR |
888 | t_next(struct seq_file *m, void *v, loff_t *pos) |
889 | { | |
890 | struct ftrace_iterator *iter = m->private; | |
891 | struct dyn_ftrace *rec = NULL; | |
892 | ||
8fc0c701 SR |
893 | if (iter->flags & FTRACE_ITER_HASH) |
894 | return t_hash_next(m, v, pos); | |
895 | ||
5072c59f SR |
896 | (*pos)++; |
897 | ||
0c75a3ed SR |
898 | if (iter->flags & FTRACE_ITER_PRINTALL) |
899 | return NULL; | |
900 | ||
5072c59f SR |
901 | retry: |
902 | if (iter->idx >= iter->pg->index) { | |
903 | if (iter->pg->next) { | |
904 | iter->pg = iter->pg->next; | |
905 | iter->idx = 0; | |
906 | goto retry; | |
50cdaf08 LW |
907 | } else { |
908 | iter->idx = -1; | |
5072c59f SR |
909 | } |
910 | } else { | |
911 | rec = &iter->pg->records[iter->idx++]; | |
a9fdda33 SR |
912 | if ((rec->flags & FTRACE_FL_FREE) || |
913 | ||
914 | (!(iter->flags & FTRACE_ITER_FAILURES) && | |
eb9a7bf0 AS |
915 | (rec->flags & FTRACE_FL_FAILED)) || |
916 | ||
917 | ((iter->flags & FTRACE_ITER_FAILURES) && | |
a9fdda33 | 918 | !(rec->flags & FTRACE_FL_FAILED)) || |
eb9a7bf0 | 919 | |
0183fb1c SR |
920 | ((iter->flags & FTRACE_ITER_FILTER) && |
921 | !(rec->flags & FTRACE_FL_FILTER)) || | |
922 | ||
41c52c0d SR |
923 | ((iter->flags & FTRACE_ITER_NOTRACE) && |
924 | !(rec->flags & FTRACE_FL_NOTRACE))) { | |
5072c59f SR |
925 | rec = NULL; |
926 | goto retry; | |
927 | } | |
928 | } | |
929 | ||
5072c59f SR |
930 | return rec; |
931 | } | |
932 | ||
933 | static void *t_start(struct seq_file *m, loff_t *pos) | |
934 | { | |
935 | struct ftrace_iterator *iter = m->private; | |
936 | void *p = NULL; | |
5072c59f | 937 | |
8fc0c701 | 938 | mutex_lock(&ftrace_lock); |
0c75a3ed SR |
939 | /* |
940 | * For set_ftrace_filter reading, if we have the filter | |
941 | * off, we can short cut and just print out that all | |
942 | * functions are enabled. | |
943 | */ | |
944 | if (iter->flags & FTRACE_ITER_FILTER && !ftrace_filtered) { | |
945 | if (*pos > 0) | |
8fc0c701 | 946 | return t_hash_start(m, pos); |
0c75a3ed SR |
947 | iter->flags |= FTRACE_ITER_PRINTALL; |
948 | (*pos)++; | |
949 | return iter; | |
950 | } | |
951 | ||
8fc0c701 SR |
952 | if (iter->flags & FTRACE_ITER_HASH) |
953 | return t_hash_start(m, pos); | |
954 | ||
50cdaf08 LW |
955 | if (*pos > 0) { |
956 | if (iter->idx < 0) | |
957 | return p; | |
958 | (*pos)--; | |
959 | iter->idx--; | |
960 | } | |
5821e1b7 | 961 | |
50cdaf08 | 962 | p = t_next(m, p, pos); |
5072c59f | 963 | |
8fc0c701 SR |
964 | if (!p) |
965 | return t_hash_start(m, pos); | |
966 | ||
5072c59f SR |
967 | return p; |
968 | } | |
969 | ||
970 | static void t_stop(struct seq_file *m, void *p) | |
971 | { | |
8fc0c701 | 972 | mutex_unlock(&ftrace_lock); |
5072c59f SR |
973 | } |
974 | ||
975 | static int t_show(struct seq_file *m, void *v) | |
976 | { | |
0c75a3ed | 977 | struct ftrace_iterator *iter = m->private; |
5072c59f SR |
978 | struct dyn_ftrace *rec = v; |
979 | char str[KSYM_SYMBOL_LEN]; | |
980 | ||
8fc0c701 SR |
981 | if (iter->flags & FTRACE_ITER_HASH) |
982 | return t_hash_show(m, v); | |
983 | ||
0c75a3ed SR |
984 | if (iter->flags & FTRACE_ITER_PRINTALL) { |
985 | seq_printf(m, "#### all functions enabled ####\n"); | |
986 | return 0; | |
987 | } | |
988 | ||
5072c59f SR |
989 | if (!rec) |
990 | return 0; | |
991 | ||
992 | kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); | |
993 | ||
50cdaf08 | 994 | seq_printf(m, "%s\n", str); |
5072c59f SR |
995 | |
996 | return 0; | |
997 | } | |
998 | ||
999 | static struct seq_operations show_ftrace_seq_ops = { | |
1000 | .start = t_start, | |
1001 | .next = t_next, | |
1002 | .stop = t_stop, | |
1003 | .show = t_show, | |
1004 | }; | |
1005 | ||
e309b41d | 1006 | static int |
5072c59f SR |
1007 | ftrace_avail_open(struct inode *inode, struct file *file) |
1008 | { | |
1009 | struct ftrace_iterator *iter; | |
1010 | int ret; | |
1011 | ||
4eebcc81 SR |
1012 | if (unlikely(ftrace_disabled)) |
1013 | return -ENODEV; | |
1014 | ||
5072c59f SR |
1015 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); |
1016 | if (!iter) | |
1017 | return -ENOMEM; | |
1018 | ||
1019 | iter->pg = ftrace_pages_start; | |
5072c59f SR |
1020 | |
1021 | ret = seq_open(file, &show_ftrace_seq_ops); | |
1022 | if (!ret) { | |
1023 | struct seq_file *m = file->private_data; | |
4bf39a94 | 1024 | |
5072c59f | 1025 | m->private = iter; |
4bf39a94 | 1026 | } else { |
5072c59f | 1027 | kfree(iter); |
4bf39a94 | 1028 | } |
5072c59f SR |
1029 | |
1030 | return ret; | |
1031 | } | |
1032 | ||
1033 | int ftrace_avail_release(struct inode *inode, struct file *file) | |
1034 | { | |
1035 | struct seq_file *m = (struct seq_file *)file->private_data; | |
1036 | struct ftrace_iterator *iter = m->private; | |
1037 | ||
1038 | seq_release(inode, file); | |
1039 | kfree(iter); | |
4bf39a94 | 1040 | |
5072c59f SR |
1041 | return 0; |
1042 | } | |
1043 | ||
eb9a7bf0 AS |
1044 | static int |
1045 | ftrace_failures_open(struct inode *inode, struct file *file) | |
1046 | { | |
1047 | int ret; | |
1048 | struct seq_file *m; | |
1049 | struct ftrace_iterator *iter; | |
1050 | ||
1051 | ret = ftrace_avail_open(inode, file); | |
1052 | if (!ret) { | |
1053 | m = (struct seq_file *)file->private_data; | |
1054 | iter = (struct ftrace_iterator *)m->private; | |
1055 | iter->flags = FTRACE_ITER_FAILURES; | |
1056 | } | |
1057 | ||
1058 | return ret; | |
1059 | } | |
1060 | ||
1061 | ||
41c52c0d | 1062 | static void ftrace_filter_reset(int enable) |
5072c59f SR |
1063 | { |
1064 | struct ftrace_page *pg; | |
1065 | struct dyn_ftrace *rec; | |
41c52c0d | 1066 | unsigned long type = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; |
5072c59f | 1067 | |
52baf119 | 1068 | mutex_lock(&ftrace_lock); |
41c52c0d SR |
1069 | if (enable) |
1070 | ftrace_filtered = 0; | |
265c831c SR |
1071 | do_for_each_ftrace_rec(pg, rec) { |
1072 | if (rec->flags & FTRACE_FL_FAILED) | |
1073 | continue; | |
1074 | rec->flags &= ~type; | |
1075 | } while_for_each_ftrace_rec(); | |
52baf119 | 1076 | mutex_unlock(&ftrace_lock); |
5072c59f SR |
1077 | } |
1078 | ||
e309b41d | 1079 | static int |
41c52c0d | 1080 | ftrace_regex_open(struct inode *inode, struct file *file, int enable) |
5072c59f SR |
1081 | { |
1082 | struct ftrace_iterator *iter; | |
1083 | int ret = 0; | |
1084 | ||
4eebcc81 SR |
1085 | if (unlikely(ftrace_disabled)) |
1086 | return -ENODEV; | |
1087 | ||
5072c59f SR |
1088 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); |
1089 | if (!iter) | |
1090 | return -ENOMEM; | |
1091 | ||
41c52c0d | 1092 | mutex_lock(&ftrace_regex_lock); |
5072c59f SR |
1093 | if ((file->f_mode & FMODE_WRITE) && |
1094 | !(file->f_flags & O_APPEND)) | |
41c52c0d | 1095 | ftrace_filter_reset(enable); |
5072c59f SR |
1096 | |
1097 | if (file->f_mode & FMODE_READ) { | |
1098 | iter->pg = ftrace_pages_start; | |
41c52c0d SR |
1099 | iter->flags = enable ? FTRACE_ITER_FILTER : |
1100 | FTRACE_ITER_NOTRACE; | |
5072c59f SR |
1101 | |
1102 | ret = seq_open(file, &show_ftrace_seq_ops); | |
1103 | if (!ret) { | |
1104 | struct seq_file *m = file->private_data; | |
1105 | m->private = iter; | |
1106 | } else | |
1107 | kfree(iter); | |
1108 | } else | |
1109 | file->private_data = iter; | |
41c52c0d | 1110 | mutex_unlock(&ftrace_regex_lock); |
5072c59f SR |
1111 | |
1112 | return ret; | |
1113 | } | |
1114 | ||
41c52c0d SR |
1115 | static int |
1116 | ftrace_filter_open(struct inode *inode, struct file *file) | |
1117 | { | |
1118 | return ftrace_regex_open(inode, file, 1); | |
1119 | } | |
1120 | ||
1121 | static int | |
1122 | ftrace_notrace_open(struct inode *inode, struct file *file) | |
1123 | { | |
1124 | return ftrace_regex_open(inode, file, 0); | |
1125 | } | |
1126 | ||
e309b41d | 1127 | static loff_t |
41c52c0d | 1128 | ftrace_regex_lseek(struct file *file, loff_t offset, int origin) |
5072c59f SR |
1129 | { |
1130 | loff_t ret; | |
1131 | ||
1132 | if (file->f_mode & FMODE_READ) | |
1133 | ret = seq_lseek(file, offset, origin); | |
1134 | else | |
1135 | file->f_pos = ret = 1; | |
1136 | ||
1137 | return ret; | |
1138 | } | |
1139 | ||
1140 | enum { | |
1141 | MATCH_FULL, | |
1142 | MATCH_FRONT_ONLY, | |
1143 | MATCH_MIDDLE_ONLY, | |
1144 | MATCH_END_ONLY, | |
1145 | }; | |
1146 | ||
9f4801e3 SR |
1147 | /* |
1148 | * (static function - no need for kernel doc) | |
1149 | * | |
1150 | * Pass in a buffer containing a glob and this function will | |
1151 | * set search to point to the search part of the buffer and | |
1152 | * return the type of search it is (see enum above). | |
1153 | * This does modify buff. | |
1154 | * | |
1155 | * Returns enum type. | |
1156 | * search returns the pointer to use for comparison. | |
1157 | * not returns 1 if buff started with a '!' | |
1158 | * 0 otherwise. | |
1159 | */ | |
1160 | static int | |
64e7c440 | 1161 | ftrace_setup_glob(char *buff, int len, char **search, int *not) |
5072c59f | 1162 | { |
5072c59f | 1163 | int type = MATCH_FULL; |
9f4801e3 | 1164 | int i; |
ea3a6d6d SR |
1165 | |
1166 | if (buff[0] == '!') { | |
9f4801e3 | 1167 | *not = 1; |
ea3a6d6d SR |
1168 | buff++; |
1169 | len--; | |
9f4801e3 SR |
1170 | } else |
1171 | *not = 0; | |
1172 | ||
1173 | *search = buff; | |
5072c59f SR |
1174 | |
1175 | for (i = 0; i < len; i++) { | |
1176 | if (buff[i] == '*') { | |
1177 | if (!i) { | |
9f4801e3 | 1178 | *search = buff + 1; |
5072c59f | 1179 | type = MATCH_END_ONLY; |
5072c59f | 1180 | } else { |
9f4801e3 | 1181 | if (type == MATCH_END_ONLY) |
5072c59f | 1182 | type = MATCH_MIDDLE_ONLY; |
9f4801e3 | 1183 | else |
5072c59f | 1184 | type = MATCH_FRONT_ONLY; |
5072c59f SR |
1185 | buff[i] = 0; |
1186 | break; | |
1187 | } | |
1188 | } | |
1189 | } | |
1190 | ||
9f4801e3 SR |
1191 | return type; |
1192 | } | |
1193 | ||
64e7c440 | 1194 | static int ftrace_match(char *str, char *regex, int len, int type) |
9f4801e3 | 1195 | { |
9f4801e3 SR |
1196 | int matched = 0; |
1197 | char *ptr; | |
1198 | ||
9f4801e3 SR |
1199 | switch (type) { |
1200 | case MATCH_FULL: | |
1201 | if (strcmp(str, regex) == 0) | |
1202 | matched = 1; | |
1203 | break; | |
1204 | case MATCH_FRONT_ONLY: | |
1205 | if (strncmp(str, regex, len) == 0) | |
1206 | matched = 1; | |
1207 | break; | |
1208 | case MATCH_MIDDLE_ONLY: | |
1209 | if (strstr(str, regex)) | |
1210 | matched = 1; | |
1211 | break; | |
1212 | case MATCH_END_ONLY: | |
1213 | ptr = strstr(str, regex); | |
1214 | if (ptr && (ptr[len] == 0)) | |
1215 | matched = 1; | |
1216 | break; | |
1217 | } | |
1218 | ||
1219 | return matched; | |
1220 | } | |
1221 | ||
64e7c440 SR |
1222 | static int |
1223 | ftrace_match_record(struct dyn_ftrace *rec, char *regex, int len, int type) | |
1224 | { | |
1225 | char str[KSYM_SYMBOL_LEN]; | |
1226 | ||
1227 | kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); | |
1228 | return ftrace_match(str, regex, len, type); | |
1229 | } | |
1230 | ||
9f4801e3 SR |
1231 | static void ftrace_match_records(char *buff, int len, int enable) |
1232 | { | |
6a24a244 | 1233 | unsigned int search_len; |
9f4801e3 SR |
1234 | struct ftrace_page *pg; |
1235 | struct dyn_ftrace *rec; | |
6a24a244 SR |
1236 | unsigned long flag; |
1237 | char *search; | |
9f4801e3 | 1238 | int type; |
9f4801e3 SR |
1239 | int not; |
1240 | ||
6a24a244 | 1241 | flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; |
9f4801e3 SR |
1242 | type = ftrace_setup_glob(buff, len, &search, ¬); |
1243 | ||
1244 | search_len = strlen(search); | |
1245 | ||
52baf119 | 1246 | mutex_lock(&ftrace_lock); |
265c831c | 1247 | do_for_each_ftrace_rec(pg, rec) { |
265c831c SR |
1248 | |
1249 | if (rec->flags & FTRACE_FL_FAILED) | |
1250 | continue; | |
9f4801e3 SR |
1251 | |
1252 | if (ftrace_match_record(rec, search, search_len, type)) { | |
265c831c SR |
1253 | if (not) |
1254 | rec->flags &= ~flag; | |
1255 | else | |
1256 | rec->flags |= flag; | |
1257 | } | |
e68746a2 SR |
1258 | /* |
1259 | * Only enable filtering if we have a function that | |
1260 | * is filtered on. | |
1261 | */ | |
1262 | if (enable && (rec->flags & FTRACE_FL_FILTER)) | |
1263 | ftrace_filtered = 1; | |
265c831c | 1264 | } while_for_each_ftrace_rec(); |
52baf119 | 1265 | mutex_unlock(&ftrace_lock); |
5072c59f SR |
1266 | } |
1267 | ||
64e7c440 SR |
1268 | static int |
1269 | ftrace_match_module_record(struct dyn_ftrace *rec, char *mod, | |
1270 | char *regex, int len, int type) | |
1271 | { | |
1272 | char str[KSYM_SYMBOL_LEN]; | |
1273 | char *modname; | |
1274 | ||
1275 | kallsyms_lookup(rec->ip, NULL, NULL, &modname, str); | |
1276 | ||
1277 | if (!modname || strcmp(modname, mod)) | |
1278 | return 0; | |
1279 | ||
1280 | /* blank search means to match all funcs in the mod */ | |
1281 | if (len) | |
1282 | return ftrace_match(str, regex, len, type); | |
1283 | else | |
1284 | return 1; | |
1285 | } | |
1286 | ||
1287 | static void ftrace_match_module_records(char *buff, char *mod, int enable) | |
1288 | { | |
6a24a244 | 1289 | unsigned search_len = 0; |
64e7c440 SR |
1290 | struct ftrace_page *pg; |
1291 | struct dyn_ftrace *rec; | |
1292 | int type = MATCH_FULL; | |
6a24a244 SR |
1293 | char *search = buff; |
1294 | unsigned long flag; | |
64e7c440 SR |
1295 | int not = 0; |
1296 | ||
6a24a244 SR |
1297 | flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; |
1298 | ||
64e7c440 SR |
1299 | /* blank or '*' mean the same */ |
1300 | if (strcmp(buff, "*") == 0) | |
1301 | buff[0] = 0; | |
1302 | ||
1303 | /* handle the case of 'dont filter this module' */ | |
1304 | if (strcmp(buff, "!") == 0 || strcmp(buff, "!*") == 0) { | |
1305 | buff[0] = 0; | |
1306 | not = 1; | |
1307 | } | |
1308 | ||
1309 | if (strlen(buff)) { | |
1310 | type = ftrace_setup_glob(buff, strlen(buff), &search, ¬); | |
1311 | search_len = strlen(search); | |
1312 | } | |
1313 | ||
52baf119 | 1314 | mutex_lock(&ftrace_lock); |
64e7c440 SR |
1315 | do_for_each_ftrace_rec(pg, rec) { |
1316 | ||
1317 | if (rec->flags & FTRACE_FL_FAILED) | |
1318 | continue; | |
1319 | ||
1320 | if (ftrace_match_module_record(rec, mod, | |
1321 | search, search_len, type)) { | |
1322 | if (not) | |
1323 | rec->flags &= ~flag; | |
1324 | else | |
1325 | rec->flags |= flag; | |
1326 | } | |
e68746a2 SR |
1327 | if (enable && (rec->flags & FTRACE_FL_FILTER)) |
1328 | ftrace_filtered = 1; | |
64e7c440 SR |
1329 | |
1330 | } while_for_each_ftrace_rec(); | |
52baf119 | 1331 | mutex_unlock(&ftrace_lock); |
64e7c440 SR |
1332 | } |
1333 | ||
f6180773 SR |
1334 | /* |
1335 | * We register the module command as a template to show others how | |
1336 | * to register the a command as well. | |
1337 | */ | |
1338 | ||
1339 | static int | |
1340 | ftrace_mod_callback(char *func, char *cmd, char *param, int enable) | |
1341 | { | |
1342 | char *mod; | |
1343 | ||
1344 | /* | |
1345 | * cmd == 'mod' because we only registered this func | |
1346 | * for the 'mod' ftrace_func_command. | |
1347 | * But if you register one func with multiple commands, | |
1348 | * you can tell which command was used by the cmd | |
1349 | * parameter. | |
1350 | */ | |
1351 | ||
1352 | /* we must have a module name */ | |
1353 | if (!param) | |
1354 | return -EINVAL; | |
1355 | ||
1356 | mod = strsep(¶m, ":"); | |
1357 | if (!strlen(mod)) | |
1358 | return -EINVAL; | |
1359 | ||
1360 | ftrace_match_module_records(func, mod, enable); | |
1361 | return 0; | |
1362 | } | |
1363 | ||
1364 | static struct ftrace_func_command ftrace_mod_cmd = { | |
1365 | .name = "mod", | |
1366 | .func = ftrace_mod_callback, | |
1367 | }; | |
1368 | ||
1369 | static int __init ftrace_mod_cmd_init(void) | |
1370 | { | |
1371 | return register_ftrace_command(&ftrace_mod_cmd); | |
1372 | } | |
1373 | device_initcall(ftrace_mod_cmd_init); | |
1374 | ||
59df055f | 1375 | static void |
b6887d79 | 1376 | function_trace_probe_call(unsigned long ip, unsigned long parent_ip) |
59df055f | 1377 | { |
b6887d79 | 1378 | struct ftrace_func_probe *entry; |
59df055f SR |
1379 | struct hlist_head *hhd; |
1380 | struct hlist_node *n; | |
1381 | unsigned long key; | |
1382 | int resched; | |
1383 | ||
1384 | key = hash_long(ip, FTRACE_HASH_BITS); | |
1385 | ||
1386 | hhd = &ftrace_func_hash[key]; | |
1387 | ||
1388 | if (hlist_empty(hhd)) | |
1389 | return; | |
1390 | ||
1391 | /* | |
1392 | * Disable preemption for these calls to prevent a RCU grace | |
1393 | * period. This syncs the hash iteration and freeing of items | |
1394 | * on the hash. rcu_read_lock is too dangerous here. | |
1395 | */ | |
1396 | resched = ftrace_preempt_disable(); | |
1397 | hlist_for_each_entry_rcu(entry, n, hhd, node) { | |
1398 | if (entry->ip == ip) | |
1399 | entry->ops->func(ip, parent_ip, &entry->data); | |
1400 | } | |
1401 | ftrace_preempt_enable(resched); | |
1402 | } | |
1403 | ||
b6887d79 | 1404 | static struct ftrace_ops trace_probe_ops __read_mostly = |
59df055f | 1405 | { |
b6887d79 | 1406 | .func = function_trace_probe_call, |
59df055f SR |
1407 | }; |
1408 | ||
b6887d79 | 1409 | static int ftrace_probe_registered; |
59df055f | 1410 | |
b6887d79 | 1411 | static void __enable_ftrace_function_probe(void) |
59df055f SR |
1412 | { |
1413 | int i; | |
1414 | ||
b6887d79 | 1415 | if (ftrace_probe_registered) |
59df055f SR |
1416 | return; |
1417 | ||
1418 | for (i = 0; i < FTRACE_FUNC_HASHSIZE; i++) { | |
1419 | struct hlist_head *hhd = &ftrace_func_hash[i]; | |
1420 | if (hhd->first) | |
1421 | break; | |
1422 | } | |
1423 | /* Nothing registered? */ | |
1424 | if (i == FTRACE_FUNC_HASHSIZE) | |
1425 | return; | |
1426 | ||
b6887d79 | 1427 | __register_ftrace_function(&trace_probe_ops); |
59df055f | 1428 | ftrace_startup(0); |
b6887d79 | 1429 | ftrace_probe_registered = 1; |
59df055f SR |
1430 | } |
1431 | ||
b6887d79 | 1432 | static void __disable_ftrace_function_probe(void) |
59df055f SR |
1433 | { |
1434 | int i; | |
1435 | ||
b6887d79 | 1436 | if (!ftrace_probe_registered) |
59df055f SR |
1437 | return; |
1438 | ||
1439 | for (i = 0; i < FTRACE_FUNC_HASHSIZE; i++) { | |
1440 | struct hlist_head *hhd = &ftrace_func_hash[i]; | |
1441 | if (hhd->first) | |
1442 | return; | |
1443 | } | |
1444 | ||
1445 | /* no more funcs left */ | |
b6887d79 | 1446 | __unregister_ftrace_function(&trace_probe_ops); |
59df055f | 1447 | ftrace_shutdown(0); |
b6887d79 | 1448 | ftrace_probe_registered = 0; |
59df055f SR |
1449 | } |
1450 | ||
1451 | ||
1452 | static void ftrace_free_entry_rcu(struct rcu_head *rhp) | |
1453 | { | |
b6887d79 SR |
1454 | struct ftrace_func_probe *entry = |
1455 | container_of(rhp, struct ftrace_func_probe, rcu); | |
59df055f SR |
1456 | |
1457 | if (entry->ops->free) | |
1458 | entry->ops->free(&entry->data); | |
1459 | kfree(entry); | |
1460 | } | |
1461 | ||
1462 | ||
1463 | int | |
b6887d79 | 1464 | register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, |
59df055f SR |
1465 | void *data) |
1466 | { | |
b6887d79 | 1467 | struct ftrace_func_probe *entry; |
59df055f SR |
1468 | struct ftrace_page *pg; |
1469 | struct dyn_ftrace *rec; | |
59df055f | 1470 | int type, len, not; |
6a24a244 | 1471 | unsigned long key; |
59df055f SR |
1472 | int count = 0; |
1473 | char *search; | |
1474 | ||
1475 | type = ftrace_setup_glob(glob, strlen(glob), &search, ¬); | |
1476 | len = strlen(search); | |
1477 | ||
b6887d79 | 1478 | /* we do not support '!' for function probes */ |
59df055f SR |
1479 | if (WARN_ON(not)) |
1480 | return -EINVAL; | |
1481 | ||
1482 | mutex_lock(&ftrace_lock); | |
1483 | do_for_each_ftrace_rec(pg, rec) { | |
1484 | ||
1485 | if (rec->flags & FTRACE_FL_FAILED) | |
1486 | continue; | |
1487 | ||
1488 | if (!ftrace_match_record(rec, search, len, type)) | |
1489 | continue; | |
1490 | ||
1491 | entry = kmalloc(sizeof(*entry), GFP_KERNEL); | |
1492 | if (!entry) { | |
b6887d79 | 1493 | /* If we did not process any, then return error */ |
59df055f SR |
1494 | if (!count) |
1495 | count = -ENOMEM; | |
1496 | goto out_unlock; | |
1497 | } | |
1498 | ||
1499 | count++; | |
1500 | ||
1501 | entry->data = data; | |
1502 | ||
1503 | /* | |
1504 | * The caller might want to do something special | |
1505 | * for each function we find. We call the callback | |
1506 | * to give the caller an opportunity to do so. | |
1507 | */ | |
1508 | if (ops->callback) { | |
1509 | if (ops->callback(rec->ip, &entry->data) < 0) { | |
1510 | /* caller does not like this func */ | |
1511 | kfree(entry); | |
1512 | continue; | |
1513 | } | |
1514 | } | |
1515 | ||
1516 | entry->ops = ops; | |
1517 | entry->ip = rec->ip; | |
1518 | ||
1519 | key = hash_long(entry->ip, FTRACE_HASH_BITS); | |
1520 | hlist_add_head_rcu(&entry->node, &ftrace_func_hash[key]); | |
1521 | ||
1522 | } while_for_each_ftrace_rec(); | |
b6887d79 | 1523 | __enable_ftrace_function_probe(); |
59df055f SR |
1524 | |
1525 | out_unlock: | |
1526 | mutex_unlock(&ftrace_lock); | |
1527 | ||
1528 | return count; | |
1529 | } | |
1530 | ||
1531 | enum { | |
b6887d79 SR |
1532 | PROBE_TEST_FUNC = 1, |
1533 | PROBE_TEST_DATA = 2 | |
59df055f SR |
1534 | }; |
1535 | ||
1536 | static void | |
b6887d79 | 1537 | __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, |
59df055f SR |
1538 | void *data, int flags) |
1539 | { | |
b6887d79 | 1540 | struct ftrace_func_probe *entry; |
59df055f SR |
1541 | struct hlist_node *n, *tmp; |
1542 | char str[KSYM_SYMBOL_LEN]; | |
1543 | int type = MATCH_FULL; | |
1544 | int i, len = 0; | |
1545 | char *search; | |
1546 | ||
1547 | if (glob && (strcmp(glob, "*") || !strlen(glob))) | |
1548 | glob = NULL; | |
1549 | else { | |
1550 | int not; | |
1551 | ||
1552 | type = ftrace_setup_glob(glob, strlen(glob), &search, ¬); | |
1553 | len = strlen(search); | |
1554 | ||
b6887d79 | 1555 | /* we do not support '!' for function probes */ |
59df055f SR |
1556 | if (WARN_ON(not)) |
1557 | return; | |
1558 | } | |
1559 | ||
1560 | mutex_lock(&ftrace_lock); | |
1561 | for (i = 0; i < FTRACE_FUNC_HASHSIZE; i++) { | |
1562 | struct hlist_head *hhd = &ftrace_func_hash[i]; | |
1563 | ||
1564 | hlist_for_each_entry_safe(entry, n, tmp, hhd, node) { | |
1565 | ||
1566 | /* break up if statements for readability */ | |
b6887d79 | 1567 | if ((flags & PROBE_TEST_FUNC) && entry->ops != ops) |
59df055f SR |
1568 | continue; |
1569 | ||
b6887d79 | 1570 | if ((flags & PROBE_TEST_DATA) && entry->data != data) |
59df055f SR |
1571 | continue; |
1572 | ||
1573 | /* do this last, since it is the most expensive */ | |
1574 | if (glob) { | |
1575 | kallsyms_lookup(entry->ip, NULL, NULL, | |
1576 | NULL, str); | |
1577 | if (!ftrace_match(str, glob, len, type)) | |
1578 | continue; | |
1579 | } | |
1580 | ||
1581 | hlist_del(&entry->node); | |
1582 | call_rcu(&entry->rcu, ftrace_free_entry_rcu); | |
1583 | } | |
1584 | } | |
b6887d79 | 1585 | __disable_ftrace_function_probe(); |
59df055f SR |
1586 | mutex_unlock(&ftrace_lock); |
1587 | } | |
1588 | ||
1589 | void | |
b6887d79 | 1590 | unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, |
59df055f SR |
1591 | void *data) |
1592 | { | |
b6887d79 SR |
1593 | __unregister_ftrace_function_probe(glob, ops, data, |
1594 | PROBE_TEST_FUNC | PROBE_TEST_DATA); | |
59df055f SR |
1595 | } |
1596 | ||
1597 | void | |
b6887d79 | 1598 | unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops) |
59df055f | 1599 | { |
b6887d79 | 1600 | __unregister_ftrace_function_probe(glob, ops, NULL, PROBE_TEST_FUNC); |
59df055f SR |
1601 | } |
1602 | ||
b6887d79 | 1603 | void unregister_ftrace_function_probe_all(char *glob) |
59df055f | 1604 | { |
b6887d79 | 1605 | __unregister_ftrace_function_probe(glob, NULL, NULL, 0); |
59df055f SR |
1606 | } |
1607 | ||
f6180773 SR |
1608 | static LIST_HEAD(ftrace_commands); |
1609 | static DEFINE_MUTEX(ftrace_cmd_mutex); | |
1610 | ||
1611 | int register_ftrace_command(struct ftrace_func_command *cmd) | |
1612 | { | |
1613 | struct ftrace_func_command *p; | |
1614 | int ret = 0; | |
1615 | ||
1616 | mutex_lock(&ftrace_cmd_mutex); | |
1617 | list_for_each_entry(p, &ftrace_commands, list) { | |
1618 | if (strcmp(cmd->name, p->name) == 0) { | |
1619 | ret = -EBUSY; | |
1620 | goto out_unlock; | |
1621 | } | |
1622 | } | |
1623 | list_add(&cmd->list, &ftrace_commands); | |
1624 | out_unlock: | |
1625 | mutex_unlock(&ftrace_cmd_mutex); | |
1626 | ||
1627 | return ret; | |
1628 | } | |
1629 | ||
1630 | int unregister_ftrace_command(struct ftrace_func_command *cmd) | |
1631 | { | |
1632 | struct ftrace_func_command *p, *n; | |
1633 | int ret = -ENODEV; | |
1634 | ||
1635 | mutex_lock(&ftrace_cmd_mutex); | |
1636 | list_for_each_entry_safe(p, n, &ftrace_commands, list) { | |
1637 | if (strcmp(cmd->name, p->name) == 0) { | |
1638 | ret = 0; | |
1639 | list_del_init(&p->list); | |
1640 | goto out_unlock; | |
1641 | } | |
1642 | } | |
1643 | out_unlock: | |
1644 | mutex_unlock(&ftrace_cmd_mutex); | |
1645 | ||
1646 | return ret; | |
1647 | } | |
1648 | ||
64e7c440 SR |
1649 | static int ftrace_process_regex(char *buff, int len, int enable) |
1650 | { | |
f6180773 | 1651 | char *func, *command, *next = buff; |
6a24a244 | 1652 | struct ftrace_func_command *p; |
f6180773 | 1653 | int ret = -EINVAL; |
64e7c440 SR |
1654 | |
1655 | func = strsep(&next, ":"); | |
1656 | ||
1657 | if (!next) { | |
1658 | ftrace_match_records(func, len, enable); | |
1659 | return 0; | |
1660 | } | |
1661 | ||
f6180773 | 1662 | /* command found */ |
64e7c440 SR |
1663 | |
1664 | command = strsep(&next, ":"); | |
1665 | ||
f6180773 SR |
1666 | mutex_lock(&ftrace_cmd_mutex); |
1667 | list_for_each_entry(p, &ftrace_commands, list) { | |
1668 | if (strcmp(p->name, command) == 0) { | |
1669 | ret = p->func(func, command, next, enable); | |
1670 | goto out_unlock; | |
1671 | } | |
64e7c440 | 1672 | } |
f6180773 SR |
1673 | out_unlock: |
1674 | mutex_unlock(&ftrace_cmd_mutex); | |
64e7c440 | 1675 | |
f6180773 | 1676 | return ret; |
64e7c440 SR |
1677 | } |
1678 | ||
e309b41d | 1679 | static ssize_t |
41c52c0d SR |
1680 | ftrace_regex_write(struct file *file, const char __user *ubuf, |
1681 | size_t cnt, loff_t *ppos, int enable) | |
5072c59f SR |
1682 | { |
1683 | struct ftrace_iterator *iter; | |
1684 | char ch; | |
1685 | size_t read = 0; | |
1686 | ssize_t ret; | |
1687 | ||
1688 | if (!cnt || cnt < 0) | |
1689 | return 0; | |
1690 | ||
41c52c0d | 1691 | mutex_lock(&ftrace_regex_lock); |
5072c59f SR |
1692 | |
1693 | if (file->f_mode & FMODE_READ) { | |
1694 | struct seq_file *m = file->private_data; | |
1695 | iter = m->private; | |
1696 | } else | |
1697 | iter = file->private_data; | |
1698 | ||
1699 | if (!*ppos) { | |
1700 | iter->flags &= ~FTRACE_ITER_CONT; | |
1701 | iter->buffer_idx = 0; | |
1702 | } | |
1703 | ||
1704 | ret = get_user(ch, ubuf++); | |
1705 | if (ret) | |
1706 | goto out; | |
1707 | read++; | |
1708 | cnt--; | |
1709 | ||
1710 | if (!(iter->flags & ~FTRACE_ITER_CONT)) { | |
1711 | /* skip white space */ | |
1712 | while (cnt && isspace(ch)) { | |
1713 | ret = get_user(ch, ubuf++); | |
1714 | if (ret) | |
1715 | goto out; | |
1716 | read++; | |
1717 | cnt--; | |
1718 | } | |
1719 | ||
5072c59f SR |
1720 | if (isspace(ch)) { |
1721 | file->f_pos += read; | |
1722 | ret = read; | |
1723 | goto out; | |
1724 | } | |
1725 | ||
1726 | iter->buffer_idx = 0; | |
1727 | } | |
1728 | ||
1729 | while (cnt && !isspace(ch)) { | |
1730 | if (iter->buffer_idx < FTRACE_BUFF_MAX) | |
1731 | iter->buffer[iter->buffer_idx++] = ch; | |
1732 | else { | |
1733 | ret = -EINVAL; | |
1734 | goto out; | |
1735 | } | |
1736 | ret = get_user(ch, ubuf++); | |
1737 | if (ret) | |
1738 | goto out; | |
1739 | read++; | |
1740 | cnt--; | |
1741 | } | |
1742 | ||
1743 | if (isspace(ch)) { | |
1744 | iter->filtered++; | |
1745 | iter->buffer[iter->buffer_idx] = 0; | |
64e7c440 SR |
1746 | ret = ftrace_process_regex(iter->buffer, |
1747 | iter->buffer_idx, enable); | |
1748 | if (ret) | |
1749 | goto out; | |
5072c59f SR |
1750 | iter->buffer_idx = 0; |
1751 | } else | |
1752 | iter->flags |= FTRACE_ITER_CONT; | |
1753 | ||
1754 | ||
1755 | file->f_pos += read; | |
1756 | ||
1757 | ret = read; | |
1758 | out: | |
41c52c0d | 1759 | mutex_unlock(&ftrace_regex_lock); |
5072c59f SR |
1760 | |
1761 | return ret; | |
1762 | } | |
1763 | ||
41c52c0d SR |
1764 | static ssize_t |
1765 | ftrace_filter_write(struct file *file, const char __user *ubuf, | |
1766 | size_t cnt, loff_t *ppos) | |
1767 | { | |
1768 | return ftrace_regex_write(file, ubuf, cnt, ppos, 1); | |
1769 | } | |
1770 | ||
1771 | static ssize_t | |
1772 | ftrace_notrace_write(struct file *file, const char __user *ubuf, | |
1773 | size_t cnt, loff_t *ppos) | |
1774 | { | |
1775 | return ftrace_regex_write(file, ubuf, cnt, ppos, 0); | |
1776 | } | |
1777 | ||
1778 | static void | |
1779 | ftrace_set_regex(unsigned char *buf, int len, int reset, int enable) | |
1780 | { | |
1781 | if (unlikely(ftrace_disabled)) | |
1782 | return; | |
1783 | ||
1784 | mutex_lock(&ftrace_regex_lock); | |
1785 | if (reset) | |
1786 | ftrace_filter_reset(enable); | |
1787 | if (buf) | |
7f24b31b | 1788 | ftrace_match_records(buf, len, enable); |
41c52c0d SR |
1789 | mutex_unlock(&ftrace_regex_lock); |
1790 | } | |
1791 | ||
77a2b37d SR |
1792 | /** |
1793 | * ftrace_set_filter - set a function to filter on in ftrace | |
1794 | * @buf - the string that holds the function filter text. | |
1795 | * @len - the length of the string. | |
1796 | * @reset - non zero to reset all filters before applying this filter. | |
1797 | * | |
1798 | * Filters denote which functions should be enabled when tracing is enabled. | |
1799 | * If @buf is NULL and reset is set, all functions will be enabled for tracing. | |
1800 | */ | |
e309b41d | 1801 | void ftrace_set_filter(unsigned char *buf, int len, int reset) |
77a2b37d | 1802 | { |
41c52c0d SR |
1803 | ftrace_set_regex(buf, len, reset, 1); |
1804 | } | |
4eebcc81 | 1805 | |
41c52c0d SR |
1806 | /** |
1807 | * ftrace_set_notrace - set a function to not trace in ftrace | |
1808 | * @buf - the string that holds the function notrace text. | |
1809 | * @len - the length of the string. | |
1810 | * @reset - non zero to reset all filters before applying this filter. | |
1811 | * | |
1812 | * Notrace Filters denote which functions should not be enabled when tracing | |
1813 | * is enabled. If @buf is NULL and reset is set, all functions will be enabled | |
1814 | * for tracing. | |
1815 | */ | |
1816 | void ftrace_set_notrace(unsigned char *buf, int len, int reset) | |
1817 | { | |
1818 | ftrace_set_regex(buf, len, reset, 0); | |
77a2b37d SR |
1819 | } |
1820 | ||
e309b41d | 1821 | static int |
41c52c0d | 1822 | ftrace_regex_release(struct inode *inode, struct file *file, int enable) |
5072c59f SR |
1823 | { |
1824 | struct seq_file *m = (struct seq_file *)file->private_data; | |
1825 | struct ftrace_iterator *iter; | |
1826 | ||
41c52c0d | 1827 | mutex_lock(&ftrace_regex_lock); |
5072c59f SR |
1828 | if (file->f_mode & FMODE_READ) { |
1829 | iter = m->private; | |
1830 | ||
1831 | seq_release(inode, file); | |
1832 | } else | |
1833 | iter = file->private_data; | |
1834 | ||
1835 | if (iter->buffer_idx) { | |
1836 | iter->filtered++; | |
1837 | iter->buffer[iter->buffer_idx] = 0; | |
7f24b31b | 1838 | ftrace_match_records(iter->buffer, iter->buffer_idx, enable); |
5072c59f SR |
1839 | } |
1840 | ||
e6ea44e9 | 1841 | mutex_lock(&ftrace_lock); |
ee02a2e5 | 1842 | if (ftrace_start_up && ftrace_enabled) |
5072c59f | 1843 | ftrace_run_update_code(FTRACE_ENABLE_CALLS); |
e6ea44e9 | 1844 | mutex_unlock(&ftrace_lock); |
5072c59f SR |
1845 | |
1846 | kfree(iter); | |
41c52c0d | 1847 | mutex_unlock(&ftrace_regex_lock); |
5072c59f SR |
1848 | return 0; |
1849 | } | |
1850 | ||
41c52c0d SR |
1851 | static int |
1852 | ftrace_filter_release(struct inode *inode, struct file *file) | |
1853 | { | |
1854 | return ftrace_regex_release(inode, file, 1); | |
1855 | } | |
1856 | ||
1857 | static int | |
1858 | ftrace_notrace_release(struct inode *inode, struct file *file) | |
1859 | { | |
1860 | return ftrace_regex_release(inode, file, 0); | |
1861 | } | |
1862 | ||
5e2336a0 | 1863 | static const struct file_operations ftrace_avail_fops = { |
5072c59f SR |
1864 | .open = ftrace_avail_open, |
1865 | .read = seq_read, | |
1866 | .llseek = seq_lseek, | |
1867 | .release = ftrace_avail_release, | |
1868 | }; | |
1869 | ||
5e2336a0 | 1870 | static const struct file_operations ftrace_failures_fops = { |
eb9a7bf0 AS |
1871 | .open = ftrace_failures_open, |
1872 | .read = seq_read, | |
1873 | .llseek = seq_lseek, | |
1874 | .release = ftrace_avail_release, | |
1875 | }; | |
1876 | ||
5e2336a0 | 1877 | static const struct file_operations ftrace_filter_fops = { |
5072c59f | 1878 | .open = ftrace_filter_open, |
850a80cf | 1879 | .read = seq_read, |
5072c59f | 1880 | .write = ftrace_filter_write, |
41c52c0d | 1881 | .llseek = ftrace_regex_lseek, |
5072c59f SR |
1882 | .release = ftrace_filter_release, |
1883 | }; | |
1884 | ||
5e2336a0 | 1885 | static const struct file_operations ftrace_notrace_fops = { |
41c52c0d | 1886 | .open = ftrace_notrace_open, |
850a80cf | 1887 | .read = seq_read, |
41c52c0d SR |
1888 | .write = ftrace_notrace_write, |
1889 | .llseek = ftrace_regex_lseek, | |
1890 | .release = ftrace_notrace_release, | |
1891 | }; | |
1892 | ||
ea4e2bc4 SR |
1893 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
1894 | ||
1895 | static DEFINE_MUTEX(graph_lock); | |
1896 | ||
1897 | int ftrace_graph_count; | |
1898 | unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS] __read_mostly; | |
1899 | ||
1900 | static void * | |
1901 | g_next(struct seq_file *m, void *v, loff_t *pos) | |
1902 | { | |
1903 | unsigned long *array = m->private; | |
1904 | int index = *pos; | |
1905 | ||
1906 | (*pos)++; | |
1907 | ||
1908 | if (index >= ftrace_graph_count) | |
1909 | return NULL; | |
1910 | ||
1911 | return &array[index]; | |
1912 | } | |
1913 | ||
1914 | static void *g_start(struct seq_file *m, loff_t *pos) | |
1915 | { | |
1916 | void *p = NULL; | |
1917 | ||
1918 | mutex_lock(&graph_lock); | |
1919 | ||
f9349a8f FW |
1920 | /* Nothing, tell g_show to print all functions are enabled */ |
1921 | if (!ftrace_graph_count && !*pos) | |
1922 | return (void *)1; | |
1923 | ||
ea4e2bc4 SR |
1924 | p = g_next(m, p, pos); |
1925 | ||
1926 | return p; | |
1927 | } | |
1928 | ||
1929 | static void g_stop(struct seq_file *m, void *p) | |
1930 | { | |
1931 | mutex_unlock(&graph_lock); | |
1932 | } | |
1933 | ||
1934 | static int g_show(struct seq_file *m, void *v) | |
1935 | { | |
1936 | unsigned long *ptr = v; | |
1937 | char str[KSYM_SYMBOL_LEN]; | |
1938 | ||
1939 | if (!ptr) | |
1940 | return 0; | |
1941 | ||
f9349a8f FW |
1942 | if (ptr == (unsigned long *)1) { |
1943 | seq_printf(m, "#### all functions enabled ####\n"); | |
1944 | return 0; | |
1945 | } | |
1946 | ||
ea4e2bc4 SR |
1947 | kallsyms_lookup(*ptr, NULL, NULL, NULL, str); |
1948 | ||
1949 | seq_printf(m, "%s\n", str); | |
1950 | ||
1951 | return 0; | |
1952 | } | |
1953 | ||
1954 | static struct seq_operations ftrace_graph_seq_ops = { | |
1955 | .start = g_start, | |
1956 | .next = g_next, | |
1957 | .stop = g_stop, | |
1958 | .show = g_show, | |
1959 | }; | |
1960 | ||
1961 | static int | |
1962 | ftrace_graph_open(struct inode *inode, struct file *file) | |
1963 | { | |
1964 | int ret = 0; | |
1965 | ||
1966 | if (unlikely(ftrace_disabled)) | |
1967 | return -ENODEV; | |
1968 | ||
1969 | mutex_lock(&graph_lock); | |
1970 | if ((file->f_mode & FMODE_WRITE) && | |
1971 | !(file->f_flags & O_APPEND)) { | |
1972 | ftrace_graph_count = 0; | |
1973 | memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs)); | |
1974 | } | |
1975 | ||
1976 | if (file->f_mode & FMODE_READ) { | |
1977 | ret = seq_open(file, &ftrace_graph_seq_ops); | |
1978 | if (!ret) { | |
1979 | struct seq_file *m = file->private_data; | |
1980 | m->private = ftrace_graph_funcs; | |
1981 | } | |
1982 | } else | |
1983 | file->private_data = ftrace_graph_funcs; | |
1984 | mutex_unlock(&graph_lock); | |
1985 | ||
1986 | return ret; | |
1987 | } | |
1988 | ||
ea4e2bc4 | 1989 | static int |
f9349a8f | 1990 | ftrace_set_func(unsigned long *array, int *idx, char *buffer) |
ea4e2bc4 | 1991 | { |
ea4e2bc4 SR |
1992 | struct dyn_ftrace *rec; |
1993 | struct ftrace_page *pg; | |
f9349a8f | 1994 | int search_len; |
ea4e2bc4 | 1995 | int found = 0; |
f9349a8f FW |
1996 | int type, not; |
1997 | char *search; | |
1998 | bool exists; | |
1999 | int i; | |
ea4e2bc4 SR |
2000 | |
2001 | if (ftrace_disabled) | |
2002 | return -ENODEV; | |
2003 | ||
f9349a8f FW |
2004 | /* decode regex */ |
2005 | type = ftrace_setup_glob(buffer, strlen(buffer), &search, ¬); | |
2006 | if (not) | |
2007 | return -EINVAL; | |
2008 | ||
2009 | search_len = strlen(search); | |
2010 | ||
52baf119 | 2011 | mutex_lock(&ftrace_lock); |
265c831c SR |
2012 | do_for_each_ftrace_rec(pg, rec) { |
2013 | ||
f9349a8f FW |
2014 | if (*idx >= FTRACE_GRAPH_MAX_FUNCS) |
2015 | break; | |
2016 | ||
265c831c SR |
2017 | if (rec->flags & (FTRACE_FL_FAILED | FTRACE_FL_FREE)) |
2018 | continue; | |
2019 | ||
f9349a8f FW |
2020 | if (ftrace_match_record(rec, search, search_len, type)) { |
2021 | /* ensure it is not already in the array */ | |
2022 | exists = false; | |
2023 | for (i = 0; i < *idx; i++) | |
2024 | if (array[i] == rec->ip) { | |
2025 | exists = true; | |
265c831c SR |
2026 | break; |
2027 | } | |
f9349a8f FW |
2028 | if (!exists) { |
2029 | array[(*idx)++] = rec->ip; | |
2030 | found = 1; | |
2031 | } | |
ea4e2bc4 | 2032 | } |
265c831c | 2033 | } while_for_each_ftrace_rec(); |
f9349a8f | 2034 | |
52baf119 | 2035 | mutex_unlock(&ftrace_lock); |
ea4e2bc4 SR |
2036 | |
2037 | return found ? 0 : -EINVAL; | |
2038 | } | |
2039 | ||
2040 | static ssize_t | |
2041 | ftrace_graph_write(struct file *file, const char __user *ubuf, | |
2042 | size_t cnt, loff_t *ppos) | |
2043 | { | |
2044 | unsigned char buffer[FTRACE_BUFF_MAX+1]; | |
2045 | unsigned long *array; | |
2046 | size_t read = 0; | |
2047 | ssize_t ret; | |
2048 | int index = 0; | |
2049 | char ch; | |
2050 | ||
2051 | if (!cnt || cnt < 0) | |
2052 | return 0; | |
2053 | ||
2054 | mutex_lock(&graph_lock); | |
2055 | ||
2056 | if (ftrace_graph_count >= FTRACE_GRAPH_MAX_FUNCS) { | |
2057 | ret = -EBUSY; | |
2058 | goto out; | |
2059 | } | |
2060 | ||
2061 | if (file->f_mode & FMODE_READ) { | |
2062 | struct seq_file *m = file->private_data; | |
2063 | array = m->private; | |
2064 | } else | |
2065 | array = file->private_data; | |
2066 | ||
2067 | ret = get_user(ch, ubuf++); | |
2068 | if (ret) | |
2069 | goto out; | |
2070 | read++; | |
2071 | cnt--; | |
2072 | ||
2073 | /* skip white space */ | |
2074 | while (cnt && isspace(ch)) { | |
2075 | ret = get_user(ch, ubuf++); | |
2076 | if (ret) | |
2077 | goto out; | |
2078 | read++; | |
2079 | cnt--; | |
2080 | } | |
2081 | ||
2082 | if (isspace(ch)) { | |
2083 | *ppos += read; | |
2084 | ret = read; | |
2085 | goto out; | |
2086 | } | |
2087 | ||
2088 | while (cnt && !isspace(ch)) { | |
2089 | if (index < FTRACE_BUFF_MAX) | |
2090 | buffer[index++] = ch; | |
2091 | else { | |
2092 | ret = -EINVAL; | |
2093 | goto out; | |
2094 | } | |
2095 | ret = get_user(ch, ubuf++); | |
2096 | if (ret) | |
2097 | goto out; | |
2098 | read++; | |
2099 | cnt--; | |
2100 | } | |
2101 | buffer[index] = 0; | |
2102 | ||
f9349a8f FW |
2103 | /* we allow only one expression at a time */ |
2104 | ret = ftrace_set_func(array, &ftrace_graph_count, buffer); | |
ea4e2bc4 SR |
2105 | if (ret) |
2106 | goto out; | |
2107 | ||
ea4e2bc4 SR |
2108 | file->f_pos += read; |
2109 | ||
2110 | ret = read; | |
2111 | out: | |
2112 | mutex_unlock(&graph_lock); | |
2113 | ||
2114 | return ret; | |
2115 | } | |
2116 | ||
2117 | static const struct file_operations ftrace_graph_fops = { | |
2118 | .open = ftrace_graph_open, | |
850a80cf | 2119 | .read = seq_read, |
ea4e2bc4 SR |
2120 | .write = ftrace_graph_write, |
2121 | }; | |
2122 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ | |
2123 | ||
df4fc315 | 2124 | static __init int ftrace_init_dyn_debugfs(struct dentry *d_tracer) |
5072c59f | 2125 | { |
5072c59f SR |
2126 | struct dentry *entry; |
2127 | ||
5072c59f SR |
2128 | entry = debugfs_create_file("available_filter_functions", 0444, |
2129 | d_tracer, NULL, &ftrace_avail_fops); | |
2130 | if (!entry) | |
2131 | pr_warning("Could not create debugfs " | |
2132 | "'available_filter_functions' entry\n"); | |
2133 | ||
eb9a7bf0 AS |
2134 | entry = debugfs_create_file("failures", 0444, |
2135 | d_tracer, NULL, &ftrace_failures_fops); | |
2136 | if (!entry) | |
2137 | pr_warning("Could not create debugfs 'failures' entry\n"); | |
2138 | ||
5072c59f SR |
2139 | entry = debugfs_create_file("set_ftrace_filter", 0644, d_tracer, |
2140 | NULL, &ftrace_filter_fops); | |
2141 | if (!entry) | |
2142 | pr_warning("Could not create debugfs " | |
2143 | "'set_ftrace_filter' entry\n"); | |
41c52c0d SR |
2144 | |
2145 | entry = debugfs_create_file("set_ftrace_notrace", 0644, d_tracer, | |
2146 | NULL, &ftrace_notrace_fops); | |
2147 | if (!entry) | |
2148 | pr_warning("Could not create debugfs " | |
2149 | "'set_ftrace_notrace' entry\n"); | |
ad90c0e3 | 2150 | |
ea4e2bc4 SR |
2151 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
2152 | entry = debugfs_create_file("set_graph_function", 0444, d_tracer, | |
2153 | NULL, | |
2154 | &ftrace_graph_fops); | |
2155 | if (!entry) | |
2156 | pr_warning("Could not create debugfs " | |
2157 | "'set_graph_function' entry\n"); | |
2158 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ | |
2159 | ||
5072c59f SR |
2160 | return 0; |
2161 | } | |
2162 | ||
31e88909 SR |
2163 | static int ftrace_convert_nops(struct module *mod, |
2164 | unsigned long *start, | |
68bf21aa SR |
2165 | unsigned long *end) |
2166 | { | |
2167 | unsigned long *p; | |
2168 | unsigned long addr; | |
2169 | unsigned long flags; | |
2170 | ||
e6ea44e9 | 2171 | mutex_lock(&ftrace_lock); |
68bf21aa SR |
2172 | p = start; |
2173 | while (p < end) { | |
2174 | addr = ftrace_call_adjust(*p++); | |
20e5227e SR |
2175 | /* |
2176 | * Some architecture linkers will pad between | |
2177 | * the different mcount_loc sections of different | |
2178 | * object files to satisfy alignments. | |
2179 | * Skip any NULL pointers. | |
2180 | */ | |
2181 | if (!addr) | |
2182 | continue; | |
68bf21aa | 2183 | ftrace_record_ip(addr); |
68bf21aa SR |
2184 | } |
2185 | ||
08f5ac90 | 2186 | /* disable interrupts to prevent kstop machine */ |
68bf21aa | 2187 | local_irq_save(flags); |
31e88909 | 2188 | ftrace_update_code(mod); |
68bf21aa | 2189 | local_irq_restore(flags); |
e6ea44e9 | 2190 | mutex_unlock(&ftrace_lock); |
68bf21aa SR |
2191 | |
2192 | return 0; | |
2193 | } | |
2194 | ||
31e88909 SR |
2195 | void ftrace_init_module(struct module *mod, |
2196 | unsigned long *start, unsigned long *end) | |
90d595fe | 2197 | { |
00fd61ae | 2198 | if (ftrace_disabled || start == end) |
fed1939c | 2199 | return; |
31e88909 | 2200 | ftrace_convert_nops(mod, start, end); |
90d595fe SR |
2201 | } |
2202 | ||
68bf21aa SR |
2203 | extern unsigned long __start_mcount_loc[]; |
2204 | extern unsigned long __stop_mcount_loc[]; | |
2205 | ||
2206 | void __init ftrace_init(void) | |
2207 | { | |
2208 | unsigned long count, addr, flags; | |
2209 | int ret; | |
2210 | ||
2211 | /* Keep the ftrace pointer to the stub */ | |
2212 | addr = (unsigned long)ftrace_stub; | |
2213 | ||
2214 | local_irq_save(flags); | |
2215 | ftrace_dyn_arch_init(&addr); | |
2216 | local_irq_restore(flags); | |
2217 | ||
2218 | /* ftrace_dyn_arch_init places the return code in addr */ | |
2219 | if (addr) | |
2220 | goto failed; | |
2221 | ||
2222 | count = __stop_mcount_loc - __start_mcount_loc; | |
2223 | ||
2224 | ret = ftrace_dyn_table_alloc(count); | |
2225 | if (ret) | |
2226 | goto failed; | |
2227 | ||
2228 | last_ftrace_enabled = ftrace_enabled = 1; | |
2229 | ||
31e88909 SR |
2230 | ret = ftrace_convert_nops(NULL, |
2231 | __start_mcount_loc, | |
68bf21aa SR |
2232 | __stop_mcount_loc); |
2233 | ||
2234 | return; | |
2235 | failed: | |
2236 | ftrace_disabled = 1; | |
2237 | } | |
68bf21aa | 2238 | |
3d083395 | 2239 | #else |
0b6e4d56 FW |
2240 | |
2241 | static int __init ftrace_nodyn_init(void) | |
2242 | { | |
2243 | ftrace_enabled = 1; | |
2244 | return 0; | |
2245 | } | |
2246 | device_initcall(ftrace_nodyn_init); | |
2247 | ||
df4fc315 SR |
2248 | static inline int ftrace_init_dyn_debugfs(struct dentry *d_tracer) { return 0; } |
2249 | static inline void ftrace_startup_enable(int command) { } | |
5a45cfe1 SR |
2250 | /* Keep as macros so we do not need to define the commands */ |
2251 | # define ftrace_startup(command) do { } while (0) | |
2252 | # define ftrace_shutdown(command) do { } while (0) | |
c7aafc54 IM |
2253 | # define ftrace_startup_sysctl() do { } while (0) |
2254 | # define ftrace_shutdown_sysctl() do { } while (0) | |
3d083395 SR |
2255 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
2256 | ||
df4fc315 SR |
2257 | static ssize_t |
2258 | ftrace_pid_read(struct file *file, char __user *ubuf, | |
2259 | size_t cnt, loff_t *ppos) | |
2260 | { | |
2261 | char buf[64]; | |
2262 | int r; | |
2263 | ||
e32d8956 SR |
2264 | if (ftrace_pid_trace == ftrace_swapper_pid) |
2265 | r = sprintf(buf, "swapper tasks\n"); | |
2266 | else if (ftrace_pid_trace) | |
978f3a45 | 2267 | r = sprintf(buf, "%u\n", pid_nr(ftrace_pid_trace)); |
df4fc315 SR |
2268 | else |
2269 | r = sprintf(buf, "no pid\n"); | |
2270 | ||
2271 | return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); | |
2272 | } | |
2273 | ||
e32d8956 | 2274 | static void clear_ftrace_swapper(void) |
978f3a45 SR |
2275 | { |
2276 | struct task_struct *p; | |
e32d8956 | 2277 | int cpu; |
978f3a45 | 2278 | |
e32d8956 SR |
2279 | get_online_cpus(); |
2280 | for_each_online_cpu(cpu) { | |
2281 | p = idle_task(cpu); | |
978f3a45 | 2282 | clear_tsk_trace_trace(p); |
e32d8956 SR |
2283 | } |
2284 | put_online_cpus(); | |
2285 | } | |
978f3a45 | 2286 | |
e32d8956 SR |
2287 | static void set_ftrace_swapper(void) |
2288 | { | |
2289 | struct task_struct *p; | |
2290 | int cpu; | |
2291 | ||
2292 | get_online_cpus(); | |
2293 | for_each_online_cpu(cpu) { | |
2294 | p = idle_task(cpu); | |
2295 | set_tsk_trace_trace(p); | |
2296 | } | |
2297 | put_online_cpus(); | |
978f3a45 SR |
2298 | } |
2299 | ||
e32d8956 SR |
2300 | static void clear_ftrace_pid(struct pid *pid) |
2301 | { | |
2302 | struct task_struct *p; | |
2303 | ||
229c4ef8 | 2304 | rcu_read_lock(); |
e32d8956 SR |
2305 | do_each_pid_task(pid, PIDTYPE_PID, p) { |
2306 | clear_tsk_trace_trace(p); | |
2307 | } while_each_pid_task(pid, PIDTYPE_PID, p); | |
229c4ef8 ON |
2308 | rcu_read_unlock(); |
2309 | ||
e32d8956 SR |
2310 | put_pid(pid); |
2311 | } | |
2312 | ||
2313 | static void set_ftrace_pid(struct pid *pid) | |
978f3a45 SR |
2314 | { |
2315 | struct task_struct *p; | |
2316 | ||
229c4ef8 | 2317 | rcu_read_lock(); |
978f3a45 SR |
2318 | do_each_pid_task(pid, PIDTYPE_PID, p) { |
2319 | set_tsk_trace_trace(p); | |
2320 | } while_each_pid_task(pid, PIDTYPE_PID, p); | |
229c4ef8 | 2321 | rcu_read_unlock(); |
978f3a45 SR |
2322 | } |
2323 | ||
e32d8956 SR |
2324 | static void clear_ftrace_pid_task(struct pid **pid) |
2325 | { | |
2326 | if (*pid == ftrace_swapper_pid) | |
2327 | clear_ftrace_swapper(); | |
2328 | else | |
2329 | clear_ftrace_pid(*pid); | |
2330 | ||
2331 | *pid = NULL; | |
2332 | } | |
2333 | ||
2334 | static void set_ftrace_pid_task(struct pid *pid) | |
2335 | { | |
2336 | if (pid == ftrace_swapper_pid) | |
2337 | set_ftrace_swapper(); | |
2338 | else | |
2339 | set_ftrace_pid(pid); | |
2340 | } | |
2341 | ||
df4fc315 SR |
2342 | static ssize_t |
2343 | ftrace_pid_write(struct file *filp, const char __user *ubuf, | |
2344 | size_t cnt, loff_t *ppos) | |
2345 | { | |
978f3a45 | 2346 | struct pid *pid; |
df4fc315 SR |
2347 | char buf[64]; |
2348 | long val; | |
2349 | int ret; | |
2350 | ||
2351 | if (cnt >= sizeof(buf)) | |
2352 | return -EINVAL; | |
2353 | ||
2354 | if (copy_from_user(&buf, ubuf, cnt)) | |
2355 | return -EFAULT; | |
2356 | ||
2357 | buf[cnt] = 0; | |
2358 | ||
2359 | ret = strict_strtol(buf, 10, &val); | |
2360 | if (ret < 0) | |
2361 | return ret; | |
2362 | ||
e6ea44e9 | 2363 | mutex_lock(&ftrace_lock); |
978f3a45 | 2364 | if (val < 0) { |
df4fc315 | 2365 | /* disable pid tracing */ |
978f3a45 | 2366 | if (!ftrace_pid_trace) |
df4fc315 | 2367 | goto out; |
978f3a45 SR |
2368 | |
2369 | clear_ftrace_pid_task(&ftrace_pid_trace); | |
df4fc315 SR |
2370 | |
2371 | } else { | |
e32d8956 SR |
2372 | /* swapper task is special */ |
2373 | if (!val) { | |
2374 | pid = ftrace_swapper_pid; | |
2375 | if (pid == ftrace_pid_trace) | |
2376 | goto out; | |
2377 | } else { | |
2378 | pid = find_get_pid(val); | |
df4fc315 | 2379 | |
e32d8956 SR |
2380 | if (pid == ftrace_pid_trace) { |
2381 | put_pid(pid); | |
2382 | goto out; | |
2383 | } | |
0ef8cde5 | 2384 | } |
0ef8cde5 | 2385 | |
978f3a45 SR |
2386 | if (ftrace_pid_trace) |
2387 | clear_ftrace_pid_task(&ftrace_pid_trace); | |
2388 | ||
2389 | if (!pid) | |
2390 | goto out; | |
2391 | ||
2392 | ftrace_pid_trace = pid; | |
2393 | ||
2394 | set_ftrace_pid_task(ftrace_pid_trace); | |
df4fc315 SR |
2395 | } |
2396 | ||
2397 | /* update the function call */ | |
2398 | ftrace_update_pid_func(); | |
2399 | ftrace_startup_enable(0); | |
2400 | ||
2401 | out: | |
e6ea44e9 | 2402 | mutex_unlock(&ftrace_lock); |
df4fc315 SR |
2403 | |
2404 | return cnt; | |
2405 | } | |
2406 | ||
5e2336a0 | 2407 | static const struct file_operations ftrace_pid_fops = { |
df4fc315 SR |
2408 | .read = ftrace_pid_read, |
2409 | .write = ftrace_pid_write, | |
2410 | }; | |
2411 | ||
2412 | static __init int ftrace_init_debugfs(void) | |
2413 | { | |
2414 | struct dentry *d_tracer; | |
2415 | struct dentry *entry; | |
2416 | ||
2417 | d_tracer = tracing_init_dentry(); | |
2418 | if (!d_tracer) | |
2419 | return 0; | |
2420 | ||
2421 | ftrace_init_dyn_debugfs(d_tracer); | |
2422 | ||
2423 | entry = debugfs_create_file("set_ftrace_pid", 0644, d_tracer, | |
2424 | NULL, &ftrace_pid_fops); | |
2425 | if (!entry) | |
2426 | pr_warning("Could not create debugfs " | |
2427 | "'set_ftrace_pid' entry\n"); | |
2428 | return 0; | |
2429 | } | |
df4fc315 SR |
2430 | fs_initcall(ftrace_init_debugfs); |
2431 | ||
a2bb6a3d | 2432 | /** |
81adbdc0 | 2433 | * ftrace_kill - kill ftrace |
a2bb6a3d SR |
2434 | * |
2435 | * This function should be used by panic code. It stops ftrace | |
2436 | * but in a not so nice way. If you need to simply kill ftrace | |
2437 | * from a non-atomic section, use ftrace_kill. | |
2438 | */ | |
81adbdc0 | 2439 | void ftrace_kill(void) |
a2bb6a3d SR |
2440 | { |
2441 | ftrace_disabled = 1; | |
2442 | ftrace_enabled = 0; | |
a2bb6a3d SR |
2443 | clear_ftrace_function(); |
2444 | } | |
2445 | ||
16444a8a | 2446 | /** |
3d083395 SR |
2447 | * register_ftrace_function - register a function for profiling |
2448 | * @ops - ops structure that holds the function for profiling. | |
16444a8a | 2449 | * |
3d083395 SR |
2450 | * Register a function to be called by all functions in the |
2451 | * kernel. | |
2452 | * | |
2453 | * Note: @ops->func and all the functions it calls must be labeled | |
2454 | * with "notrace", otherwise it will go into a | |
2455 | * recursive loop. | |
16444a8a | 2456 | */ |
3d083395 | 2457 | int register_ftrace_function(struct ftrace_ops *ops) |
16444a8a | 2458 | { |
b0fc494f SR |
2459 | int ret; |
2460 | ||
4eebcc81 SR |
2461 | if (unlikely(ftrace_disabled)) |
2462 | return -1; | |
2463 | ||
e6ea44e9 | 2464 | mutex_lock(&ftrace_lock); |
e7d3737e | 2465 | |
b0fc494f | 2466 | ret = __register_ftrace_function(ops); |
5a45cfe1 | 2467 | ftrace_startup(0); |
b0fc494f | 2468 | |
e6ea44e9 | 2469 | mutex_unlock(&ftrace_lock); |
b0fc494f | 2470 | return ret; |
3d083395 SR |
2471 | } |
2472 | ||
2473 | /** | |
32632920 | 2474 | * unregister_ftrace_function - unregister a function for profiling. |
3d083395 SR |
2475 | * @ops - ops structure that holds the function to unregister |
2476 | * | |
2477 | * Unregister a function that was added to be called by ftrace profiling. | |
2478 | */ | |
2479 | int unregister_ftrace_function(struct ftrace_ops *ops) | |
2480 | { | |
2481 | int ret; | |
2482 | ||
e6ea44e9 | 2483 | mutex_lock(&ftrace_lock); |
3d083395 | 2484 | ret = __unregister_ftrace_function(ops); |
5a45cfe1 | 2485 | ftrace_shutdown(0); |
e6ea44e9 | 2486 | mutex_unlock(&ftrace_lock); |
b0fc494f SR |
2487 | |
2488 | return ret; | |
2489 | } | |
2490 | ||
e309b41d | 2491 | int |
b0fc494f | 2492 | ftrace_enable_sysctl(struct ctl_table *table, int write, |
5072c59f | 2493 | struct file *file, void __user *buffer, size_t *lenp, |
b0fc494f SR |
2494 | loff_t *ppos) |
2495 | { | |
2496 | int ret; | |
2497 | ||
4eebcc81 SR |
2498 | if (unlikely(ftrace_disabled)) |
2499 | return -ENODEV; | |
2500 | ||
e6ea44e9 | 2501 | mutex_lock(&ftrace_lock); |
b0fc494f | 2502 | |
5072c59f | 2503 | ret = proc_dointvec(table, write, file, buffer, lenp, ppos); |
b0fc494f SR |
2504 | |
2505 | if (ret || !write || (last_ftrace_enabled == ftrace_enabled)) | |
2506 | goto out; | |
2507 | ||
2508 | last_ftrace_enabled = ftrace_enabled; | |
2509 | ||
2510 | if (ftrace_enabled) { | |
2511 | ||
2512 | ftrace_startup_sysctl(); | |
2513 | ||
2514 | /* we are starting ftrace again */ | |
2515 | if (ftrace_list != &ftrace_list_end) { | |
2516 | if (ftrace_list->next == &ftrace_list_end) | |
2517 | ftrace_trace_function = ftrace_list->func; | |
2518 | else | |
2519 | ftrace_trace_function = ftrace_list_func; | |
2520 | } | |
2521 | ||
2522 | } else { | |
2523 | /* stopping ftrace calls (just send to ftrace_stub) */ | |
2524 | ftrace_trace_function = ftrace_stub; | |
2525 | ||
2526 | ftrace_shutdown_sysctl(); | |
2527 | } | |
2528 | ||
2529 | out: | |
e6ea44e9 | 2530 | mutex_unlock(&ftrace_lock); |
3d083395 | 2531 | return ret; |
16444a8a | 2532 | } |
f17845e5 | 2533 | |
fb52607a | 2534 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
e7d3737e | 2535 | |
287b6e68 | 2536 | static atomic_t ftrace_graph_active; |
4a2b8dda | 2537 | static struct notifier_block ftrace_suspend_notifier; |
e7d3737e | 2538 | |
e49dc19c SR |
2539 | int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace) |
2540 | { | |
2541 | return 0; | |
2542 | } | |
2543 | ||
287b6e68 FW |
2544 | /* The callbacks that hook a function */ |
2545 | trace_func_graph_ret_t ftrace_graph_return = | |
2546 | (trace_func_graph_ret_t)ftrace_stub; | |
e49dc19c | 2547 | trace_func_graph_ent_t ftrace_graph_entry = ftrace_graph_entry_stub; |
f201ae23 FW |
2548 | |
2549 | /* Try to assign a return stack array on FTRACE_RETSTACK_ALLOC_SIZE tasks. */ | |
2550 | static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) | |
2551 | { | |
2552 | int i; | |
2553 | int ret = 0; | |
2554 | unsigned long flags; | |
2555 | int start = 0, end = FTRACE_RETSTACK_ALLOC_SIZE; | |
2556 | struct task_struct *g, *t; | |
2557 | ||
2558 | for (i = 0; i < FTRACE_RETSTACK_ALLOC_SIZE; i++) { | |
2559 | ret_stack_list[i] = kmalloc(FTRACE_RETFUNC_DEPTH | |
2560 | * sizeof(struct ftrace_ret_stack), | |
2561 | GFP_KERNEL); | |
2562 | if (!ret_stack_list[i]) { | |
2563 | start = 0; | |
2564 | end = i; | |
2565 | ret = -ENOMEM; | |
2566 | goto free; | |
2567 | } | |
2568 | } | |
2569 | ||
2570 | read_lock_irqsave(&tasklist_lock, flags); | |
2571 | do_each_thread(g, t) { | |
2572 | if (start == end) { | |
2573 | ret = -EAGAIN; | |
2574 | goto unlock; | |
2575 | } | |
2576 | ||
2577 | if (t->ret_stack == NULL) { | |
f201ae23 | 2578 | t->curr_ret_stack = -1; |
48d68b20 FW |
2579 | /* Make sure IRQs see the -1 first: */ |
2580 | barrier(); | |
2581 | t->ret_stack = ret_stack_list[start++]; | |
380c4b14 | 2582 | atomic_set(&t->tracing_graph_pause, 0); |
f201ae23 FW |
2583 | atomic_set(&t->trace_overrun, 0); |
2584 | } | |
2585 | } while_each_thread(g, t); | |
2586 | ||
2587 | unlock: | |
2588 | read_unlock_irqrestore(&tasklist_lock, flags); | |
2589 | free: | |
2590 | for (i = start; i < end; i++) | |
2591 | kfree(ret_stack_list[i]); | |
2592 | return ret; | |
2593 | } | |
2594 | ||
8aef2d28 SR |
2595 | static void |
2596 | ftrace_graph_probe_sched_switch(struct rq *__rq, struct task_struct *prev, | |
2597 | struct task_struct *next) | |
2598 | { | |
2599 | unsigned long long timestamp; | |
2600 | int index; | |
2601 | ||
be6f164a SR |
2602 | /* |
2603 | * Does the user want to count the time a function was asleep. | |
2604 | * If so, do not update the time stamps. | |
2605 | */ | |
2606 | if (trace_flags & TRACE_ITER_SLEEP_TIME) | |
2607 | return; | |
2608 | ||
8aef2d28 SR |
2609 | timestamp = trace_clock_local(); |
2610 | ||
2611 | prev->ftrace_timestamp = timestamp; | |
2612 | ||
2613 | /* only process tasks that we timestamped */ | |
2614 | if (!next->ftrace_timestamp) | |
2615 | return; | |
2616 | ||
2617 | /* | |
2618 | * Update all the counters in next to make up for the | |
2619 | * time next was sleeping. | |
2620 | */ | |
2621 | timestamp -= next->ftrace_timestamp; | |
2622 | ||
2623 | for (index = next->curr_ret_stack; index >= 0; index--) | |
2624 | next->ret_stack[index].calltime += timestamp; | |
2625 | } | |
2626 | ||
f201ae23 | 2627 | /* Allocate a return stack for each task */ |
fb52607a | 2628 | static int start_graph_tracing(void) |
f201ae23 FW |
2629 | { |
2630 | struct ftrace_ret_stack **ret_stack_list; | |
5b058bcd | 2631 | int ret, cpu; |
f201ae23 FW |
2632 | |
2633 | ret_stack_list = kmalloc(FTRACE_RETSTACK_ALLOC_SIZE * | |
2634 | sizeof(struct ftrace_ret_stack *), | |
2635 | GFP_KERNEL); | |
2636 | ||
2637 | if (!ret_stack_list) | |
2638 | return -ENOMEM; | |
2639 | ||
5b058bcd FW |
2640 | /* The cpu_boot init_task->ret_stack will never be freed */ |
2641 | for_each_online_cpu(cpu) | |
2642 | ftrace_graph_init_task(idle_task(cpu)); | |
2643 | ||
f201ae23 FW |
2644 | do { |
2645 | ret = alloc_retstack_tasklist(ret_stack_list); | |
2646 | } while (ret == -EAGAIN); | |
2647 | ||
8aef2d28 SR |
2648 | if (!ret) { |
2649 | ret = register_trace_sched_switch(ftrace_graph_probe_sched_switch); | |
2650 | if (ret) | |
2651 | pr_info("ftrace_graph: Couldn't activate tracepoint" | |
2652 | " probe to kernel_sched_switch\n"); | |
2653 | } | |
2654 | ||
f201ae23 FW |
2655 | kfree(ret_stack_list); |
2656 | return ret; | |
2657 | } | |
2658 | ||
4a2b8dda FW |
2659 | /* |
2660 | * Hibernation protection. | |
2661 | * The state of the current task is too much unstable during | |
2662 | * suspend/restore to disk. We want to protect against that. | |
2663 | */ | |
2664 | static int | |
2665 | ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state, | |
2666 | void *unused) | |
2667 | { | |
2668 | switch (state) { | |
2669 | case PM_HIBERNATION_PREPARE: | |
2670 | pause_graph_tracing(); | |
2671 | break; | |
2672 | ||
2673 | case PM_POST_HIBERNATION: | |
2674 | unpause_graph_tracing(); | |
2675 | break; | |
2676 | } | |
2677 | return NOTIFY_DONE; | |
2678 | } | |
2679 | ||
287b6e68 FW |
2680 | int register_ftrace_graph(trace_func_graph_ret_t retfunc, |
2681 | trace_func_graph_ent_t entryfunc) | |
15e6cb36 | 2682 | { |
e7d3737e FW |
2683 | int ret = 0; |
2684 | ||
e6ea44e9 | 2685 | mutex_lock(&ftrace_lock); |
e7d3737e | 2686 | |
05ce5818 SR |
2687 | /* we currently allow only one tracer registered at a time */ |
2688 | if (atomic_read(&ftrace_graph_active)) { | |
2689 | ret = -EBUSY; | |
2690 | goto out; | |
2691 | } | |
2692 | ||
4a2b8dda FW |
2693 | ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call; |
2694 | register_pm_notifier(&ftrace_suspend_notifier); | |
2695 | ||
287b6e68 | 2696 | atomic_inc(&ftrace_graph_active); |
fb52607a | 2697 | ret = start_graph_tracing(); |
f201ae23 | 2698 | if (ret) { |
287b6e68 | 2699 | atomic_dec(&ftrace_graph_active); |
f201ae23 FW |
2700 | goto out; |
2701 | } | |
e53a6319 | 2702 | |
287b6e68 FW |
2703 | ftrace_graph_return = retfunc; |
2704 | ftrace_graph_entry = entryfunc; | |
e53a6319 | 2705 | |
5a45cfe1 | 2706 | ftrace_startup(FTRACE_START_FUNC_RET); |
e7d3737e FW |
2707 | |
2708 | out: | |
e6ea44e9 | 2709 | mutex_unlock(&ftrace_lock); |
e7d3737e | 2710 | return ret; |
15e6cb36 FW |
2711 | } |
2712 | ||
fb52607a | 2713 | void unregister_ftrace_graph(void) |
15e6cb36 | 2714 | { |
e6ea44e9 | 2715 | mutex_lock(&ftrace_lock); |
e7d3737e | 2716 | |
287b6e68 | 2717 | atomic_dec(&ftrace_graph_active); |
8aef2d28 | 2718 | unregister_trace_sched_switch(ftrace_graph_probe_sched_switch); |
287b6e68 | 2719 | ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub; |
e49dc19c | 2720 | ftrace_graph_entry = ftrace_graph_entry_stub; |
5a45cfe1 | 2721 | ftrace_shutdown(FTRACE_STOP_FUNC_RET); |
4a2b8dda | 2722 | unregister_pm_notifier(&ftrace_suspend_notifier); |
e7d3737e | 2723 | |
e6ea44e9 | 2724 | mutex_unlock(&ftrace_lock); |
15e6cb36 | 2725 | } |
f201ae23 FW |
2726 | |
2727 | /* Allocate a return stack for newly created task */ | |
fb52607a | 2728 | void ftrace_graph_init_task(struct task_struct *t) |
f201ae23 | 2729 | { |
287b6e68 | 2730 | if (atomic_read(&ftrace_graph_active)) { |
f201ae23 FW |
2731 | t->ret_stack = kmalloc(FTRACE_RETFUNC_DEPTH |
2732 | * sizeof(struct ftrace_ret_stack), | |
2733 | GFP_KERNEL); | |
2734 | if (!t->ret_stack) | |
2735 | return; | |
2736 | t->curr_ret_stack = -1; | |
380c4b14 | 2737 | atomic_set(&t->tracing_graph_pause, 0); |
f201ae23 | 2738 | atomic_set(&t->trace_overrun, 0); |
8aef2d28 | 2739 | t->ftrace_timestamp = 0; |
f201ae23 FW |
2740 | } else |
2741 | t->ret_stack = NULL; | |
2742 | } | |
2743 | ||
fb52607a | 2744 | void ftrace_graph_exit_task(struct task_struct *t) |
f201ae23 | 2745 | { |
eae849ca FW |
2746 | struct ftrace_ret_stack *ret_stack = t->ret_stack; |
2747 | ||
f201ae23 | 2748 | t->ret_stack = NULL; |
eae849ca FW |
2749 | /* NULL must become visible to IRQs before we free it: */ |
2750 | barrier(); | |
2751 | ||
2752 | kfree(ret_stack); | |
f201ae23 | 2753 | } |
14a866c5 SR |
2754 | |
2755 | void ftrace_graph_stop(void) | |
2756 | { | |
2757 | ftrace_stop(); | |
2758 | } | |
15e6cb36 FW |
2759 | #endif |
2760 |