diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2008-10-23 19:26:08 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-27 10:03:15 -0400 |
commit | 944ac4259e39801c843a915c3da8194ac9af0440 (patch) | |
tree | 0b028e4dfa510e41e09a6497eab4ff9f16642245 /kernel/trace/trace.c | |
parent | f4a2a0d9a4226846693b5b4462d4350c1bfd58ea (diff) |
ftrace: ftrace dump on oops control
Impact: add (default-off) dump-trace-on-oops flag
Currently, ftrace is set up to dump its contents to the console if the
kernel panics or oops. This can be annoying if you have trace data in
the buffers and you experience an oops, but the trace data is old or
static.
Usually when you want ftrace to dump its contents is when you are debugging
your system and you have set up ftrace to trace the events leading to
an oops.
This patch adds a control variable called "ftrace_dump_on_oops" that will
enable the ftrace dump to console on oops. This variable is default off
but a developer can enable it either through the kernel command line
by adding "ftrace_dump_on_oops" or at run time by setting (or disabling)
/proc/sys/kernel/ftrace_dump_on_oops.
v2:
Replaced /** with /* as Randy explained that kernel-doc does
not yet handle variables.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index d345d649d073..47f46cbdd860 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -63,6 +63,28 @@ static cpumask_t __read_mostly tracing_buffer_mask; | |||
63 | 63 | ||
64 | static int tracing_disabled = 1; | 64 | static int tracing_disabled = 1; |
65 | 65 | ||
66 | /* | ||
67 | * ftrace_dump_on_oops - variable to dump ftrace buffer on oops | ||
68 | * | ||
69 | * If there is an oops (or kernel panic) and the ftrace_dump_on_oops | ||
70 | * is set, then ftrace_dump is called. This will output the contents | ||
71 | * of the ftrace buffers to the console. This is very useful for | ||
72 | * capturing traces that lead to crashes and outputing it to a | ||
73 | * serial console. | ||
74 | * | ||
75 | * It is default off, but you can enable it with either specifying | ||
76 | * "ftrace_dump_on_oops" in the kernel command line, or setting | ||
77 | * /proc/sys/kernel/ftrace_dump_on_oops to true. | ||
78 | */ | ||
79 | int ftrace_dump_on_oops; | ||
80 | |||
81 | static int __init set_ftrace_dump_on_oops(char *str) | ||
82 | { | ||
83 | ftrace_dump_on_oops = 1; | ||
84 | return 1; | ||
85 | } | ||
86 | __setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops); | ||
87 | |||
66 | long | 88 | long |
67 | ns2usecs(cycle_t nsec) | 89 | ns2usecs(cycle_t nsec) |
68 | { | 90 | { |
@@ -3021,7 +3043,8 @@ EXPORT_SYMBOL_GPL(__ftrace_printk); | |||
3021 | static int trace_panic_handler(struct notifier_block *this, | 3043 | static int trace_panic_handler(struct notifier_block *this, |
3022 | unsigned long event, void *unused) | 3044 | unsigned long event, void *unused) |
3023 | { | 3045 | { |
3024 | ftrace_dump(); | 3046 | if (ftrace_dump_on_oops) |
3047 | ftrace_dump(); | ||
3025 | return NOTIFY_OK; | 3048 | return NOTIFY_OK; |
3026 | } | 3049 | } |
3027 | 3050 | ||
@@ -3037,7 +3060,8 @@ static int trace_die_handler(struct notifier_block *self, | |||
3037 | { | 3060 | { |
3038 | switch (val) { | 3061 | switch (val) { |
3039 | case DIE_OOPS: | 3062 | case DIE_OOPS: |
3040 | ftrace_dump(); | 3063 | if (ftrace_dump_on_oops) |
3064 | ftrace_dump(); | ||
3041 | break; | 3065 | break; |
3042 | default: | 3066 | default: |
3043 | break; | 3067 | break; |
@@ -3078,7 +3102,6 @@ trace_printk_seq(struct trace_seq *s) | |||
3078 | trace_seq_reset(s); | 3102 | trace_seq_reset(s); |
3079 | } | 3103 | } |
3080 | 3104 | ||
3081 | |||
3082 | void ftrace_dump(void) | 3105 | void ftrace_dump(void) |
3083 | { | 3106 | { |
3084 | static DEFINE_SPINLOCK(ftrace_dump_lock); | 3107 | static DEFINE_SPINLOCK(ftrace_dump_lock); |