public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [git pull] core/stacktrace changes for v2.6.27
@ 2008-07-14 14:44 Ingo Molnar
  2008-07-14 15:35 ` Stephen Rothwell
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2008-07-14 14:44 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, Andrew Morton

Linus,

Please pull the latest core/stacktrace git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git core/stacktrace

Thanks,

	Ingo

------------------>
Ingo Molnar (3):
      debugging: make stacktrace independent from DEBUG_KERNEL
      stacktrace: fix modular build, export print_stack_trace and save_stack_trace
      stacktrace: export save_stack_trace[_tsk]

Johannes Berg (1):
      stacktrace: don't crash on invalid stack trace structs

Stephen Rothwell (1):
      stacktrace: fix build failure on sparc64

Vegard Nossum (3):
      stacktrace: print_stack_trace() cleanup
      stacktrace: add saved stack traces to backtrace self-test
      backtrace: replace timer with tasklet + completions


 arch/arm/kernel/stacktrace.c     |    1 +
 arch/avr32/kernel/stacktrace.c   |    1 +
 arch/mips/kernel/stacktrace.c    |    1 +
 arch/powerpc/kernel/stacktrace.c |    1 +
 arch/s390/kernel/stacktrace.c    |    2 +
 arch/sh/kernel/stacktrace.c      |    1 +
 arch/sparc64/kernel/stacktrace.c |    2 +
 arch/x86/kernel/stacktrace.c     |    2 +
 kernel/backtracetest.c           |   65 +++++++++++++++++++++++++++++++------
 kernel/stacktrace.c              |   14 +++++---
 lib/Kconfig.debug                |    4 ++-
 11 files changed, 76 insertions(+), 18 deletions(-)

diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index ae31deb..6b3ffde 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -66,4 +66,5 @@ void save_stack_trace(struct stack_trace *trace)
 
 	walk_stackframe(fp, base, base + THREAD_SIZE, save_trace, &data);
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
 #endif
diff --git a/arch/avr32/kernel/stacktrace.c b/arch/avr32/kernel/stacktrace.c
index 9a68190..f4bdb44 100644
--- a/arch/avr32/kernel/stacktrace.c
+++ b/arch/avr32/kernel/stacktrace.c
@@ -51,3 +51,4 @@ void save_stack_trace(struct stack_trace *trace)
 		fp = frame->fp;
 	}
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/mips/kernel/stacktrace.c b/arch/mips/kernel/stacktrace.c
index ebd9db8..5eb4681 100644
--- a/arch/mips/kernel/stacktrace.c
+++ b/arch/mips/kernel/stacktrace.c
@@ -73,3 +73,4 @@ void save_stack_trace(struct stack_trace *trace)
 	prepare_frametrace(regs);
 	save_context_stack(trace, regs);
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 9629440..9861f17 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -44,3 +44,4 @@ void save_stack_trace(struct stack_trace *trace)
 		sp = newsp;
 	}
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c
index 85e46a5..57571f1 100644
--- a/arch/s390/kernel/stacktrace.c
+++ b/arch/s390/kernel/stacktrace.c
@@ -81,6 +81,7 @@ void save_stack_trace(struct stack_trace *trace)
 			   S390_lowcore.thread_info,
 			   S390_lowcore.thread_info + THREAD_SIZE, 1);
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
 
 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 {
@@ -93,3 +94,4 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 	if (trace->nr_entries < trace->max_entries)
 		trace->entries[trace->nr_entries++] = ULONG_MAX;
 }
+EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
diff --git a/arch/sh/kernel/stacktrace.c b/arch/sh/kernel/stacktrace.c
index d41e561..1b2ae35 100644
--- a/arch/sh/kernel/stacktrace.c
+++ b/arch/sh/kernel/stacktrace.c
@@ -34,3 +34,4 @@ void save_stack_trace(struct stack_trace *trace)
 		}
 	}
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/sparc64/kernel/stacktrace.c b/arch/sparc64/kernel/stacktrace.c
index c73ce3f..b3e3737 100644
--- a/arch/sparc64/kernel/stacktrace.c
+++ b/arch/sparc64/kernel/stacktrace.c
@@ -1,6 +1,7 @@
 #include <linux/sched.h>
 #include <linux/stacktrace.h>
 #include <linux/thread_info.h>
+#include <linux/module.h>
 #include <asm/ptrace.h>
 #include <asm/stacktrace.h>
 
@@ -47,3 +48,4 @@ void save_stack_trace(struct stack_trace *trace)
 			trace->entries[trace->nr_entries++] = pc;
 	} while (trace->nr_entries < trace->max_entries);
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index c28c342..a03e7f6 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -74,6 +74,7 @@ void save_stack_trace(struct stack_trace *trace)
 	if (trace->nr_entries < trace->max_entries)
 		trace->entries[trace->nr_entries++] = ULONG_MAX;
 }
+EXPORT_SYMBOL_GPL(save_stack_trace);
 
 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 {
@@ -81,3 +82,4 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 	if (trace->nr_entries < trace->max_entries)
 		trace->entries[trace->nr_entries++] = ULONG_MAX;
 }
+EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
diff --git a/kernel/backtracetest.c b/kernel/backtracetest.c
index d1a7605..a5e026b 100644
--- a/kernel/backtracetest.c
+++ b/kernel/backtracetest.c
@@ -10,30 +10,73 @@
  * of the License.
  */
 
+#include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/sched.h>
-#include <linux/delay.h>
+#include <linux/stacktrace.h>
+
+static void backtrace_test_normal(void)
+{
+	printk("Testing a backtrace from process context.\n");
+	printk("The following trace is a kernel self test and not a bug!\n");
 
-static struct timer_list backtrace_timer;
+	dump_stack();
+}
 
-static void backtrace_test_timer(unsigned long data)
+static DECLARE_COMPLETION(backtrace_work);
+
+static void backtrace_test_irq_callback(unsigned long data)
+{
+	dump_stack();
+	complete(&backtrace_work);
+}
+
+static DECLARE_TASKLET(backtrace_tasklet, &backtrace_test_irq_callback, 0);
+
+static void backtrace_test_irq(void)
 {
 	printk("Testing a backtrace from irq context.\n");
 	printk("The following trace is a kernel self test and not a bug!\n");
-	dump_stack();
+
+	init_completion(&backtrace_work);
+	tasklet_schedule(&backtrace_tasklet);
+	wait_for_completion(&backtrace_work);
+}
+
+#ifdef CONFIG_STACKTRACE
+static void backtrace_test_saved(void)
+{
+	struct stack_trace trace;
+	unsigned long entries[8];
+
+	printk("Testing a saved backtrace.\n");
+	printk("The following trace is a kernel self test and not a bug!\n");
+
+	trace.nr_entries = 0;
+	trace.max_entries = ARRAY_SIZE(entries);
+	trace.entries = entries;
+	trace.skip = 0;
+
+	save_stack_trace(&trace);
+	print_stack_trace(&trace, 0);
+}
+#else
+static void backtrace_test_saved(void)
+{
+	printk("Saved backtrace test skipped.\n");
 }
+#endif
+
 static int backtrace_regression_test(void)
 {
 	printk("====[ backtrace testing ]===========\n");
-	printk("Testing a backtrace from process context.\n");
-	printk("The following trace is a kernel self test and not a bug!\n");
-	dump_stack();
 
-	init_timer(&backtrace_timer);
-	backtrace_timer.function = backtrace_test_timer;
-	mod_timer(&backtrace_timer, jiffies + 10);
+	backtrace_test_normal();
+	backtrace_test_irq();
+	backtrace_test_saved();
 
-	msleep(10);
 	printk("====[ end of backtrace testing ]====\n");
 	return 0;
 }
diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index b71816e..94b527e 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -6,19 +6,21 @@
  *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
  */
 #include <linux/sched.h>
+#include <linux/module.h>
 #include <linux/kallsyms.h>
 #include <linux/stacktrace.h>
 
 void print_stack_trace(struct stack_trace *trace, int spaces)
 {
-	int i, j;
+	int i;
 
-	for (i = 0; i < trace->nr_entries; i++) {
-		unsigned long ip = trace->entries[i];
+	if (WARN_ON(!trace->entries))
+		return;
 
-		for (j = 0; j < spaces + 1; j++)
-			printk(" ");
-		print_ip_sym(ip);
+	for (i = 0; i < trace->nr_entries; i++) {
+		printk("%*c", 1 + spaces, ' ');
+		print_ip_sym(trace->entries[i]);
 	}
 }
+EXPORT_SYMBOL_GPL(print_stack_trace);
 
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index d2099f4..6263e2d 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -419,7 +419,6 @@ config DEBUG_LOCKING_API_SELFTESTS
 
 config STACKTRACE
 	bool
-	depends on DEBUG_KERNEL
 	depends on STACKTRACE_SUPPORT
 
 config DEBUG_KOBJECT
@@ -563,6 +562,9 @@ config BACKTRACE_SELF_TEST
 	  for distributions or general kernels, but only for kernel
 	  developers working on architecture code.
 
+	  Note that if you want to also test saved backtraces, you will
+	  have to enable STACKTRACE as well.
+
 	  Say N if you are unsure.
 
 config LKDTM

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

* Re: [git pull] core/stacktrace changes for v2.6.27
  2008-07-14 14:44 [git pull] core/stacktrace changes for v2.6.27 Ingo Molnar
@ 2008-07-14 15:35 ` Stephen Rothwell
  2008-07-14 15:56   ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Rothwell @ 2008-07-14 15:35 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linus Torvalds, linux-kernel, Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]

Hi Ingo,

On Mon, 14 Jul 2008 16:44:20 +0200 Ingo Molnar <mingo@elte.hu> wrote:
>
> Please pull the latest core/stacktrace git tree from:
> 
>    git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git core/stacktrace

This presumably needs the patch I posted today against linux-next that
fixes the powerpc allmodconfig build.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [git pull] core/stacktrace changes for v2.6.27
  2008-07-14 15:35 ` Stephen Rothwell
@ 2008-07-14 15:56   ` Ingo Molnar
  2008-07-14 21:32     ` Heiko Carstens
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2008-07-14 15:56 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Linus Torvalds, linux-kernel, Andrew Morton


* Stephen Rothwell <sfr@canb.auug.org.au> wrote:

> Hi Ingo,
> 
> On Mon, 14 Jul 2008 16:44:20 +0200 Ingo Molnar <mingo@elte.hu> wrote:
> >
> > Please pull the latest core/stacktrace git tree from:
> > 
> >    git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git core/stacktrace
> 
> This presumably needs the patch I posted today against linux-next that 
> fixes the powerpc allmodconfig build.

hm - but you sent that against the generic-ipi tree :-)

but i agree - the patch is below, Linus please apply.

	Ingo

---------------->
commit 7798ed0f57b4d137e660fbf5be1e1528e40f89ac
Author: Stephen Rothwell <sfr@canb.auug.org.au>
Date:   Mon Jul 14 19:55:03 2008 +1000

    generic-ipi: powerpc/generic-ipi tree build failure
    
    Today's linux-next build (powerpc allmodconfig) failed like this:
    
    ERROR: ".save_stack_trace" [tests/backtracetest.ko] undefined!
    
    But save_stack_trace is exported in arch/powerpc/kernel/stacktrace.c
    
    I couldn't figure it out until I noticed these earlier warnings:
    
    arch/powerpc/kernel/stacktrace.c:47: warning: data definition has no type or storage class
    arch/powerpc/kernel/stacktrace.c:47: warning: type defaults to 'int' in declaration of 'EXPORT_SYMBOL_GPL'
    arch/powerpc/kernel/stacktrace.c:47: warning: parameter names (without types) in function declaration
    
    I applied the patch below.
    
    Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: <linuxppc-dev@ozlabs.org>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/powerpc/kernel/stacktrace.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 9861f17..3cf0d94 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -12,6 +12,7 @@
 
 #include <linux/sched.h>
 #include <linux/stacktrace.h>
+#include <linux/module.h>
 #include <asm/ptrace.h>
 
 /*

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

* Re: [git pull] core/stacktrace changes for v2.6.27
  2008-07-14 15:56   ` Ingo Molnar
@ 2008-07-14 21:32     ` Heiko Carstens
  2008-07-18 12:42       ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Heiko Carstens @ 2008-07-14 21:32 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Stephen Rothwell, Linus Torvalds, linux-kernel, Andrew Morton

On Mon, Jul 14, 2008 at 05:56:17PM +0200, Ingo Molnar wrote:
> 
> * Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> 
> > Hi Ingo,
> > 
> > On Mon, 14 Jul 2008 16:44:20 +0200 Ingo Molnar <mingo@elte.hu> wrote:
> > >
> > > Please pull the latest core/stacktrace git tree from:
> > > 
> > >    git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git core/stacktrace
> > 
> > This presumably needs the patch I posted today against linux-next that 
> > fixes the powerpc allmodconfig build.
> 
> hm - but you sent that against the generic-ipi tree :-)
> 
> but i agree - the patch is below, Linus please apply.
> 
> 	Ingo
> 
> ---------------->
> commit 7798ed0f57b4d137e660fbf5be1e1528e40f89ac
> Author: Stephen Rothwell <sfr@canb.auug.org.au>
> Date:   Mon Jul 14 19:55:03 2008 +1000
> 
>     generic-ipi: powerpc/generic-ipi tree build failure
>     
>     Today's linux-next build (powerpc allmodconfig) failed like this:
>     
>     ERROR: ".save_stack_trace" [tests/backtracetest.ko] undefined!
>     
>     But save_stack_trace is exported in arch/powerpc/kernel/stacktrace.c
>     
>     I couldn't figure it out until I noticed these earlier warnings:
>     
>     arch/powerpc/kernel/stacktrace.c:47: warning: data definition has no type or storage class
>     arch/powerpc/kernel/stacktrace.c:47: warning: type defaults to 'int' in declaration of 'EXPORT_SYMBOL_GPL'
>     arch/powerpc/kernel/stacktrace.c:47: warning: parameter names (without types) in function declaration
>     
>     I applied the patch below.
>     
>     Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
>     Cc: Paul Mackerras <paulus@samba.org>
>     Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>     Cc: <linuxppc-dev@ozlabs.org>
>     Signed-off-by: Ingo Molnar <mingo@elte.hu>
> ---
>  arch/powerpc/kernel/stacktrace.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
> index 9861f17..3cf0d94 100644
> --- a/arch/powerpc/kernel/stacktrace.c
> +++ b/arch/powerpc/kernel/stacktrace.c
> @@ -12,6 +12,7 @@
> 
>  #include <linux/sched.h>
>  #include <linux/stacktrace.h>
> +#include <linux/module.h>
>  #include <asm/ptrace.h>

s390 and probably other architectures will suffer from the same compile bug.
I sent you the patch below against linux-next to fix this problem a couple of
days ago:
http://marc.info/?l=linux-next&m=121577286607960&w=2

Subject: [PATCH] Add module.h include to stacktrace.c.

From: Heiko Carstens <heiko.carstens@de.ibm.com>

Fixes this:

  CC      arch/s390/kernel/stacktrace.o
arch/s390/kernel/stacktrace.c:84: warning: data definition has no type or storage class
arch/s390/kernel/stacktrace.c:84: warning: type defaults to 'int' in declaration of 'EXPORT_SYMBOL_GPL'
arch/s390/kernel/stacktrace.c:84: warning: parameter names (without types) in function declaration
arch/s390/kernel/stacktrace.c:97: warning: data definition has no type or storage class
arch/s390/kernel/stacktrace.c:97: warning: type defaults to 'int' in declaration of 'EXPORT_SYMBOL_GPL'
arch/s390/kernel/stacktrace.c:97: warning: parameter names (without types) in function declaration

caused by "stacktrace: export save_stack_trace[_tsk]"

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 arch/avr32/kernel/stacktrace.c   |    1 +
 arch/mips/kernel/stacktrace.c    |    1 +
 arch/powerpc/kernel/stacktrace.c |    1 +
 arch/s390/kernel/stacktrace.c    |    1 +
 arch/sh/kernel/stacktrace.c      |    1 +
 5 files changed, 5 insertions(+)

Index: linux-next/arch/s390/kernel/stacktrace.c
===================================================================
--- linux-next.orig/arch/s390/kernel/stacktrace.c
+++ linux-next/arch/s390/kernel/stacktrace.c
@@ -10,6 +10,7 @@
 #include <linux/sched.h>
 #include <linux/stacktrace.h>
 #include <linux/kallsyms.h>
+#include <linux/module.h>
 
 static unsigned long save_context_stack(struct stack_trace *trace,
 					unsigned long sp,
Index: linux-next/arch/avr32/kernel/stacktrace.c
===================================================================
--- linux-next.orig/arch/avr32/kernel/stacktrace.c
+++ linux-next/arch/avr32/kernel/stacktrace.c
@@ -10,6 +10,7 @@
 #include <linux/sched.h>
 #include <linux/stacktrace.h>
 #include <linux/thread_info.h>
+#include <linux/module.h>
 
 register unsigned long current_frame_pointer asm("r7");
 
Index: linux-next/arch/mips/kernel/stacktrace.c
===================================================================
--- linux-next.orig/arch/mips/kernel/stacktrace.c
+++ linux-next/arch/mips/kernel/stacktrace.c
@@ -7,6 +7,7 @@
  */
 #include <linux/sched.h>
 #include <linux/stacktrace.h>
+#include <linux/module.h
 #include <asm/stacktrace.h>
 
 /*
Index: linux-next/arch/powerpc/kernel/stacktrace.c
===================================================================
--- linux-next.orig/arch/powerpc/kernel/stacktrace.c
+++ linux-next/arch/powerpc/kernel/stacktrace.c
@@ -12,6 +12,7 @@
 
 #include <linux/sched.h>
 #include <linux/stacktrace.h>
+#include <linux/module.h>
 #include <asm/ptrace.h>
 
 /*
Index: linux-next/arch/sh/kernel/stacktrace.c
===================================================================
--- linux-next.orig/arch/sh/kernel/stacktrace.c
+++ linux-next/arch/sh/kernel/stacktrace.c
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/stacktrace.h>
 #include <linux/thread_info.h>
+#include <linux/module.h>
 #include <asm/ptrace.h>
 
 /*

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

* Re: [git pull] core/stacktrace changes for v2.6.27
  2008-07-14 21:32     ` Heiko Carstens
@ 2008-07-18 12:42       ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2008-07-18 12:42 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Stephen Rothwell, Linus Torvalds, linux-kernel, Andrew Morton


* Heiko Carstens <heiko.carstens@de.ibm.com> wrote:

> 
> s390 and probably other architectures will suffer from the same 
> compile bug. I sent you the patch below against linux-next to fix this 
> problem a couple of days ago: 
> http://marc.info/?l=linux-next&m=121577286607960&w=2
> 
> Subject: [PATCH] Add module.h include to stacktrace.c.

applied to tip/core/urgent, thanks Heiko.

	Ingo

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

end of thread, other threads:[~2008-07-18 12:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-14 14:44 [git pull] core/stacktrace changes for v2.6.27 Ingo Molnar
2008-07-14 15:35 ` Stephen Rothwell
2008-07-14 15:56   ` Ingo Molnar
2008-07-14 21:32     ` Heiko Carstens
2008-07-18 12:42       ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox