aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2012-11-01 22:56:07 -0400
committerSteven Rostedt <rostedt@goodmis.org>2012-11-02 10:21:53 -0400
commit7bcfaf54f591a0775254c4ea679faf615152ee3a (patch)
tree697df255d0d3961b568c8e17f527f52175d7c3fa
parent0d5c6e1c19bab82fad4837108c2902f557d62a04 (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>
-rw-r--r--Documentation/kernel-parameters.txt16
-rw-r--r--kernel/trace/trace.c54
2 files changed, 55 insertions, 15 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 9776f068306b..2b48c52464a1 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2859,6 +2859,22 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2859 to facilitate early boot debugging. 2859 to facilitate early boot debugging.
2860 See also Documentation/trace/events.txt 2860 See also Documentation/trace/events.txt
2861 2861
2862 trace_options=[option-list]
2863 [FTRACE] Enable or disable tracer options at boot.
2864 The option-list is a comma delimited list of options
2865 that can be enabled or disabled just as if you were
2866 to echo the option name into
2867
2868 /sys/kernel/debug/tracing/trace_options
2869
2870 For example, to enable stacktrace option (to dump the
2871 stack trace of each event), add to the command line:
2872
2873 trace_options=stacktrace
2874
2875 See also Documentation/trace/ftrace.txt "trace options"
2876 section.
2877
2862 transparent_hugepage= 2878 transparent_hugepage=
2863 [KNL] 2879 [KNL]
2864 Format: [always|madvise|never] 2880 Format: [always|madvise|never]
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
159static char trace_boot_options_buf[MAX_TRACER_SIZE] __initdata;
160static char *trace_boot_options __initdata;
161
162static 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
158unsigned long long ns2usecs(cycle_t nsec) 170unsigned 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
2841static ssize_t 2853static int trace_set_options(char *option)
2842tracing_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
2884static ssize_t
2885tracing_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
5138out_free_cpumask: 5162out_free_cpumask: