linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ftrace: ftrace dump on oops control
@ 2008-10-23 19:15 Steven Rostedt
  2008-10-23 22:54 ` Randy Dunlap
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2008-10-23 19:15 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, Peter Zijlstra,
	Linus Torvalds


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.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 include/linux/ftrace.h |    2 ++
 kernel/sysctl.c        |   10 ++++++++++
 kernel/trace/trace.c   |   29 ++++++++++++++++++++++++++---
 3 files changed, 38 insertions(+), 3 deletions(-)

Index: linux-tip.git/include/linux/ftrace.h
===================================================================
--- linux-tip.git.orig/include/linux/ftrace.h	2008-10-23 12:55:35.000000000 -0400
+++ linux-tip.git/include/linux/ftrace.h	2008-10-23 14:17:22.000000000 -0400
@@ -181,6 +181,8 @@ static inline void __ftrace_enabled_rest
 #endif
 
 #ifdef CONFIG_TRACING
+extern int ftrace_dump_on_oops;
+
 extern void
 ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
 
Index: linux-tip.git/kernel/sysctl.c
===================================================================
--- linux-tip.git.orig/kernel/sysctl.c	2008-10-23 12:55:37.000000000 -0400
+++ linux-tip.git/kernel/sysctl.c	2008-10-23 15:01:00.000000000 -0400
@@ -485,6 +485,16 @@ static struct ctl_table kern_table[] = {
 		.proc_handler	= &ftrace_enable_sysctl,
 	},
 #endif
+#ifdef CONFIG_TRACING
+	{
+		.ctl_name	= CTL_UNNUMBERED,
+		.procname	= "ftrace_dump_on_opps",
+		.data		= &ftrace_dump_on_oops,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec,
+	},
+#endif
 #ifdef CONFIG_MODULES
 	{
 		.ctl_name	= KERN_MODPROBE,
Index: linux-tip.git/kernel/trace/trace.c
===================================================================
--- linux-tip.git.orig/kernel/trace/trace.c	2008-10-23 12:55:37.000000000 -0400
+++ linux-tip.git/kernel/trace/trace.c	2008-10-23 14:24:28.000000000 -0400
@@ -63,6 +63,28 @@ static cpumask_t __read_mostly		tracing_
 
 static int tracing_disabled = 1;
 
+/**
+ * ftrace_dump_on_oops - variable to dump ftrace buffer on oops
+ *
+ * If there is an oops (or kernel panic) and the ftrace_dump_on_oops
+ * is set, then ftrace_dump is called. This will output the contents
+ * of the ftrace buffers to the console.  This is very useful for
+ * capturing traces that lead to crashes and outputing it to a
+ * serial console.
+ *
+ * It is default off, but you can enable it with either specifying
+ * "ftrace_dump_on_oops" in the kernel command line, or setting
+ * /proc/sys/kernel/ftrace_dump_on_oops to true.
+ */
+int ftrace_dump_on_oops;
+
+static int __init set_ftrace_dump_on_oops(char *str)
+{
+	ftrace_dump_on_oops = 1;
+	return 1;
+}
+__setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops);
+
 long
 ns2usecs(cycle_t nsec)
 {
@@ -3018,7 +3040,8 @@ EXPORT_SYMBOL_GPL(__ftrace_printk);
 static int trace_panic_handler(struct notifier_block *this,
 			       unsigned long event, void *unused)
 {
-	ftrace_dump();
+	if (ftrace_dump_on_oops)
+		ftrace_dump();
 	return NOTIFY_OK;
 }
 
@@ -3034,7 +3057,8 @@ static int trace_die_handler(struct noti
 {
 	switch (val) {
 	case DIE_OOPS:
-		ftrace_dump();
+		if (ftrace_dump_on_oops)
+			ftrace_dump();
 		break;
 	default:
 		break;
@@ -3075,7 +3099,6 @@ trace_printk_seq(struct trace_seq *s)
 	trace_seq_reset(s);
 }
 
-
 void ftrace_dump(void)
 {
 	static DEFINE_SPINLOCK(ftrace_dump_lock);


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ftrace: ftrace dump on oops control
  2008-10-23 19:15 [PATCH] ftrace: ftrace dump on oops control Steven Rostedt
@ 2008-10-23 22:54 ` Randy Dunlap
  2008-10-23 23:02   ` Steven Rostedt
  2008-10-23 23:26   ` [PATCH v2] " Steven Rostedt
  0 siblings, 2 replies; 5+ messages in thread
From: Randy Dunlap @ 2008-10-23 22:54 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Ingo Molnar, Thomas Gleixner, Andrew Morton,
	Peter Zijlstra, Linus Torvalds

On Thu, 23 Oct 2008 15:15:27 -0400 (EDT) Steven Rostedt wrote:

> +/**
> + * ftrace_dump_on_oops - variable to dump ftrace buffer on oops
> + *
> + * If there is an oops (or kernel panic) and the ftrace_dump_on_oops
> + * is set, then ftrace_dump is called. This will output the contents
> + * of the ftrace buffers to the console.  This is very useful for
> + * capturing traces that lead to crashes and outputing it to a
> + * serial console.
> + *
> + * It is default off, but you can enable it with either specifying
> + * "ftrace_dump_on_oops" in the kernel command line, or setting
> + * /proc/sys/kernel/ftrace_dump_on_oops to true.
> + */
> +int ftrace_dump_on_oops;

Hi Steven,

Please lose the /** (just use /*).  The documentation is a good thing,
but we don't do kernel-doc for simple variables.
That might be a good thing to add one day....

---
~Randy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ftrace: ftrace dump on oops control
  2008-10-23 22:54 ` Randy Dunlap
@ 2008-10-23 23:02   ` Steven Rostedt
  2008-10-23 23:26   ` [PATCH v2] " Steven Rostedt
  1 sibling, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2008-10-23 23:02 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: LKML, Ingo Molnar, Thomas Gleixner, Andrew Morton,
	Peter Zijlstra, Linus Torvalds


On Thu, 23 Oct 2008, Randy Dunlap wrote:

> On Thu, 23 Oct 2008 15:15:27 -0400 (EDT) Steven Rostedt wrote:
> 
> > +/**
> > + * ftrace_dump_on_oops - variable to dump ftrace buffer on oops
> > + *
> > + * If there is an oops (or kernel panic) and the ftrace_dump_on_oops
> > + * is set, then ftrace_dump is called. This will output the contents
> > + * of the ftrace buffers to the console.  This is very useful for
> > + * capturing traces that lead to crashes and outputing it to a
> > + * serial console.
> > + *
> > + * It is default off, but you can enable it with either specifying
> > + * "ftrace_dump_on_oops" in the kernel command line, or setting
> > + * /proc/sys/kernel/ftrace_dump_on_oops to true.
> > + */
> > +int ftrace_dump_on_oops;
> 
> Hi Steven,
> 
> Please lose the /** (just use /*).  The documentation is a good thing,
> but we don't do kernel-doc for simple variables.
> That might be a good thing to add one day....

OK, will do. Yeah, this variable is kind of special, and I wanted it to
be documented well. Oh well, I'll have to wait for kernel-doc to do
variables ;-)

I'll send a new patch that does the update.

-- Steve


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] ftrace: ftrace dump on oops control
  2008-10-23 22:54 ` Randy Dunlap
  2008-10-23 23:02   ` Steven Rostedt
@ 2008-10-23 23:26   ` Steven Rostedt
  2008-10-27 14:03     ` Ingo Molnar
  1 sibling, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2008-10-23 23:26 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: LKML, Ingo Molnar, Thomas Gleixner, Andrew Morton,
	Peter Zijlstra, Linus Torvalds

[
  Changes since v1:

   Replaced /** with /* as Randy explained that kernel-doc does
    not yet handle variables.
]

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.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 include/linux/ftrace.h |    2 ++
 kernel/sysctl.c        |   10 ++++++++++
 kernel/trace/trace.c   |   29 ++++++++++++++++++++++++++---
 3 files changed, 38 insertions(+), 3 deletions(-)

Index: linux-tip.git/include/linux/ftrace.h
===================================================================
--- linux-tip.git.orig/include/linux/ftrace.h	2008-10-23 12:55:35.000000000 -0400
+++ linux-tip.git/include/linux/ftrace.h	2008-10-23 15:31:50.000000000 -0400
@@ -181,6 +181,8 @@ static inline void __ftrace_enabled_rest
 #endif
 
 #ifdef CONFIG_TRACING
+extern int ftrace_dump_on_oops;
+
 extern void
 ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
 
Index: linux-tip.git/kernel/sysctl.c
===================================================================
--- linux-tip.git.orig/kernel/sysctl.c	2008-10-23 12:55:37.000000000 -0400
+++ linux-tip.git/kernel/sysctl.c	2008-10-23 15:01:00.000000000 -0400
@@ -485,6 +485,16 @@ static struct ctl_table kern_table[] = {
 		.proc_handler	= &ftrace_enable_sysctl,
 	},
 #endif
+#ifdef CONFIG_TRACING
+	{
+		.ctl_name	= CTL_UNNUMBERED,
+		.procname	= "ftrace_dump_on_opps",
+		.data		= &ftrace_dump_on_oops,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec,
+	},
+#endif
 #ifdef CONFIG_MODULES
 	{
 		.ctl_name	= KERN_MODPROBE,
Index: linux-tip.git/kernel/trace/trace.c
===================================================================
--- linux-tip.git.orig/kernel/trace/trace.c	2008-10-23 12:55:37.000000000 -0400
+++ linux-tip.git/kernel/trace/trace.c	2008-10-23 19:24:15.000000000 -0400
@@ -63,6 +63,28 @@ static cpumask_t __read_mostly		tracing_
 
 static int tracing_disabled = 1;
 
+/*
+ * ftrace_dump_on_oops - variable to dump ftrace buffer on oops
+ *
+ * If there is an oops (or kernel panic) and the ftrace_dump_on_oops
+ * is set, then ftrace_dump is called. This will output the contents
+ * of the ftrace buffers to the console.  This is very useful for
+ * capturing traces that lead to crashes and outputing it to a
+ * serial console.
+ *
+ * It is default off, but you can enable it with either specifying
+ * "ftrace_dump_on_oops" in the kernel command line, or setting
+ * /proc/sys/kernel/ftrace_dump_on_oops to true.
+ */
+int ftrace_dump_on_oops;
+
+static int __init set_ftrace_dump_on_oops(char *str)
+{
+	ftrace_dump_on_oops = 1;
+	return 1;
+}
+__setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops);
+
 long
 ns2usecs(cycle_t nsec)
 {
@@ -3018,7 +3040,8 @@ EXPORT_SYMBOL_GPL(__ftrace_printk);
 static int trace_panic_handler(struct notifier_block *this,
 			       unsigned long event, void *unused)
 {
-	ftrace_dump();
+	if (ftrace_dump_on_oops)
+		ftrace_dump();
 	return NOTIFY_OK;
 }
 
@@ -3034,7 +3057,8 @@ static int trace_die_handler(struct noti
 {
 	switch (val) {
 	case DIE_OOPS:
-		ftrace_dump();
+		if (ftrace_dump_on_oops)
+			ftrace_dump();
 		break;
 	default:
 		break;
@@ -3075,7 +3099,6 @@ trace_printk_seq(struct trace_seq *s)
 	trace_seq_reset(s);
 }
 
-
 void ftrace_dump(void)
 {
 	static DEFINE_SPINLOCK(ftrace_dump_lock);



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ftrace: ftrace dump on oops control
  2008-10-23 23:26   ` [PATCH v2] " Steven Rostedt
@ 2008-10-27 14:03     ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2008-10-27 14:03 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Randy Dunlap, LKML, Thomas Gleixner, Andrew Morton,
	Peter Zijlstra, Linus Torvalds


* Steven Rostedt <rostedt@goodmis.org> wrote:

> [
>   Changes since v1:
> 
>    Replaced /** with /* as Randy explained that kernel-doc does
>     not yet handle variables.
> ]
> 
> 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.
> 
> Signed-off-by: Steven Rostedt <srostedt@redhat.com>
> ---
>  include/linux/ftrace.h |    2 ++
>  kernel/sysctl.c        |   10 ++++++++++
>  kernel/trace/trace.c   |   29 ++++++++++++++++++++++++++---
>  3 files changed, 38 insertions(+), 3 deletions(-)

applied to tip/tracing/ftrace, thanks Steve!

	Ingo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-10-27 14:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-23 19:15 [PATCH] ftrace: ftrace dump on oops control Steven Rostedt
2008-10-23 22:54 ` Randy Dunlap
2008-10-23 23:02   ` Steven Rostedt
2008-10-23 23:26   ` [PATCH v2] " Steven Rostedt
2008-10-27 14:03     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).