diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-05-28 13:37:24 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-06-01 23:23:10 -0400 |
commit | 2af15d6a44b871ad4c2a651302374cde8f335480 (patch) | |
tree | 39f06d511e3e1d1970fe4571128549c1c26230c1 /kernel/trace | |
parent | f2aebaee653a35b01c3665de2cbb1e31456b8ea8 (diff) |
ftrace: add kernel command line function filtering
When using ftrace=function on the command line to trace functions
on boot up, one can not filter out functions that are commonly called.
This patch adds two new ftrace command line commands.
ftrace_notrace=function-list
ftrace_filter=function-list
Where function-list is a comma separated list of functions to filter.
The ftrace_notrace will make the functions listed not be included
in the function tracing, and ftrace_filter will only trace the functions
listed.
These two act the same as the debugfs/tracing/set_ftrace_notrace and
debugfs/tracing/set_ftrace_filter respectively.
The simple glob expressions that are allowed by the filter files can also
be used by the command line interface.
ftrace_notrace=rcu*,*lock,*spin*
Will not trace any function that starts with rcu, ends with lock, or has
the word spin in it.
Note, if the self tests are enabled, they may interfere with the filtering
set by the command lines.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/ftrace.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 140699a9a8a7..2074e5b7766b 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <trace/events/sched.h> | 32 | #include <trace/events/sched.h> |
33 | 33 | ||
34 | #include <asm/ftrace.h> | 34 | #include <asm/ftrace.h> |
35 | #include <asm/setup.h> | ||
35 | 36 | ||
36 | #include "trace_output.h" | 37 | #include "trace_output.h" |
37 | #include "trace_stat.h" | 38 | #include "trace_stat.h" |
@@ -2369,6 +2370,45 @@ void ftrace_set_notrace(unsigned char *buf, int len, int reset) | |||
2369 | ftrace_set_regex(buf, len, reset, 0); | 2370 | ftrace_set_regex(buf, len, reset, 0); |
2370 | } | 2371 | } |
2371 | 2372 | ||
2373 | /* | ||
2374 | * command line interface to allow users to set filters on boot up. | ||
2375 | */ | ||
2376 | #define FTRACE_FILTER_SIZE COMMAND_LINE_SIZE | ||
2377 | static char ftrace_notrace_buf[FTRACE_FILTER_SIZE] __initdata; | ||
2378 | static char ftrace_filter_buf[FTRACE_FILTER_SIZE] __initdata; | ||
2379 | |||
2380 | static int __init set_ftrace_notrace(char *str) | ||
2381 | { | ||
2382 | strncpy(ftrace_notrace_buf, str, FTRACE_FILTER_SIZE); | ||
2383 | return 1; | ||
2384 | } | ||
2385 | __setup("ftrace_notrace=", set_ftrace_notrace); | ||
2386 | |||
2387 | static int __init set_ftrace_filter(char *str) | ||
2388 | { | ||
2389 | strncpy(ftrace_filter_buf, str, FTRACE_FILTER_SIZE); | ||
2390 | return 1; | ||
2391 | } | ||
2392 | __setup("ftrace_filter=", set_ftrace_filter); | ||
2393 | |||
2394 | static void __init set_ftrace_early_filter(char *buf, int enable) | ||
2395 | { | ||
2396 | char *func; | ||
2397 | |||
2398 | while (buf) { | ||
2399 | func = strsep(&buf, ","); | ||
2400 | ftrace_set_regex(func, strlen(func), 0, enable); | ||
2401 | } | ||
2402 | } | ||
2403 | |||
2404 | static void __init set_ftrace_early_filters(void) | ||
2405 | { | ||
2406 | if (ftrace_filter_buf[0]) | ||
2407 | set_ftrace_early_filter(ftrace_filter_buf, 1); | ||
2408 | if (ftrace_notrace_buf[0]) | ||
2409 | set_ftrace_early_filter(ftrace_notrace_buf, 0); | ||
2410 | } | ||
2411 | |||
2372 | static int | 2412 | static int |
2373 | ftrace_regex_release(struct inode *inode, struct file *file, int enable) | 2413 | ftrace_regex_release(struct inode *inode, struct file *file, int enable) |
2374 | { | 2414 | { |
@@ -2829,6 +2869,8 @@ void __init ftrace_init(void) | |||
2829 | if (ret) | 2869 | if (ret) |
2830 | pr_warning("Failed to register trace ftrace module notifier\n"); | 2870 | pr_warning("Failed to register trace ftrace module notifier\n"); |
2831 | 2871 | ||
2872 | set_ftrace_early_filters(); | ||
2873 | |||
2832 | return; | 2874 | return; |
2833 | failed: | 2875 | failed: |
2834 | ftrace_disabled = 1; | 2876 | ftrace_disabled = 1; |