diff options
author | Steven Rostedt <srostedt@redhat.com> | 2012-11-01 22:56:07 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2012-11-02 10:21:53 -0400 |
commit | 7bcfaf54f591a0775254c4ea679faf615152ee3a (patch) | |
tree | 697df255d0d3961b568c8e17f527f52175d7c3fa /kernel/trace/trace.c | |
parent | 0d5c6e1c19bab82fad4837108c2902f557d62a04 (diff) |
tracing: Add trace_options kernel command line parameter
Add trace_options to the kernel command line parameter to be able to
set options at early boot. For example, to enable stack dumps of
events, add the following:
trace_options=stacktrace
This along with the trace_event option, you can get not only
traces of the events but also the stack dumps with them.
Requested-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 37d1c703e3ec..c1434b5ce4d1 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -155,6 +155,18 @@ static int __init set_ftrace_dump_on_oops(char *str) | |||
155 | } | 155 | } |
156 | __setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops); | 156 | __setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops); |
157 | 157 | ||
158 | |||
159 | static char trace_boot_options_buf[MAX_TRACER_SIZE] __initdata; | ||
160 | static char *trace_boot_options __initdata; | ||
161 | |||
162 | static int __init set_trace_boot_options(char *str) | ||
163 | { | ||
164 | strncpy(trace_boot_options_buf, str, MAX_TRACER_SIZE); | ||
165 | trace_boot_options = trace_boot_options_buf; | ||
166 | return 0; | ||
167 | } | ||
168 | __setup("trace_options=", set_trace_boot_options); | ||
169 | |||
158 | unsigned long long ns2usecs(cycle_t nsec) | 170 | unsigned long long ns2usecs(cycle_t nsec) |
159 | { | 171 | { |
160 | nsec += 500; | 172 | nsec += 500; |
@@ -2838,24 +2850,14 @@ static void set_tracer_flags(unsigned int mask, int enabled) | |||
2838 | trace_printk_start_stop_comm(enabled); | 2850 | trace_printk_start_stop_comm(enabled); |
2839 | } | 2851 | } |
2840 | 2852 | ||
2841 | static ssize_t | 2853 | static int trace_set_options(char *option) |
2842 | tracing_trace_options_write(struct file *filp, const char __user *ubuf, | ||
2843 | size_t cnt, loff_t *ppos) | ||
2844 | { | 2854 | { |
2845 | char buf[64]; | ||
2846 | char *cmp; | 2855 | char *cmp; |
2847 | int neg = 0; | 2856 | int neg = 0; |
2848 | int ret; | 2857 | int ret = 0; |
2849 | int i; | 2858 | int i; |
2850 | 2859 | ||
2851 | if (cnt >= sizeof(buf)) | 2860 | cmp = strstrip(option); |
2852 | return -EINVAL; | ||
2853 | |||
2854 | if (copy_from_user(&buf, ubuf, cnt)) | ||
2855 | return -EFAULT; | ||
2856 | |||
2857 | buf[cnt] = 0; | ||
2858 | cmp = strstrip(buf); | ||
2859 | 2861 | ||
2860 | if (strncmp(cmp, "no", 2) == 0) { | 2862 | if (strncmp(cmp, "no", 2) == 0) { |
2861 | neg = 1; | 2863 | neg = 1; |
@@ -2874,10 +2876,25 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf, | |||
2874 | mutex_lock(&trace_types_lock); | 2876 | mutex_lock(&trace_types_lock); |
2875 | ret = set_tracer_option(current_trace, cmp, neg); | 2877 | ret = set_tracer_option(current_trace, cmp, neg); |
2876 | mutex_unlock(&trace_types_lock); | 2878 | mutex_unlock(&trace_types_lock); |
2877 | if (ret) | ||
2878 | return ret; | ||
2879 | } | 2879 | } |
2880 | 2880 | ||
2881 | return ret; | ||
2882 | } | ||
2883 | |||
2884 | static ssize_t | ||
2885 | tracing_trace_options_write(struct file *filp, const char __user *ubuf, | ||
2886 | size_t cnt, loff_t *ppos) | ||
2887 | { | ||
2888 | char buf[64]; | ||
2889 | |||
2890 | if (cnt >= sizeof(buf)) | ||
2891 | return -EINVAL; | ||
2892 | |||
2893 | if (copy_from_user(&buf, ubuf, cnt)) | ||
2894 | return -EFAULT; | ||
2895 | |||
2896 | trace_set_options(buf); | ||
2897 | |||
2881 | *ppos += cnt; | 2898 | *ppos += cnt; |
2882 | 2899 | ||
2883 | return cnt; | 2900 | return cnt; |
@@ -5133,6 +5150,13 @@ __init static int tracer_alloc_buffers(void) | |||
5133 | 5150 | ||
5134 | register_die_notifier(&trace_die_notifier); | 5151 | register_die_notifier(&trace_die_notifier); |
5135 | 5152 | ||
5153 | while (trace_boot_options) { | ||
5154 | char *option; | ||
5155 | |||
5156 | option = strsep(&trace_boot_options, ","); | ||
5157 | trace_set_options(option); | ||
5158 | } | ||
5159 | |||
5136 | return 0; | 5160 | return 0; |
5137 | 5161 | ||
5138 | out_free_cpumask: | 5162 | out_free_cpumask: |