linux/arch/sh/kernel
Tejun Heo 196779b9b4 dump_stack: consolidate dump_stack() implementations and unify their behaviors
Both dump_stack() and show_stack() are currently implemented by each
architecture.  show_stack(NULL, NULL) dumps the backtrace for the
current task as does dump_stack().  On some archs, dump_stack() prints
extra information - pid, utsname and so on - in addition to the
backtrace while the two are identical on other archs.

The usages in arch-independent code of the two functions indicate
show_stack(NULL, NULL) should print out bare backtrace while
dump_stack() is used for debugging purposes when something went wrong,
so it does make sense to print additional information on the task which
triggered dump_stack().

There's no reason to require archs to implement two separate but mostly
identical functions.  It leads to unnecessary subtle information.

This patch expands the dummy fallback dump_stack() implementation in
lib/dump_stack.c such that it prints out debug information (taken from
x86) and invokes show_stack(NULL, NULL) and drops arch-specific
dump_stack() implementations in all archs except blackfin.  Blackfin's
dump_stack() does something wonky that I don't understand.

Debug information can be printed separately by calling
dump_stack_print_info() so that arch-specific dump_stack()
implementation can still emit the same debug information.  This is used
in blackfin.

This patch brings the following behavior changes.

* On some archs, an extra level in backtrace for show_stack() could be
  printed.  This is because the top frame was determined in
  dump_stack() on those archs while generic dump_stack() can't do that
  reliably.  It can be compensated by inlining dump_stack() but not
  sure whether that'd be necessary.

* Most archs didn't use to print debug info on dump_stack().  They do
  now.

An example WARN dump follows.

 WARNING: at kernel/workqueue.c:4841 init_workqueues+0x35/0x505()
 Hardware name: empty
 Modules linked in:
 CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.9.0-rc1-work+ #9
  0000000000000009 ffff88007c861e08 ffffffff81c614dc ffff88007c861e48
  ffffffff8108f50f ffffffff82228240 0000000000000040 ffffffff8234a03c
  0000000000000000 0000000000000000 0000000000000000 ffff88007c861e58
 Call Trace:
  [<ffffffff81c614dc>] dump_stack+0x19/0x1b
  [<ffffffff8108f50f>] warn_slowpath_common+0x7f/0xc0
  [<ffffffff8108f56a>] warn_slowpath_null+0x1a/0x20
  [<ffffffff8234a071>] init_workqueues+0x35/0x505
  ...

v2: CPU number added to the generic debug info as requested by s390
    folks and dropped the s390 specific dump_stack().  This loses %ksp
    from the debug message which the maintainers think isn't important
    enough to keep the s390-specific dump_stack() implementation.

    dump_stack_print_info() is moved to kernel/printk.c from
    lib/dump_stack.c.  Because linkage is per objecct file,
    dump_stack_print_info() living in the same lib file as generic
    dump_stack() means that archs which implement custom dump_stack()
    - at this point, only blackfin - can't use dump_stack_print_info()
    as that will bring in the generic version of dump_stack() too.  v1
    The v1 patch broke build on blackfin due to this issue.  The build
    breakage was reported by Fengguang Wu.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>	[s390 bits]
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Richard Kuo <rkuo@codeaurora.org>		[hexagon bits]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-04-30 17:04:02 -07:00
..
cpu sh: Remove unused sh_pfc_register_info() function 2013-01-25 09:24:30 +09:00
vsyscall sh: vsyscall: Fix up .eh_frame generation. 2012-03-30 19:42:26 +09:00
.gitignore
asm-offsets.c
cpufreq.c sh: cpufreq: Wire up scaling_available_freqs support. 2012-01-27 20:45:24 +09:00
crash_dump.c crash_dump: export is_kdump_kernel to modules, consolidate elfcorehdr_addr, setup_elfcorehdr and saved_max_pfn 2011-03-23 19:47:19 -07:00
debugtraps.S sh: kgdb: Rework breakpoint handling on top of notifier chain. 2009-12-22 12:44:14 +09:00
disassemble.c
dma-nommu.c SH: adapt for dma_map_ops changes 2012-03-28 16:36:37 +02:00
dumpstack.c dump_stack: consolidate dump_stack() implementations and unify their behaviors 2013-04-30 17:04:02 -07:00
dwarf.c sh: handle early calls to return_address() when using dwarf unwinder. 2010-05-25 16:16:40 +09:00
entry-common.S sh: switch to generic kernel_thread()/kernel_execve() 2012-10-22 22:31:01 -04:00
ftrace.c tracing: Unify arch_syscall_addr() implementations 2010-02-17 13:07:21 +01:00
head_32.S sh: boot kernel with SR.BL set 2010-09-30 09:43:32 +09:00
head_64.S sh64: Fix up early serial fixmap. 2010-01-12 15:22:26 +09:00
hw_breakpoint.c Disintegrate asm/system.h for SH 2012-03-28 18:30:03 +01:00
idle.c sh: Use generic idle loop 2013-04-08 17:39:28 +02:00
io.c sh: support for platforms without PIO. 2010-06-02 16:31:42 +09:00
io_trapped.c Disintegrate asm/system.h for SH 2012-03-28 18:30:03 +01:00
iomap.c sh: machvec IO death. 2010-11-01 09:49:04 -04:00
ioport.c sections: fix section conflicts in arch/sh 2012-10-06 03:04:40 +09:00
irq.c sh: Kill off now unused arch_probe_nr_irqs(). 2012-05-24 13:59:35 +09:00
irq_32.c Fix IRQ flag handling naming 2010-10-07 14:08:55 +01:00
irq_64.c sh64: update for IRQ flag handling naming changes. 2010-10-27 15:34:51 +09:00
kdebugfs.c sh: provide generic arch_debugfs_dir. 2010-09-24 04:04:26 +09:00
kgdb.c sh: kgdb: Fix up NULL pointer deref by kgdb_nmicallback. 2012-04-10 14:22:39 +09:00
kprobes.c hlist: drop the node parameter from iterators 2013-02-27 19:10:24 -08:00
localtimer.c sh: CPU hotplug support. 2010-04-26 19:08:55 +09:00
machine_kexec.c memblock: s/memblock_analyze()/memblock_allow_resize()/ and update users 2011-12-08 10:22:08 -08:00
machvec.c sh: Kill off machvec IRQ hinting. 2012-05-21 17:54:01 +09:00
Makefile sh: switch to generic kernel_thread()/kernel_execve() 2012-10-22 22:31:01 -04:00
module.c modules: make arch's use default loader hooks 2011-07-24 22:06:04 +09:30
nmi_debug.c
perf_callchain.c sh: remove warning and warning_symbol from struct stacktrace_ops 2011-05-23 14:42:15 +09:00
perf_event.c perf: Disable PERF_SAMPLE_BRANCH_* when not supported 2012-03-05 14:55:42 +01:00
process.c sh: arch/sh/kernel/process.c needs asm/fpu.h for unlazy_fpu(). 2012-05-24 13:03:20 +09:00
process_32.c flagday: don't pass regs to copy_thread() 2012-11-28 23:43:42 -05:00
process_64.c flagday: don't pass regs to copy_thread() 2012-11-28 23:43:42 -05:00
ptrace.c sh: Add kprobe-based event tracer. 2010-06-14 15:16:53 +09:00
ptrace_32.c seccomp: ignore secure_computing return values 2012-04-18 12:24:50 +10:00
ptrace_64.c seccomp: ignore secure_computing return values 2012-04-18 12:24:50 +10:00
reboot.c Disintegrate asm/system.h for SH 2012-03-28 18:30:03 +01:00
relocate_kernel.S
return_address.c sh: handle early calls to return_address() when using dwarf unwinder. 2010-05-25 16:16:40 +09:00
setup.c mtd/uclinux: Use generic __bss_stop instead of _ebss 2012-06-27 09:59:43 +02:00
sh_bios.c early_printk: consolidate random copies of identical code 2013-04-29 18:28:13 -07:00
sh_ksyms_32.c mtd/uclinux: Use generic __bss_stop instead of _ebss 2012-06-27 09:59:43 +02:00
sh_ksyms_64.c sh: use the new generic strnlen_user() function 2012-06-13 10:28:37 +09:00
signal_32.c sh: switch to generic old sigaction() 2013-02-03 18:16:16 -05:00
signal_64.c sh: switch to generic old sigaction() 2013-02-03 18:16:16 -05:00
smp.c sh: Use generic idle loop 2013-04-08 17:39:28 +02:00
stacktrace.c sh: remove warning and warning_symbol from struct stacktrace_ops 2011-05-23 14:42:15 +09:00
swsusp.c
sys_sh.c sh: avoid to flush all cache in sys_cacheflush 2010-11-17 17:55:30 +09:00
sys_sh32.c sh: switch to generic kernel_thread()/kernel_execve() 2012-10-22 22:31:01 -04:00
syscalls_32.S sh: wire up finit_module syscall. 2013-01-14 17:59:03 +09:00
syscalls_64.S sh: wire up finit_module syscall. 2013-01-14 17:59:03 +09:00
time.c sh: hwblk: Kill off remaining bits of hwblk API. 2011-11-18 16:26:00 +09:00
topology.c arch/sh: remove references to cpu_*_map. 2012-02-24 13:21:45 +09:00
traps.c taint: add explicit flag to show whether lock dep is still OK. 2013-01-21 17:17:57 +10:30
traps_32.c sh: Consolidate die definitions for trap handlers. 2012-06-14 14:18:51 +09:00
traps_64.c sh64: Attempt to make reserved insn trap handler resemble C. 2012-06-14 14:46:36 +09:00
unwinder.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
vmlinux.lds.S mtd/uclinux: Use generic __bss_stop instead of _ebss 2012-06-27 09:59:43 +02:00