Skip to content

Commit 196779b

Browse files
htejuntorvalds
authored andcommitted
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+ hardkernel#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 <[email protected]> Acked-by: David S. Miller <[email protected]> Acked-by: Vineet Gupta <[email protected]> Acked-by: Jesper Nilsson <[email protected]> Acked-by: Vineet Gupta <[email protected]> Acked-by: Martin Schwidefsky <[email protected]> [s390 bits] Cc: Heiko Carstens <[email protected]> Cc: Mike Frysinger <[email protected]> Cc: Fengguang Wu <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Sam Ravnborg <[email protected]> Acked-by: Richard Kuo <[email protected]> [hexagon bits] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 89e3f23 commit 196779b

File tree

33 files changed

+32
-262
lines changed

33 files changed

+32
-262
lines changed

arch/alpha/kernel/traps.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,6 @@ void show_stack(struct task_struct *task, unsigned long *sp)
169169
dik_show_trace(sp);
170170
}
171171

172-
void dump_stack(void)
173-
{
174-
show_stack(NULL, NULL);
175-
}
176-
177-
EXPORT_SYMBOL(dump_stack);
178-
179172
void
180173
die_if_kernel(char * str, struct pt_regs *regs, long err, unsigned long *r9_15)
181174
{

arch/arc/kernel/stacktrace.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,6 @@ void show_stack(struct task_struct *tsk, unsigned long *sp)
220220
show_stacktrace(tsk, NULL);
221221
}
222222

223-
/* Expected by Rest of kernel code */
224-
void dump_stack(void)
225-
{
226-
show_stacktrace(NULL, NULL);
227-
}
228-
EXPORT_SYMBOL(dump_stack);
229-
230223
/* Another API expected by schedular, shows up in "ps" as Wait Channel
231224
* Ofcourse just returning schedule( ) would be pointless so unwind until
232225
* the function is not in schedular code

arch/arm/kernel/traps.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,6 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
204204
}
205205
#endif
206206

207-
void dump_stack(void)
208-
{
209-
dump_backtrace(NULL, NULL);
210-
}
211-
212-
EXPORT_SYMBOL(dump_stack);
213-
214207
void show_stack(struct task_struct *tsk, unsigned long *sp)
215208
{
216209
dump_backtrace(NULL, tsk);

arch/arm64/kernel/traps.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,6 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
167167
}
168168
}
169169

170-
void dump_stack(void)
171-
{
172-
dump_backtrace(NULL, NULL);
173-
}
174-
175-
EXPORT_SYMBOL(dump_stack);
176-
177170
void show_stack(struct task_struct *tsk, unsigned long *sp)
178171
{
179172
dump_backtrace(NULL, tsk);

arch/avr32/kernel/process.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,6 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
204204
show_stack_log_lvl(tsk, (unsigned long)stack, NULL, "");
205205
}
206206

207-
void dump_stack(void)
208-
{
209-
unsigned long stack;
210-
211-
show_trace_log_lvl(current, &stack, NULL, "");
212-
}
213-
EXPORT_SYMBOL(dump_stack);
214-
215207
static const char *cpu_modes[] = {
216208
"Application", "Supervisor", "Interrupt level 0", "Interrupt level 1",
217209
"Interrupt level 2", "Interrupt level 3", "Exception", "NMI"

arch/blackfin/kernel/dumpstack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ void dump_stack(void)
168168
#endif
169169
trace_buffer_save(tflags);
170170
dump_bfin_trace_buffer();
171+
dump_stack_print_info(KERN_DEFAULT);
171172
show_stack(current, &stack);
172173
trace_buffer_restore(tflags);
173174
}

arch/c6x/kernel/traps.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,6 @@ void show_regs(struct pt_regs *regs)
6767
pr_err("A31: %08lx B31: %08lx\n", regs->a31, regs->b31);
6868
}
6969

70-
void dump_stack(void)
71-
{
72-
unsigned long stack;
73-
74-
show_stack(current, &stack);
75-
}
76-
EXPORT_SYMBOL(dump_stack);
77-
78-
7970
void die(char *str, struct pt_regs *fp, int nr)
8071
{
8172
console_verbose();

arch/cris/kernel/traps.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ show_stack(void)
146146
}
147147
#endif
148148

149-
void
150-
dump_stack(void)
151-
{
152-
show_stack(NULL, NULL);
153-
}
154-
EXPORT_SYMBOL(dump_stack);
155-
156149
void
157150
set_nmi_handler(void (*handler)(struct pt_regs *))
158151
{

arch/frv/kernel/traps.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -466,17 +466,6 @@ asmlinkage void compound_exception(unsigned long esfr1,
466466
BUG();
467467
} /* end compound_exception() */
468468

469-
/*****************************************************************************/
470-
/*
471-
* The architecture-independent backtrace generator
472-
*/
473-
void dump_stack(void)
474-
{
475-
show_stack(NULL, NULL);
476-
}
477-
478-
EXPORT_SYMBOL(dump_stack);
479-
480469
void show_stack(struct task_struct *task, unsigned long *sp)
481470
{
482471
}

arch/h8300/kernel/traps.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,3 @@ void show_trace_task(struct task_struct *tsk)
164164
{
165165
show_stack(tsk,(unsigned long *)tsk->thread.esp0);
166166
}
167-
168-
void dump_stack(void)
169-
{
170-
show_stack(NULL,NULL);
171-
}
172-
173-
EXPORT_SYMBOL(dump_stack);

0 commit comments

Comments
 (0)