aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-05-28 13:37:24 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-06-01 23:23:10 -0400
commit2af15d6a44b871ad4c2a651302374cde8f335480 (patch)
tree39f06d511e3e1d1970fe4571128549c1c26230c1
parentf2aebaee653a35b01c3665de2cbb1e31456b8ea8 (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>
-rw-r--r--Documentation/kernel-parameters.txt17
-rw-r--r--kernel/trace/ftrace.c42
2 files changed, 57 insertions, 2 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 9243dd84f4d6..fcd3bfbe74e8 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -751,12 +751,25 @@ and is between 256 and 4096 characters. It is defined in the file
751 ia64_pal_cache_flush instead of SAL_CACHE_FLUSH. 751 ia64_pal_cache_flush instead of SAL_CACHE_FLUSH.
752 752
753 ftrace=[tracer] 753 ftrace=[tracer]
754 [ftrace] will set and start the specified tracer 754 [FTRACE] will set and start the specified tracer
755 as early as possible in order to facilitate early 755 as early as possible in order to facilitate early
756 boot debugging. 756 boot debugging.
757 757
758 ftrace_dump_on_oops 758 ftrace_dump_on_oops
759 [ftrace] will dump the trace buffers on oops. 759 [FTRACE] will dump the trace buffers on oops.
760
761 ftrace_filter=[function-list]
762 [FTRACE] Limit the functions traced by the function
763 tracer at boot up. function-list is a comma separated
764 list of functions. This list can be changed at run
765 time by the set_ftrace_filter file in the debugfs
766 tracing directory.
767
768 ftrace_notrace=[function-list]
769 [FTRACE] Do not trace the functions specified in
770 function-list. This list can be changed at run time
771 by the set_ftrace_notrace file in the debugfs
772 tracing directory.
760 773
761 gamecon.map[2|3]= 774 gamecon.map[2|3]=
762 [HW,JOY] Multisystem joystick and NES/SNES/PSX pad 775 [HW,JOY] Multisystem joystick and NES/SNES/PSX pad
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
2377static char ftrace_notrace_buf[FTRACE_FILTER_SIZE] __initdata;
2378static char ftrace_filter_buf[FTRACE_FILTER_SIZE] __initdata;
2379
2380static 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
2387static 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
2394static 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
2404static 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
2372static int 2412static int
2373ftrace_regex_release(struct inode *inode, struct file *file, int enable) 2413ftrace_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;