diff options
-rw-r--r-- | Documentation/kernel-parameters.txt | 13 | ||||
-rw-r--r-- | include/linux/ftrace.h | 5 | ||||
-rw-r--r-- | kernel/panic.c | 3 | ||||
-rw-r--r-- | kernel/sysctl.c | 7 | ||||
-rw-r--r-- | kernel/trace/trace.c | 17 |
5 files changed, 45 insertions, 0 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 6e3b18a8afc6..729d0b9803b7 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -3069,6 +3069,19 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
3069 | See also Documentation/trace/ftrace.txt "trace options" | 3069 | See also Documentation/trace/ftrace.txt "trace options" |
3070 | section. | 3070 | section. |
3071 | 3071 | ||
3072 | traceoff_on_warning | ||
3073 | [FTRACE] enable this option to disable tracing when a | ||
3074 | warning is hit. This turns off "tracing_on". Tracing can | ||
3075 | be enabled again by echoing '1' into the "tracing_on" | ||
3076 | file located in /sys/kernel/debug/tracing/ | ||
3077 | |||
3078 | This option is useful, as it disables the trace before | ||
3079 | the WARNING dump is called, which prevents the trace to | ||
3080 | be filled with content caused by the warning output. | ||
3081 | |||
3082 | This option can also be set at run time via the sysctl | ||
3083 | option: kernel/traceoff_on_warning | ||
3084 | |||
3072 | transparent_hugepage= | 3085 | transparent_hugepage= |
3073 | [KNL] | 3086 | [KNL] |
3074 | Format: [always|madvise|never] | 3087 | Format: [always|madvise|never] |
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index e48ed1d7876d..9f15c0064c50 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
@@ -824,10 +824,15 @@ enum ftrace_dump_mode; | |||
824 | 824 | ||
825 | extern enum ftrace_dump_mode ftrace_dump_on_oops; | 825 | extern enum ftrace_dump_mode ftrace_dump_on_oops; |
826 | 826 | ||
827 | extern void disable_trace_on_warning(void); | ||
828 | extern int __disable_trace_on_warning; | ||
829 | |||
827 | #ifdef CONFIG_PREEMPT | 830 | #ifdef CONFIG_PREEMPT |
828 | #define INIT_TRACE_RECURSION .trace_recursion = 0, | 831 | #define INIT_TRACE_RECURSION .trace_recursion = 0, |
829 | #endif | 832 | #endif |
830 | 833 | ||
834 | #else /* CONFIG_TRACING */ | ||
835 | static inline void disable_trace_on_warning(void) { } | ||
831 | #endif /* CONFIG_TRACING */ | 836 | #endif /* CONFIG_TRACING */ |
832 | 837 | ||
833 | #ifndef INIT_TRACE_RECURSION | 838 | #ifndef INIT_TRACE_RECURSION |
diff --git a/kernel/panic.c b/kernel/panic.c index 167ec097ce8b..4cea6cc628ab 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/notifier.h> | 15 | #include <linux/notifier.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/random.h> | 17 | #include <linux/random.h> |
18 | #include <linux/ftrace.h> | ||
18 | #include <linux/reboot.h> | 19 | #include <linux/reboot.h> |
19 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
20 | #include <linux/kexec.h> | 21 | #include <linux/kexec.h> |
@@ -399,6 +400,8 @@ struct slowpath_args { | |||
399 | static void warn_slowpath_common(const char *file, int line, void *caller, | 400 | static void warn_slowpath_common(const char *file, int line, void *caller, |
400 | unsigned taint, struct slowpath_args *args) | 401 | unsigned taint, struct slowpath_args *args) |
401 | { | 402 | { |
403 | disable_trace_on_warning(); | ||
404 | |||
402 | printk(KERN_WARNING "------------[ cut here ]------------\n"); | 405 | printk(KERN_WARNING "------------[ cut here ]------------\n"); |
403 | printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller); | 406 | printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller); |
404 | 407 | ||
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 9edcf456e0fc..5b0f18c12800 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -600,6 +600,13 @@ static struct ctl_table kern_table[] = { | |||
600 | .mode = 0644, | 600 | .mode = 0644, |
601 | .proc_handler = proc_dointvec, | 601 | .proc_handler = proc_dointvec, |
602 | }, | 602 | }, |
603 | { | ||
604 | .procname = "traceoff_on_warning", | ||
605 | .data = &__disable_trace_on_warning, | ||
606 | .maxlen = sizeof(__disable_trace_on_warning), | ||
607 | .mode = 0644, | ||
608 | .proc_handler = proc_dointvec, | ||
609 | }, | ||
603 | #endif | 610 | #endif |
604 | #ifdef CONFIG_MODULES | 611 | #ifdef CONFIG_MODULES |
605 | { | 612 | { |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 5f4a09c12e0b..c4c9296b1916 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -115,6 +115,9 @@ cpumask_var_t __read_mostly tracing_buffer_mask; | |||
115 | 115 | ||
116 | enum ftrace_dump_mode ftrace_dump_on_oops; | 116 | enum ftrace_dump_mode ftrace_dump_on_oops; |
117 | 117 | ||
118 | /* When set, tracing will stop when a WARN*() is hit */ | ||
119 | int __disable_trace_on_warning; | ||
120 | |||
118 | static int tracing_set_tracer(const char *buf); | 121 | static int tracing_set_tracer(const char *buf); |
119 | 122 | ||
120 | #define MAX_TRACER_SIZE 100 | 123 | #define MAX_TRACER_SIZE 100 |
@@ -149,6 +152,13 @@ static int __init set_ftrace_dump_on_oops(char *str) | |||
149 | } | 152 | } |
150 | __setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops); | 153 | __setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops); |
151 | 154 | ||
155 | static int __init stop_trace_on_warning(char *str) | ||
156 | { | ||
157 | __disable_trace_on_warning = 1; | ||
158 | return 1; | ||
159 | } | ||
160 | __setup("traceoff_on_warning=", stop_trace_on_warning); | ||
161 | |||
152 | static int __init boot_alloc_snapshot(char *str) | 162 | static int __init boot_alloc_snapshot(char *str) |
153 | { | 163 | { |
154 | allocate_snapshot = true; | 164 | allocate_snapshot = true; |
@@ -170,6 +180,7 @@ static int __init set_trace_boot_options(char *str) | |||
170 | } | 180 | } |
171 | __setup("trace_options=", set_trace_boot_options); | 181 | __setup("trace_options=", set_trace_boot_options); |
172 | 182 | ||
183 | |||
173 | unsigned long long ns2usecs(cycle_t nsec) | 184 | unsigned long long ns2usecs(cycle_t nsec) |
174 | { | 185 | { |
175 | nsec += 500; | 186 | nsec += 500; |
@@ -562,6 +573,12 @@ void tracing_off(void) | |||
562 | } | 573 | } |
563 | EXPORT_SYMBOL_GPL(tracing_off); | 574 | EXPORT_SYMBOL_GPL(tracing_off); |
564 | 575 | ||
576 | void disable_trace_on_warning(void) | ||
577 | { | ||
578 | if (__disable_trace_on_warning) | ||
579 | tracing_off(); | ||
580 | } | ||
581 | |||
565 | /** | 582 | /** |
566 | * tracing_is_on - show state of ring buffers enabled | 583 | * tracing_is_on - show state of ring buffers enabled |
567 | */ | 584 | */ |