Skip to content

Commit ebf0a36

Browse files
0x7f454c46torvalds
authored andcommitted
sh: add loglvl to dump_mem()
Currently, the log-level of show_stack() depends on a platform realization. It creates situations where the headers are printed with lower log level or higher than the stacktrace (depending on a platform or user). Furthermore, it forces the logic decision from user to an architecture side. In result, some users as sysrq/kdb/etc are doing tricks with temporary rising console_loglevel while printing their messages. And in result it not only may print unwanted messages from other CPUs, but also omit printing at all in the unlucky case where the printk() was deferred. Introducing log-level parameter and KERN_UNSUPPRESSED [1] seems an easier approach than introducing more printk buffers. Also, it will consolidate printings with headers. Add log level argument to dump_mem() as a preparation to introduce show_stack_loglvl(). [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov <dima@arista.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Rich Felker <dalias@libc.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Link: http://lkml.kernel.org/r/20200418201944.482088-30-dima@arista.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 8539c12 commit ebf0a36

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

‎arch/sh/include/asm/kdebug.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum die_val {
1313

1414
/* arch/sh/kernel/dumpstack.c */
1515
extern void printk_address(unsigned long address, int reliable);
16-
extern void dump_mem(const char *str, unsigned long bottom, unsigned long top);
16+
extern void dump_mem(const char *str, const char *loglvl,
17+
unsigned long bottom, unsigned long top);
1718

1819
#endif /* __ASM_SH_KDEBUG_H */

‎arch/sh/kernel/dumpstack.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,31 @@
1616
#include <asm/unwinder.h>
1717
#include <asm/stacktrace.h>
1818

19-
void dump_mem(const char *str, unsigned long bottom, unsigned long top)
19+
void dump_mem(const char *str, const char *loglvl,
20+
unsigned long bottom, unsigned long top)
2021
{
2122
unsigned long p;
2223
int i;
2324

24-
printk("%s(0x%08lx to 0x%08lx)\n", str, bottom, top);
25+
printk("%s%s(0x%08lx to 0x%08lx)\n", loglvl, str, bottom, top);
2526

2627
for (p = bottom & ~31; p < top; ) {
27-
printk("%04lx: ", p & 0xffff);
28+
printk("%s%04lx: ", loglvl, p & 0xffff);
2829

2930
for (i = 0; i < 8; i++, p += 4) {
3031
unsigned int val;
3132

3233
if (p < bottom || p >= top)
33-
printk(" ");
34+
printk("%s ", loglvl);
3435
else {
3536
if (__get_user(val, (unsigned int __user *)p)) {
36-
printk("\n");
37+
printk("%s\n", loglvl);
3738
return;
3839
}
39-
printk("%08x ", val);
40+
printk("%s%08x ", loglvl, val);
4041
}
4142
}
42-
printk("\n");
43+
printk("%s\n", loglvl);
4344
}
4445
}
4546

@@ -156,7 +157,7 @@ void show_stack(struct task_struct *tsk, unsigned long *sp)
156157
sp = (unsigned long *)tsk->thread.sp;
157158

158159
stack = (unsigned long)sp;
159-
dump_mem("Stack: ", stack, THREAD_SIZE +
160+
dump_mem("Stack: ", KERN_DEFAULT, stack, THREAD_SIZE +
160161
(unsigned long)task_stack_page(tsk));
161162
show_trace(tsk, sp, NULL);
162163
}

‎arch/sh/kernel/traps.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ void die(const char *str, struct pt_regs *regs, long err)
3838
task_pid_nr(current), task_stack_page(current) + 1);
3939

4040
if (!user_mode(regs) || in_interrupt())
41-
dump_mem("Stack: ", regs->regs[15], THREAD_SIZE +
42-
(unsigned long)task_stack_page(current));
41+
dump_mem("Stack: ", KERN_DEFAULT, regs->regs[15],
42+
THREAD_SIZE + (unsigned long)task_stack_page(current));
4343

4444
notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV);
4545

0 commit comments

Comments
 (0)