diff options
-rw-r--r-- | Documentation/kernel-parameters.txt | 16 | ||||
-rw-r--r-- | kernel/trace/trace.c | 54 |
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 | |||
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: |