Commit 8c49a909 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Linus Torvalds

alpha: 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().

[1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#uSigned-off-by: default avatarDmitry Safonov <dima@arista.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Richard Henderson <rth@twiddle.net>
Link: http://lkml.kernel.org/r/20200418201944.482088-3-dima@arista.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2062a4e8
......@@ -121,10 +121,10 @@ dik_show_code(unsigned int *pc)
}
static void
dik_show_trace(unsigned long *sp)
dik_show_trace(unsigned long *sp, const char *loglvl)
{
long i = 0;
printk("Trace:\n");
printk("%sTrace:\n", loglvl);
while (0x1ff8 & (unsigned long) sp) {
extern char _stext[], _etext[];
unsigned long tmp = *sp;
......@@ -133,24 +133,25 @@ dik_show_trace(unsigned long *sp)
continue;
if (tmp >= (unsigned long) &_etext)
continue;
printk("[<%lx>] %pSR\n", tmp, (void *)tmp);
printk("%s[<%lx>] %pSR\n", loglvl, tmp, (void *)tmp);
if (i > 40) {
printk(" ...");
printk("%s ...", loglvl);
break;
}
}
printk("\n");
printk("%s\n", loglvl);
}
static int kstack_depth_to_print = 24;
void show_stack(struct task_struct *task, unsigned long *sp)
void show_stack_loglvl(struct task_struct *task, unsigned long *sp,
const char *loglvl)
{
unsigned long *stack;
int i;
/*
* debugging aid: "show_stack(NULL);" prints the
* debugging aid: "show_stack(NULL, NULL, KERN_EMERG);" prints the
* back trace for this cpu.
*/
if(sp==NULL)
......@@ -163,14 +164,19 @@ void show_stack(struct task_struct *task, unsigned long *sp)
if ((i % 4) == 0) {
if (i)
pr_cont("\n");
printk(" ");
printk("%s ", loglvl);
} else {
pr_cont(" ");
}
pr_cont("%016lx", *stack++);
}
pr_cont("\n");
dik_show_trace(sp);
dik_show_trace(sp, loglvl);
}
void show_stack(struct task_struct *task, unsigned long *sp)
{
show_stack_loglvl(task, sp, KERN_DEFAULT);
}
void
......@@ -184,7 +190,7 @@ die_if_kernel(char * str, struct pt_regs *regs, long err, unsigned long *r9_15)
printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
dik_show_regs(regs, r9_15);
add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
dik_show_trace((unsigned long *)(regs+1));
dik_show_trace((unsigned long *)(regs+1), KERN_DEFAULT);
dik_show_code((unsigned int *)regs->pc);
if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
......@@ -625,7 +631,7 @@ do_entUna(void * va, unsigned long opcode, unsigned long reg,
printk("gp = %016lx sp = %p\n", regs->gp, regs+1);
dik_show_code((unsigned int *)pc);
dik_show_trace((unsigned long *)(regs+1));
dik_show_trace((unsigned long *)(regs+1), KERN_DEFAULT);
if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
printk("die_if_kernel recursion detected.\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment