Merge branch 'core/stacktrace' of git://git.kernel.org/pub/scm/linux/kernel/git/tip...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 15 Jul 2008 17:31:35 +0000 (10:31 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 15 Jul 2008 17:31:35 +0000 (10:31 -0700)
* 'core/stacktrace' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  generic-ipi: powerpc/generic-ipi tree build failure
  stacktrace: fix build failure on sparc64
  stacktrace: export save_stack_trace[_tsk]
  stacktrace: fix modular build, export print_stack_trace and save_stack_trace
  backtrace: replace timer with tasklet + completions
  stacktrace: add saved stack traces to backtrace self-test
  stacktrace: print_stack_trace() cleanup
  debugging: make stacktrace independent from DEBUG_KERNEL
  stacktrace: don't crash on invalid stack trace structs

1  2 
arch/arm/kernel/stacktrace.c
lib/Kconfig.debug

index 90e0c35ae60d24934b15fbd377c95ef3314c2c88,6b3ffde5deaa8e1edb5a772187a0a2618919aa8c..fc650f64df43ce00a83ad9f22e33e26b266d76ce
@@@ -36,7 -36,6 +36,7 @@@ EXPORT_SYMBOL(walk_stackframe)
  #ifdef CONFIG_STACKTRACE
  struct stack_trace_data {
        struct stack_trace *trace;
 +      unsigned int no_sched_functions;
        unsigned int skip;
  };
  
@@@ -44,52 -43,28 +44,53 @@@ static int save_trace(struct stackfram
  {
        struct stack_trace_data *data = d;
        struct stack_trace *trace = data->trace;
 +      unsigned long addr = frame->lr;
  
 +      if (data->no_sched_functions && in_sched_functions(addr))
 +              return 0;
        if (data->skip) {
                data->skip--;
                return 0;
        }
  
 -      trace->entries[trace->nr_entries++] = frame->lr;
 +      trace->entries[trace->nr_entries++] = addr;
  
        return trace->nr_entries >= trace->max_entries;
  }
  
 -void save_stack_trace(struct stack_trace *trace)
 +void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
  {
        struct stack_trace_data data;
        unsigned long fp, base;
  
        data.trace = trace;
        data.skip = trace->skip;
 -      base = (unsigned long)task_stack_page(current);
 -      asm("mov %0, fp" : "=r" (fp));
 +      base = (unsigned long)task_stack_page(tsk);
 +
 +      if (tsk != current) {
 +#ifdef CONFIG_SMP
 +              /*
 +               * What guarantees do we have here that 'tsk'
 +               * is not running on another CPU?
 +               */
 +              BUG();
 +#else
 +              data.no_sched_functions = 1;
 +              fp = thread_saved_fp(tsk);
 +#endif
 +      } else {
 +              data.no_sched_functions = 0;
 +              asm("mov %0, fp" : "=r" (fp));
 +      }
  
        walk_stackframe(fp, base, base + THREAD_SIZE, save_trace, &data);
 +      if (trace->nr_entries < trace->max_entries)
 +              trace->entries[trace->nr_entries++] = ULONG_MAX;
 +}
 +
 +void save_stack_trace(struct stack_trace *trace)
 +{
 +      save_stack_trace_tsk(current, trace);
  }
+ EXPORT_SYMBOL_GPL(save_stack_trace);
  #endif
diff --combined lib/Kconfig.debug
index d8b6279a9b4232cf7ca92305199b4a915cd0f591,6263e2d851f1f0d9b4201d15a678f0871c889dd1..c459e8547bd8cd11ede47e50f44e055fa1d06a6b
@@@ -419,7 -419,6 +419,6 @@@ config DEBUG_LOCKING_API_SELFTEST
  
  config STACKTRACE
        bool
-       depends on DEBUG_KERNEL
        depends on STACKTRACE_SUPPORT
  
  config DEBUG_KOBJECT
@@@ -563,6 -562,9 +562,9 @@@ config BACKTRACE_SELF_TES
          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
@@@ -634,8 -636,6 +636,8 @@@ config LATENCYTO
          Enable this option if you want to use the LatencyTOP tool
          to find out which userspace is blocking on what kernel operations.
  
 +source kernel/trace/Kconfig
 +
  config PROVIDE_OHCI1394_DMA_INIT
        bool "Remote debugging over FireWire early on boot"
        depends on PCI && X86