提交 5c088469 编写于 作者: D Dmitry Safonov 提交者: Linus Torvalds

unicore32: add show_stack_loglvl()

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.

Introduce show_stack_loglvl(), that eventually will substitute
show_stack().

As a nice side-effect - print backtrace in __die() with the same log level
as the rest of function.

[1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#uSigned-off-by: NDmitry Safonov <dima@arista.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Link: http://lkml.kernel.org/r/20200418201944.482088-40-dima@arista.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 de985dd5
......@@ -135,12 +135,13 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
set_fs(fs);
}
static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
const char *loglvl)
{
unsigned int fp;
int ok = 1;
printk(KERN_DEFAULT "Backtrace: ");
printk("%sBacktrace: ", loglvl);
if (!tsk)
tsk = current;
......@@ -153,25 +154,31 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
asm("mov %0, fp" : "=r" (fp) : : "cc");
if (!fp) {
printk("no frame pointer");
printk("%sno frame pointer", loglvl);
ok = 0;
} else if (verify_stack(fp)) {
printk("invalid frame pointer 0x%08x", fp);
printk("%sinvalid frame pointer 0x%08x", loglvl, fp);
ok = 0;
} else if (fp < (unsigned long)end_of_stack(tsk))
printk("frame pointer underflow");
printk("\n");
printk("%sframe pointer underflow", loglvl);
printk("%s\n", loglvl);
if (ok)
c_backtrace(fp, KERN_DEFAULT);
c_backtrace(fp, loglvl);
}
void show_stack(struct task_struct *tsk, unsigned long *sp)
void show_stack_loglvl(struct task_struct *tsk, unsigned long *sp,
const char *loglvl)
{
dump_backtrace(NULL, tsk);
dump_backtrace(NULL, tsk, loglvl);
barrier();
}
void show_stack(struct task_struct *tsk, unsigned long *sp)
{
show_stack_loglvl(tsk, sp, KERN_DEFAULT)
}
static int __die(const char *str, int err, struct thread_info *thread,
struct pt_regs *regs)
{
......@@ -196,7 +203,7 @@ static int __die(const char *str, int err, struct thread_info *thread,
if (!user_mode(regs) || in_interrupt()) {
dump_mem(KERN_EMERG, "Stack: ", regs->UCreg_sp,
THREAD_SIZE + (unsigned long)task_stack_page(tsk));
dump_backtrace(regs, tsk);
dump_backtrace(regs, tsk, KERN_EMERG);
dump_instr(KERN_EMERG, regs);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册