Add log level to show_stack()
Subsystems (33)
cover Add log level to show_stack()
Add log level argument to show_stack().
Done in three stages:
1. Introducing show_stack_loglvl() for every architecture
2. Migrating old users with an explicit log level
3. Renaming show_stack_loglvl() into show_stack()
Justification:
o It's a design mistake to move a business-logic decision into platform realization detail.
o I have currently two patches sets that would benefit from this work:
Removing console_loglevel jumps in sysrq driver [1]
Hung task warning before panic [2] - suggested by Tetsuo (but he probably didn't realise what it would involve).
o While doing (1), (2) the backtraces were adjusted to headers and other messages for each situation - so there won't be a situation when the backtrace is printed, but the headers are missing because they have lesser log level (or the reverse).
o As the result in (2) plays with console_loglevel for kdb are removed.
The least important for upstream, but maybe still worth to note that every company I've worked in so far had an off-list patch to print backtrace with the needed log level (but only for the architecture they cared about).
If you have other ideas how you will benefit from show_stack() with a log level - please, reply to this cover letter.
Ok, to the scary part: I've tested it on x86_64 and build tested on a couple of architectures. Though, I can't cover all platforms so I hope I'll have a couple of reports and than it'll soak in linux-next for some time. In my opinion the variety of architectures shouldn't stop general improvements.
Thanks,
Dmitry
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
[2]: https://lkml.kernel.org/r/[email protected]
Dmitry Safonov (50):
kallsyms/printk: Add loglvl to print_ip_sym()
alpha: Add show_stack_loglvl()
arc: Add show_stack_loglvl()
arm/asm: Add loglvl to c_backtrace()
arm: Add loglvl to unwind_backtrace()
arm: Add loglvl to dump_backtrace()
arm: Wire up dump_backtrace_{entry,stm}
arm: Add show_stack_loglvl()
arm64: Add loglvl to dump_backtrace()
arm64: Add show_stack_loglvl()
c6x: Add show_stack_loglvl()
csky: Add show_stack_loglvl()
h8300: Add show_stack_loglvl()
hexagon: Add show_stack_loglvl()
ia64: Pass log level as arg into ia64_do_show_stack()
ia64: Add show_stack_loglvl()
m68k: Add show_stack_loglvl()
microblaze: Add loglvl to microblaze_unwind_inner()
microblaze: Add loglvl to microblaze_unwind()
microblaze: Add show_stack_loglvl()
mips: Add show_stack_loglvl()
nds32: Add show_stack_loglvl()
nios2: Add show_stack_loglvl()
openrisc: Add show_stack_loglvl()
parisc: Add show_stack_loglvl()
powerpc: Add show_stack_loglvl()
riscv: Add show_stack_loglvl()
s390: Add show_stack_loglvl()
sh: Add loglvl to dump_mem()
sh: Remove needless printk()
sh: Add loglvl to printk_address()
sh: Add loglvl to show_trace()
sh: Add show_stack_loglvl()
sparc: Add show_stack_loglvl()
um/sysrq: Remove needless variable sp
um: Add show_stack_loglvl()
unicore32: Remove unused pmode argument in c_backtrace()
unicore32: Add loglvl to c_backtrace()
unicore32: Add show_stack_loglvl()
x86: Add missing const qualifiers for log_lvl
x86: Add show_stack_loglvl()
xtensa: Add loglvl to show_trace()
xtensa: Add show_stack_loglvl()
sysrq: Use show_stack_loglvl()
x86/amd_gart: Print stacktrace for a leak with KERN_ERR
power: Use show_stack_loglvl()
kdb: Don't play with console_loglevel
sched: Print stack trace with KERN_INFO
kernel: Use show_stack_loglvl()
kernel: Rename show_stack_loglvl() => show_stack()
arch/alpha/kernel/traps.c | 22 +++++++-------- arch/arc/include/asm/bug.h | 3 ++- arch/arc/kernel/stacktrace.c | 17 +++++++----- arch/arc/kernel/troubleshoot.c | 2 +- arch/arm/include/asm/bug.h | 3 ++- arch/arm/include/asm/traps.h | 3 ++- arch/arm/include/asm/unwind.h | 3 ++- arch/arm/kernel/traps.c | 40 ++++++++++++++++------------ arch/arm/kernel/unwind.c | 7 ++--- arch/arm/lib/backtrace-clang.S | 9 +++++-- arch/arm/lib/backtrace.S | 14 +++++++--- arch/arm64/include/asm/stacktrace.h | 3 ++- arch/arm64/kernel/process.c | 2 +- arch/arm64/kernel/traps.c | 19 ++++++------- arch/c6x/kernel/traps.c | 18 +++++++------ arch/csky/kernel/dumpstack.c | 9 ++++--- arch/csky/kernel/ptrace.c | 4 +-- arch/h8300/kernel/traps.c | 12 ++++----- arch/hexagon/kernel/traps.c | 25 ++++++++--------- arch/ia64/include/asm/ptrace.h | 1 - arch/ia64/kernel/mca.c | 2 +- arch/ia64/kernel/process.c | 17 ++++++------ arch/m68k/kernel/traps.c | 13 ++++----- arch/microblaze/include/asm/unwind.h | 3 ++- arch/microblaze/kernel/stacktrace.c | 4 +-- arch/microblaze/kernel/traps.c | 12 ++++----- arch/microblaze/kernel/unwind.c | 37 ++++++++++++++----------- arch/mips/kernel/traps.c | 35 ++++++++++++------------ arch/nds32/kernel/traps.c | 15 ++++++----- arch/nios2/kernel/traps.c | 17 ++++++------ arch/openrisc/kernel/traps.c | 12 +++++---- arch/parisc/kernel/traps.c | 24 ++++++++--------- arch/powerpc/kernel/process.c | 15 ++++++----- arch/powerpc/kernel/stacktrace.c | 2 +- arch/riscv/kernel/stacktrace.c | 9 ++++--- arch/s390/kernel/dumpstack.c | 11 ++++---- arch/sh/include/asm/kdebug.h | 6 +++-- arch/sh/include/asm/processor_32.h | 2 +- arch/sh/kernel/dumpstack.c | 36 ++++++++++++------------- arch/sh/kernel/process_32.c | 2 +- arch/sh/kernel/process_64.c | 3 +-- arch/sh/kernel/traps.c | 4 +-- arch/sh/mm/fault.c | 2 +- arch/sparc/kernel/process_32.c | 10 +++---- arch/sparc/kernel/process_64.c | 2 +- arch/um/drivers/mconsole_kern.c | 2 +- arch/um/kernel/sysrq.c | 23 ++++++++-------- arch/unicore32/kernel/setup.h | 2 +- arch/unicore32/kernel/traps.c | 34 +++++++++++------------ arch/unicore32/lib/backtrace.S | 24 +++++++++++------ arch/x86/include/asm/stacktrace.h | 2 +- arch/x86/kernel/amd_gart_64.c | 2 +- arch/x86/kernel/dumpstack.c | 9 ++++--- arch/xtensa/kernel/traps.c | 26 ++++++++++-------- drivers/base/power/main.c | 2 +- drivers/tty/sysrq.c | 2 +- include/linux/kallsyms.h | 4 +-- include/linux/sched/debug.h | 3 ++- kernel/debug/kdb/kdb_bt.c | 11 +++----- kernel/locking/lockdep.c | 4 +-- kernel/locking/rtmutex-debug.c | 2 +- kernel/sched/core.c | 6 ++--- kernel/trace/ftrace.c | 8 +++--- lib/dump_stack.c | 2 +- 64 files changed, 368 insertions(+), 311 deletions(-)
Signature · 1 line
2.23.0
PATCH 1/50 kallsyms/printk: Add loglvl to print_ip_sym()
print_ip_sym() needs to have a log level parameter to comply with other parts being printed. Otherwise, half of the expected backtrace would be printed and other may be missing with some logging level.
The following callee(s) are using now the adjusted log level:
- microblaze/unwind: the same level as headers & userspace unwind. Note that pr_debug()'s there are for debugging the unwinder itself.
- nds32/traps: symbol addresses are printed with the same log level as backtrace headers.
- lockdep: ip for locking issues is printed with the same log level as other part of the warning.
- sched: ip where preemption was disabled is printed as error like the rest part of the message.
- ftrace: bug reports are now consistent in the log level being used.
--- arch/microblaze/kernel/unwind.c | 2 +- arch/mips/kernel/traps.c | 4 ++-- arch/nds32/kernel/traps.c | 4 ++-- arch/riscv/kernel/stacktrace.c | 2 +- include/linux/kallsyms.h | 4 ++-- kernel/locking/lockdep.c | 4 ++-- kernel/sched/core.c | 4 ++-- kernel/trace/ftrace.c | 8 ++++---- 8 files changed, 16 insertions(+), 16 deletions(-)
arch/microblaze/kernel/unwind.c +1 -1
@@ -254,7 +254,7 @@ static void microblaze_unwind_inner(struct task_struct *task, task->comm);break ; }else -print_ip_sym (pc); +print_ip_sym (KERN_INFO , pc); }/* Stop when we reach anything not part of the kernel */
arch/mips/kernel/traps.c +2 -2
@@ -123,7 +123,7 @@ static void show_raw_backtrace(unsigned long reg29)break ; }if (__kernel_text_address (addr)) -print_ip_sym (addr); +print_ip_sym (KERN_DEFAULT , addr); }printk ("\n" ); }
@@ -153,7 +153,7 @@ static void show_backtrace(struct task_struct *task, const struct pt_regs *regs) }printk ("Call Trace:\n" );do { -print_ip_sym (pc); +print_ip_sym (KERN_DEFAULT , pc); pc =unwind_stack (task, &sp, pc, &ra); }while (pc);pr_cont ("\n" );
arch/nds32/kernel/traps.c +2 -2
@@ -108,7 +108,7 @@ static void __dump(struct task_struct *tsk, unsigned long *base_reg)if (__kernel_text_address (ret_addr)) { ret_addr =ftrace_graph_ret_addr ( tsk, &graph, ret_addr,NULL ); -print_ip_sym (ret_addr); +print_ip_sym (KERN_EMERG , ret_addr); }if (--cnt <0 )break ;
@@ -124,7 +124,7 @@ static void __dump(struct task_struct *tsk, unsigned long *base_reg) ret_addr =ftrace_graph_ret_addr ( tsk, &graph, ret_addr,NULL ); -print_ip_sym (ret_addr); +print_ip_sym (KERN_EMERG , ret_addr); }if (--cnt <0 )break ;
arch/riscv/kernel/stacktrace.c +1 -1
@@ -98,7 +98,7 @@ static void notrace walk_stackframe(struct task_struct *task,static bool print_trace_address (unsigned long pc,void *arg) { -print_ip_sym (pc); +print_ip_sym (KERN_DEFAULT , pc);return false; }
include/linux/kallsyms.h +2 -2
@@ -165,9 +165,9 @@ static inline int kallsyms_show_value(void)#endif /*CONFIG_KALLSYMS*/ -static inline void print_ip_sym (unsigned long ip) +static inline void print_ip_sym (const char *loglvl,unsigned long ip) { -printk ("[<%px>] %pS\n" , (void *) ip, (void *) ip); +printk ("%s[<%px>] %pS\n" , loglvl, (void *) ip, (void *) ip); }#endif /*_LINUX_KALLSYMS_H*/
kernel/locking/lockdep.c +2 -2
@@ -3999,7 +3999,7 @@ static void print_unlock_imbalance_bug(struct task_struct *curr, curr->comm, task_pid_nr(curr));print_lockdep_cache (lock);pr_cont (") at:\n" ); -print_ip_sym (ip); +print_ip_sym (KERN_WARNING , ip);pr_warn ("but there are no more locks to release!\n" );pr_warn ("\nother info that might help us debug this:\n" );lockdep_print_held_locks (curr);
@@ -4604,7 +4604,7 @@ static void print_lock_contention_bug(struct task_struct *curr, curr->comm, task_pid_nr(curr));print_lockdep_cache (lock);pr_cont (") at:\n" ); -print_ip_sym (ip); +print_ip_sym (KERN_WARNING , ip);pr_warn ("but there are no locks held!\n" );pr_warn ("\nother info that might help us debug this:\n" );lockdep_print_held_locks (curr);
kernel/sched/core.c +2 -2
@@ -3858,7 +3858,7 @@ static noinline void __schedule_bug(struct task_struct *prev)if (IS_ENABLED (CONFIG_DEBUG_PREEMPT ) &&in_atomic_preempt_off ()) {pr_err ("Preemption disabled at:" ); -print_ip_sym (preempt_disable_ip); +print_ip_sym (KERN_ERR , preempt_disable_ip);pr_cont ("\n" ); }if (panic_on_warn)
@@ -6774,7 +6774,7 @@ void ___might_sleep(const char *file, int line, int preempt_offset)if (IS_ENABLED (CONFIG_DEBUG_PREEMPT ) && !preempt_count_equals (preempt_offset)) {pr_err ("Preemption disabled at:" ); -print_ip_sym (preempt_disable_ip); +print_ip_sym (KERN_ERR , preempt_disable_ip);pr_cont ("\n" ); }dump_stack ();
kernel/trace/ftrace.c +4 -4
@@ -2002,12 +2002,12 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)case -EFAULT :FTRACE_WARN_ON_ONCE (1 );pr_info ("ftrace faulted on modifying " ); -print_ip_sym (ip); +print_ip_sym (KERN_INFO , ip);break ;case -EINVAL :FTRACE_WARN_ON_ONCE (1 );pr_info ("ftrace failed to modify " ); -print_ip_sym (ip); +print_ip_sym (KERN_INFO , ip);print_ip_ins (" actual: " , (unsigned char *)ip);pr_cont ("\n" );if (ftrace_expected) {
@@ -2018,12 +2018,12 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)case -EPERM :FTRACE_WARN_ON_ONCE (1 );pr_info ("ftrace faulted on writing " ); -print_ip_sym (ip); +print_ip_sym (KERN_INFO , ip);break ;default :FTRACE_WARN_ON_ONCE (1 );pr_info ("ftrace faulted on unknown error " ); -print_ip_sym (ip); +print_ip_sym (KERN_INFO , ip); }print_bug_type ();if (rec) {
Signature · 1 line
2.23.0
Re: [PATCH 01/50] kallsyms/printk: Add loglvl to print_ip_sym()
On (19/11/06 03:04), Dmitry Safonov wrote:
[..]
Quoted 28 lines
#endif /*_LINUX_KALLSYMS_H*/
kernel/locking/lockdep.c +2
-2@@ -3999,7 +3999,7 @@ static void print_unlock_imbalance_bug(struct task_struct *curr, curr->comm, task_pid_nr(curr));print_lockdep_cache (lock);pr_cont (") at:\n" ); -print_ip_sym (ip); +print_ip_sym (KERN_WARNING , ip);pr_warn ("but there are no more locks to release!\n" );pr_warn ("\nother info that might help us debug this:\n" );lockdep_print_held_locks (curr);@@ -4604,7 +4604,7 @@ static void print_lock_contention_bug(struct task_struct *curr, curr->comm, task_pid_nr(curr));print_lockdep_cache (lock);pr_cont (") at:\n" ); -print_ip_sym (ip); +print_ip_sym (KERN_WARNING , ip);pr_warn ("but there are no locks held!\n" );pr_warn ("\nother info that might help us debug this:\n" );lockdep_print_held_locks (curr);kernel/sched/core.c +0
-0
kernel/sched/core.c static noinline void __schedule_bug(struct task_struct *prev) · line 3862
Quoted 6 lines
kernel/sched/core.c +1
-1@@ -3858,7 +3858,7 @@ static noinline void __schedule_bug(struct task_struct *prev)if (IS_ENABLED (CONFIG_DEBUG_PREEMPT ) &&in_atomic_preempt_off ()) {pr_err ("Preemption disabled at:" ); -print_ip_sym (preempt_disable_ip); +print_ip_sym (KERN_ERR , preempt_disable_ip);pr_cont ("\n" );
Is this working with pr_cont()?
-ss
Re: [PATCH 01/50] kallsyms/printk: Add loglvl to print_ip_sym()
Hi Sergey,
Quoted 15 lines · Sergey Senozhatsky
On (19/11/06 03:04), Dmitry Safonov wrote:
[..]kernel/sched/core.c static noinline void __schedule_bug(struct task_struct *prev) · line 3862
Quoted 11 lines
kernel/sched/core.c +1
-1@@ -3858,7 +3858,7 @@ static noinline void __schedule_bug(struct task_struct *prev)if (IS_ENABLED (CONFIG_DEBUG_PREEMPT ) &&in_atomic_preempt_off ()) {pr_err ("Preemption disabled at:" ); -print_ip_sym (preempt_disable_ip); +print_ip_sym (KERN_ERR , preempt_disable_ip);pr_cont ("\n" );Is this working with
pr_cont()?
print_ip_sym() will cause log_store()..
And pr_cont("\n") will go here:
: /* Skip empty continuation lines that couldn't be added - they just
flush */
: if (!text_len && (lflags & LOG_CONT))
: return 0;
So it doesn't do anything. I didn't want to change any behavior in the patch, but seems that I can remove this pr_cont() while at here.
Thanks,
Dmitry
Re: [PATCH 01/50] kallsyms/printk: Add loglvl to print_ip_sym()
In reply to Dmitry Safonovkernel/trace/ftrace.c void ftrace_bug(int failed, struct dyn_ftrace *rec) · line 2004
Quoted 6 lines · On Wed, 6 Nov 2019 03:04:52 +0000 Dmitry Safonov <[email protected]> wrote:
kernel/trace/ftrace.c +0
-0@@ -2002,12 +2002,12 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)case -EFAULT :FTRACE_WARN_ON_ONCE (1 );pr_info ("ftrace faulted on modifying " );
Hmm, I wonder if I should change that from info to something more important, as this is important information for debugging. But this has nothing to do with this patch set.
kernel/trace/ftrace.c void ftrace_bug(int failed, struct dyn_ftrace *rec) · line 2005
Quoted 2 lines
kernel/trace/ftrace.c +1
-1-print_ip_sym (ip); +print_ip_sym (KERN_INFO , ip);
-- Steve
Quoted 24 lines
kernel/trace/ftrace.c +3
-3break ;case -EINVAL :FTRACE_WARN_ON_ONCE (1 );pr_info ("ftrace failed to modify " ); -print_ip_sym (ip); +print_ip_sym (KERN_INFO , ip);print_ip_ins (" actual: " , (unsigned char *)ip);pr_cont ("\n" );if (ftrace_expected) {@@ -2018,12 +2018,12 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)case -EPERM :FTRACE_WARN_ON_ONCE (1 );pr_info ("ftrace faulted on writing " ); -print_ip_sym (ip); +print_ip_sym (KERN_INFO , ip);break ;default :FTRACE_WARN_ON_ONCE (1 );pr_info ("ftrace faulted on unknown error " ); -print_ip_sym (ip); +print_ip_sym (KERN_INFO , ip); }print_bug_type ();if (rec) {
PATCH 2/50 alpha: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Ivan Kokshaysky <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/alpha/kernel/traps.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
arch/alpha/kernel/traps.c +17 -11
@@ -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" );
Signature · 1 line
2.23.0
PATCH 3/50 arc: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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 good side-effect header "Stack Trace:" is now printed with the same log level as the rest of backtrace.
Cc: Vineet Gupta <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/arc/include/asm/bug.h | 3 ++- arch/arc/kernel/stacktrace.c | 21 +++++++++++++++------ arch/arc/kernel/troubleshoot.c | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-)
arch/arc/include/asm/bug.h +2 -1
@@ -13,7 +13,8 @@struct task_struct ;void show_regs (struct pt_regs *regs); -void show_stacktrace (struct task_struct *tsk,struct pt_regs *regs); +void show_stacktrace (struct task_struct *tsk,struct pt_regs *regs, +const char *loglvl);void show_kernel_fault_diag (const char *str,struct pt_regs *regs,unsigned long address);void die (const char *str,struct pt_regs *regs,unsigned long address);
arch/arc/kernel/stacktrace.c +15 -6
@@ -158,9 +158,11 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs,/* Call-back which plugs into unwinding core to dump the stack in * case of panic/OOPs/BUG etc */ -static int __print_sym (unsigned int address,void *unused) +static int __print_sym (unsigned int address,void *arg) { -printk (" %pS\n" , (void *)address); +const char *loglvl = arg; + +printk ("%s %pS\n" , loglvl, (void *)address);return 0 ; }
@@ -217,17 +219,24 @@ static int __get_first_nonsched(unsigned int address, void *unused)*------------------------------------------------------------------------- */ -noinline void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs) +noinline void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs, +const char *loglvl) { -pr_info ("\nStack Trace:\n" ); -arc_unwind_core (tsk, regs, __print_sym,NULL ); +printk ("%s\nStack Trace:\n" , loglvl); +arc_unwind_core (tsk, regs, __print_sym, (void *)loglvl); }EXPORT_SYMBOL (show_stacktrace);/* Expected by sched Code */ +void show_stack_loglvl (struct task_struct *tsk,unsigned long *sp, +const char *loglvl) +{ +show_stacktrace (tsk,NULL , loglvl); +} +void show_stack (struct task_struct *tsk,unsigned long *sp) { -show_stacktrace (tsk,NULL ); +show_stack_loglvl (tsk, sp,KERN_DEFAULT ); }/* Another API expected by schedular, shows up in "ps" as Wait Channel
arch/arc/kernel/troubleshoot.c +1 -1
@@ -245,5 +245,5 @@ void show_kernel_fault_diag(const char *str, struct pt_regs *regs,/* Show stack trace if this Fatality happened in kernel mode */ if (!user_mode (regs)) -show_stacktrace (current, regs); +show_stacktrace (current, regs,KERN_DEFAULT ); }
Signature · 7 lines
2.23.0 _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
PATCH 4/50 arm/asm: Add loglvl to c_backtrace()
In reply to Dmitry SafonovCurrently, 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 c_backtrace() as a preparation for introducing show_stack_loglvl().
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/arm/include/asm/bug.h | 3 ++- arch/arm/include/asm/traps.h | 3 ++- arch/arm/kernel/traps.c | 9 +++++---- arch/arm/kernel/unwind.c | 2 +- arch/arm/lib/backtrace-clang.S | 9 +++++++-- arch/arm/lib/backtrace.S | 14 ++++++++++---- 6 files changed, 27 insertions(+), 13 deletions(-)
arch/arm/include/asm/bug.h +2 -1
@@ -82,7 +82,8 @@ void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *), int sig, int code, const char *name); -extern asmlinkage void c_backtrace(unsigned long fp, int pmode); +extern asmlinkage void c_backtrace(unsigned long fp, int pmode, +const char *loglvl);struct mm_struct ;void show_pte (const char *lvl,struct mm_struct *mm,unsigned long addr);
arch/arm/include/asm/traps.h +2 -1
@@ -29,7 +29,8 @@ static inline int __in_irqentry_text(unsigned long ptr) }extern void __init early_trap_init (void *); -extern void dump_backtrace_entry (unsigned long where,unsigned long from,unsigned long frame); +extern void dump_backtrace_entry (unsigned long where,unsigned long from, +unsigned long frame,const char *loglvl);extern void ptrace_break (struct pt_regs *regs);extern void *vectors_page;
arch/arm/kernel/traps.c +5 -4
@@ -62,7 +62,8 @@ __setup("user_debug=", user_debug_setup);static void dump_mem (const char *,const char *,unsigned long ,unsigned long ); -void dump_backtrace_entry (unsigned long where,unsigned long from,unsigned long frame) +void dump_backtrace_entry (unsigned long where,unsigned long from, +unsigned long frame,const char *loglvl) {#ifdef CONFIG_KALLSYMS printk ("[<%08lx>] (%ps) from [<%08lx>] (%pS)\n" , where, (void *)where, from, (void *)from);
@@ -74,7 +75,7 @@ void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned longdump_mem ("" ,"Exception stack" , frame +4 , frame +4 +sizeof (struct pt_regs )); } -void dump_backtrace_stm (u32 *stack,u32 instruction) +void dump_backtrace_stm (u32 *stack,u32 instruction,const char *loglvl) {char str[80 ], *p;unsigned int x;
@@ -236,7 +237,7 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)pr_cont ("\n" );if (ok) - c_backtrace(fp, mode); + c_backtrace(fp, mode, NULL); }#endif
@@ -662,7 +663,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)dump_instr ("" , regs);if (user_mode (regs)) {__show_regs (regs); -c_backtrace (frame_pointer (regs),processor_mode (regs)); +c_backtrace (frame_pointer (regs),processor_mode (regs),NULL ); } }#endif
arch/arm/kernel/unwind.c +1 -1
@@ -493,7 +493,7 @@ void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk) urc =unwind_frame (&frame);if (urc <0 )break ; -dump_backtrace_entry (where, frame.pc, frame.sp -4 ); +dump_backtrace_entry (where, frame.pc, frame.sp -4 ,NULL ); } }
arch/arm/lib/backtrace-clang.S +7 -2
@@ -17,6 +17,7 @@ #define sv_pc r6 #define mask r7 #define sv_lr r8 +#define loglvl r9 ENTRY(c_backtrace)
@@ -99,6 +100,7 @@ ENDPROC(c_backtrace) @ to ensure 8 byte alignment movs frame, r0 @ if frame pointer is zero beq no_frame @ we have no stack frames + mov loglvl, r2 tst r1, #0x10 @ 26 or 32-bit mode? moveq mask, #0xfc000003 movne mask, #0 @ mask for 32-bit
@@ -167,6 +169,7 @@ finished_setup: mov r1, sv_lr mov r2, frame bic r1, r1, mask @ mask PC/LR for the mode + mov r3, loglvl bl dump_backtrace_entry /*
@@ -183,6 +186,7 @@ finished_setup: ldr r0, [frame] @ locals are stored in @ the preceding frame subeq r0, r0, #4 + mov r2, loglvl bleq dump_backtrace_stm @ dump saved registers /*
@@ -196,7 +200,8 @@ finished_setup: bhi for_each_frame 1006: adr r0, .Lbad - mov r1, frame + mov r1, loglvl + mov r2, frame bl printk no_frame: ldmfd sp!, {r4 - r9, fp, pc} ENDPROC(c_backtrace)
@@ -209,7 +214,7 @@ ENDPROC(c_backtrace) .long 1005b, 1006b .popsection -.Lbad: .asciz "Backtrace aborted due to bad frame pointer <%p>\n" +.Lbad: .asciz "%sBacktrace aborted due to bad frame pointer <%p>\n" .align .Lopcode: .word 0xe92d4800 >> 11 @ stmfd sp!, {... fp, lr} .word 0x0b000000 @ bl if these bits are set
arch/arm/lib/backtrace.S +10 -4
@@ -18,6 +18,7 @@ #define sv_pc r6 #define mask r7 #define offset r8 +#define loglvl r9 ENTRY(c_backtrace)
@@ -25,9 +26,10 @@ ENTRY(c_backtrace) ret lr ENDPROC(c_backtrace) #else - stmfd sp!, {r4 - r8, lr} @ Save an extra register so we have a location... + stmfd sp!, {r4 - r9, lr} @ Save an extra register so we have a location... movs frame, r0 @ if frame pointer is zero beq no_frame @ we have no stack frames + mov loglvl, r2 tst r1, #0x10 @ 26 or 32-bit mode? ARM( moveq mask, #0xfc000003 )
@@ -73,6 +75,7 @@ for_each_frame: tst frame, mask @ Check for address exceptions ldr r1, [frame, #-4] @ get saved lr mov r2, frame bic r1, r1, mask @ mask PC/LR for the mode + mov r3, loglvl bl dump_backtrace_entry ldr r1, [sv_pc, #-4] @ if stmfd sp!, {args} exists,
@@ -80,12 +83,14 @@ for_each_frame: tst frame, mask @ Check for address exceptions teq r3, r1, lsr #11 ldreq r0, [frame, #-8] @ get sp subeq r0, r0, #4 @ point at the last arg + mov r2, loglvl bleq dump_backtrace_stm @ dump saved registers 1004: ldr r1, [sv_pc, #0] @ if stmfd sp!, {..., fp, ip, lr, pc} ldr r3, .Ldsi @ instruction exists, teq r3, r1, lsr #11 subeq r0, frame, #16 + mov r2, loglvl bleq dump_backtrace_stm @ dump saved registers teq sv_fp, #0 @ zero saved fp means
@@ -96,9 +101,10 @@ for_each_frame: tst frame, mask @ Check for address exceptions bhi for_each_frame 1006: adr r0, .Lbad - mov r1, frame + mov r1, loglvl + mov r2, frame bl printk -no_frame: ldmfd sp!, {r4 - r8, pc} +no_frame: ldmfd sp!, {r4 - r9, pc} ENDPROC(c_backtrace) .pushsection __ex_table,"a"
@@ -109,7 +115,7 @@ ENDPROC(c_backtrace) .long 1004b, 1006b .popsection -.Lbad: .asciz "Backtrace aborted due to bad frame pointer <%p>\n" +.Lbad: .asciz "%sBacktrace aborted due to bad frame pointer <%p>\n" .align .Ldsi: .word 0xe92dd800 >> 11 @ stmfd sp!, {... fp, ip, lr, pc} .word 0xe92d0000 >> 11 @ stmfd sp!, {}
Signature · 7 lines
2.23.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 5/50 arm: Add loglvl to unwind_backtrace()
In reply to Dmitry SafonovCurrently, 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 unwind_backtrace() as a preparation for introducing show_stack_loglvl().
As a good side-effect arm_syscall() is now printing errors with the same log level as the backtrace.
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/arm/include/asm/unwind.h | 3 ++- arch/arm/kernel/traps.c | 6 +++--- arch/arm/kernel/unwind.c | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-)
arch/arm/include/asm/unwind.h +2 -1
@@ -36,7 +36,8 @@ extern struct unwind_table *unwind_table_add(unsigned long start,unsigned long text_addr, unsigned long text_size);extern void unwind_table_del (struct unwind_table *tab); -extern void unwind_backtrace (struct pt_regs *regs,struct task_struct *tsk); +extern void unwind_backtrace (struct pt_regs *regs,struct task_struct *tsk, +const char *loglvl);#endif /* !__ASSEMBLY__ */
arch/arm/kernel/traps.c +3 -3
@@ -202,7 +202,7 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)#ifdef CONFIG_ARM_UNWIND static inline void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk) { -unwind_backtrace (regs, tsk); +unwind_backtrace (regs, tsk,KERN_DEBUG ); }#else static void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk)
@@ -660,10 +660,10 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)if (user_debug &UDBG_SYSCALL ) {pr_err ("[%d] %s: arm syscall %d\n" ,task_pid_nr (current), current->comm, no); -dump_instr ("" , regs); +dump_instr (KERN_ERR , regs);if (user_mode (regs)) {__show_regs (regs); -c_backtrace (frame_pointer (regs),processor_mode (regs),NULL ); +c_backtrace (frame_pointer (regs),processor_mode (regs),KERN_ERR ); } }#endif
arch/arm/kernel/unwind.c +4 -3
@@ -455,11 +455,12 @@ int unwind_frame(struct stackframe *frame)return URC_OK ; } -void unwind_backtrace (struct pt_regs *regs,struct task_struct *tsk) +void unwind_backtrace (struct pt_regs *regs,struct task_struct *tsk, +const char *loglvl) {struct stackframe frame; -pr_debug ("%s(regs = %p tsk = %p)\n" , __func__, regs, tsk); +printk ("%s%s(regs = %p tsk = %p)\n" , loglvl, __func__, regs, tsk);if (!tsk) tsk = current;
@@ -493,7 +494,7 @@ void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk) urc =unwind_frame (&frame);if (urc <0 )break ; -dump_backtrace_entry (where, frame.pc, frame.sp -4 ,NULL ); +dump_backtrace_entry (where, frame.pc, frame.sp -4 , loglvl); } }
Signature · 1 line
2.23.0
Russell King - ARM Linux admin
maintainerRe: [PATCH 05/50] arm: Add loglvl to unwind_backtrace()
Quoted 53 lines · Dmitry Safonov
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_loglevelwhile 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 theprintk()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
unwind_backtrace()as a preparation for introducingshow_stack_loglvl().As a good side-effect
arm_syscall()is now printing errors with the same log level as the backtrace.Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#uSigned-off-by Dmitry Safonov <[email protected]>--- arch/arm/include/asm/unwind.h | 3 ++- arch/arm/kernel/traps.c | 6 +++--- arch/arm/kernel/unwind.c | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-)arch/arm/include/asm/unwind.h +2
-1@@ -36,7 +36,8 @@ extern struct unwind_table *unwind_table_add(unsigned long start,unsigned long text_addr, unsigned long text_size);extern void unwind_table_del (struct unwind_table *tab); -extern void unwind_backtrace (struct pt_regs *regs,struct task_struct *tsk); +extern void unwind_backtrace (struct pt_regs *regs,struct task_struct *tsk, +const char *loglvl);#endif /* !__ASSEMBLY__ */ arch/arm/kernel/traps.c +0
-0
arch/arm/kernel/traps.c static void dump_instr(const char *lvl, struct pt_regs *regs) · line 205
Quoted 5 lines
arch/arm/kernel/traps.c +1
-1@@ -202,7 +202,7 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)#ifdef CONFIG_ARM_UNWIND static inline void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk) { -unwind_backtrace (regs, tsk); +unwind_backtrace (regs, tsk,KERN_DEBUG );
Why demote this to debug level? This is used as part of the kernel panic message, surely we don't want this at debug level? What about the non-unwind version?
Quoted 22 lines
arch/arm/kernel/traps.c +2
-2}#else static void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk)@@ -660,10 +660,10 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)if (user_debug &UDBG_SYSCALL ) {pr_err ("[%d] %s: arm syscall %d\n" ,task_pid_nr (current), current->comm, no); -dump_instr ("" , regs); +dump_instr (KERN_ERR , regs);if (user_mode (regs)) {__show_regs (regs); -c_backtrace (frame_pointer (regs),processor_mode (regs),NULL ); +c_backtrace (frame_pointer (regs),processor_mode (regs),KERN_ERR ); } }#endif arch/arm/kernel/unwind.c +0
-0@@ -455,11 +455,12 @@ int unwind_frame(struct stackframe *frame)return URC_OK ;
arch/arm/kernel/unwind.c int unwind_frame(struct stackframe *frame) · line 463
Quoted 10 lines
arch/arm/kernel/unwind.c +3
-2} -void unwind_backtrace (struct pt_regs *regs,struct task_struct *tsk) +void unwind_backtrace (struct pt_regs *regs,struct task_struct *tsk, +const char *loglvl) {struct stackframe frame; -pr_debug ("%s(regs = %p tsk = %p)\n" , __func__, regs, tsk); +printk ("%s%s(regs = %p tsk = %p)\n" , loglvl, __func__, regs, tsk);
Clearly, this isn't supposed to be part of the normal backtrace output...
Overall impression at this point is really not good.
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Re: [PATCH 05/50] arm: Add loglvl to unwind_backtrace()
Quoted 15 lines · Russell King - ARM Linux admin
arch/arm/kernel/traps.c static void dump_instr(const char *lvl, struct pt_regs *regs) · line 205
Quoted 10 lines · Dmitry Safonov
arch/arm/kernel/traps.c +1
-1@@ -202,7 +202,7 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)#ifdef CONFIG_ARM_UNWIND static inline void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk) { -unwind_backtrace (regs, tsk); +unwind_backtrace (regs, tsk,KERN_DEBUG );Why demote this to debug level? This is used as part of the kernel panic message, surely we don't want this at debug level? What about the non-unwind version?
Right, I wanted to keep the old loglevel in this patch - KERN_DEFAULT. But got confused with log level in unwind_backtrace().
Will fix.
[..]
Quoted 14 lines
Quoted 14 lines
arch/arm/kernel/unwind.c +2
-1@@ -455,11 +455,12 @@ int unwind_frame(struct stackframe *frame)return URC_OK ; } -void unwind_backtrace (struct pt_regs *regs,struct task_struct *tsk) +void unwind_backtrace (struct pt_regs *regs,struct task_struct *tsk, +const char *loglvl) {struct stackframe frame;
Quoted 4 lines
arch/arm/kernel/unwind.c int unwind_frame(struct stackframe *frame) · line 463
Quoted 2 lines
arch/arm/kernel/unwind.c +1
-1-pr_debug ("%s(regs = %p tsk = %p)\n" , __func__, regs, tsk); +printk ("%s%s(regs = %p tsk = %p)\n" , loglvl, __func__, regs, tsk);Clearly, this isn't supposed to be part of the normal backtrace output...
Yes, sorry it's debug for a backtrace - will return pr_debug() for the message.
Thanks,
Dmitry
PATCH 6/50 arm: Add loglvl to dump_backtrace()
In reply to Dmitry SafonovCurrently, 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_backtrace() as a preparation for introducing show_stack_loglvl().
As a good side-effect __die() now prints not only "Stack:" header with KERN_EMERG, but the backtrace itself.
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/arm/kernel/traps.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
arch/arm/kernel/traps.c +9 -7
@@ -200,17 +200,19 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) }#ifdef CONFIG_ARM_UNWIND -static inline void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk) +static inline void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk, +const char *loglvl) { -unwind_backtrace (regs, tsk,KERN_DEBUG ); +unwind_backtrace (regs, tsk, loglvl); }#else -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, mode;int ok =1 ; -printk ("Backtrace: " ); +printk ("%sBacktrace: " , loglvl);if (!tsk) tsk = current;
@@ -237,13 +239,13 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)pr_cont ("\n" );if (ok) - c_backtrace(fp, mode, NULL); + c_backtrace(fp, mode, loglvl); }#endif void show_stack (struct task_struct *tsk,unsigned long *sp) { -dump_backtrace (NULL , tsk); +dump_backtrace (NULL , tsk,KERN_DEFAULT );barrier (); }
@@ -285,7 +287,7 @@ static int __die(const char *str, int err, struct pt_regs *regs)if (!user_mode (regs) ||in_interrupt ()) {dump_mem (KERN_EMERG ,"Stack: " , regs->ARM_sp,THREAD_SIZE + (unsigned long )task_stack_page (tsk)); -dump_backtrace (regs, tsk); +dump_backtrace (regs, tsk,KERN_EMERG );dump_instr (KERN_EMERG , regs); }
Signature · 1 line
2.23.0
PATCH 7/50 arm: Wire up dump_backtrace_{entry,stm}
In reply to Dmitry SafonovCurrently, 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.
Now that c_backtrace() always emits correct loglvl, use it for printing.
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/arm/kernel/traps.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
arch/arm/kernel/traps.c +8 -5
@@ -66,13 +66,16 @@ void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame, const char *loglvl) { #ifdef CONFIG_KALLSYMS - printk("[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from); + printk("%s[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", + loglvl, where, (void *)where, from, (void *)from);#else -printk ("Function entered at [<%08lx>] from [<%08lx>]\n" , where, from); +printk ("%sFunction entered at [<%08lx>] from [<%08lx>]\n" , + loglvl, where, from);#endif if (in_entry_text (from)) -dump_mem ("" ,"Exception stack" , frame +4 , frame +4 +sizeof (struct pt_regs )); +dump_mem (loglvl,"Exception stack" , + frame +4 , frame +4 +sizeof (struct pt_regs )); }void dump_backtrace_stm (u32 *stack,u32 instruction,const char *loglvl)
@@ -87,12 +90,12 @@ void dump_backtrace_stm(u32 *stack, u32 instruction, const char *loglvl)if (++x ==6 ) { x =0 ; p = str; -printk ("%s\n" , str); +printk ("%s%s\n" , loglvl, str); } } }if (p != str) -printk ("%s\n" , str); +printk ("%s%s\n" , loglvl, str); }#ifndef CONFIG_ARM_UNWIND
Signature · 1 line
2.23.0
PATCH 8/50 arm: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/arm/kernel/traps.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/arm/kernel/traps.c +8 -2
@@ -246,12 +246,18 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, }#endif -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,KERN_DEFAULT ); +dump_backtrace (NULL , tsk, loglvl);barrier (); } +void show_stack (struct task_struct *tsk,unsigned long *sp) +{ +show_stack_loglvl (tsk, sp,KERN_DEFAULT ); +} +#ifdef CONFIG_PREEMPT #define S_PREEMPT " PREEMPT"#else
Signature · 1 line
2.23.0
PATCH 9/50 arm64: Add loglvl to dump_backtrace()
In reply to Dmitry SafonovCurrently, 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_backtrace() as a preparation for introducing show_stack_loglvl().
Cc: Catalin Marinas <[email protected]>
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/arm64/include/asm/stacktrace.h | 3 ++- arch/arm64/kernel/process.c | 2 +- arch/arm64/kernel/traps.c | 17 +++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-)
arch/arm64/include/asm/stacktrace.h +2 -1
@@ -64,7 +64,8 @@ struct stackframe {extern int unwind_frame (struct task_struct *tsk,struct stackframe *frame);extern void walk_stackframe (struct task_struct *tsk,struct stackframe *frame,int (*fn)(struct stackframe *,void *),void *data); -extern void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk); +extern void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk, +const char *loglvl); DECLARE_PER_CPU(unsigned long *, irq_stack_ptr);
arch/arm64/kernel/process.c +1 -1
@@ -291,7 +291,7 @@ void __show_regs(struct pt_regs *regs)void show_regs (struct pt_regs * regs) {__show_regs (regs); -dump_backtrace (regs,NULL ); +dump_backtrace (regs,NULL ,KERN_DEFAULT ); }static void tls_thread_flush (void )
arch/arm64/kernel/traps.c +9 -8
@@ -52,9 +52,9 @@ static const char *handler[]= {int show_unhandled_signals =0 ; -static void dump_backtrace_entry (unsigned long where) +static void dump_backtrace_entry (unsigned long where,const char *loglvl) { -printk (" %pS\n" , (void *)where); +printk ("%s %pS\n" , loglvl, (void *)where); }static void dump_kernel_instr (const char *lvl,struct pt_regs *regs)
@@ -82,12 +82,13 @@ static void dump_kernel_instr(const char *lvl, struct pt_regs *regs)printk ("%sCode: %s\n" , lvl, str); } -void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk) +void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk, +const char *loglvl) {struct stackframe frame;int skip =0 ; -pr_debug ("%s(regs = %p tsk = %p)\n" , __func__, regs, tsk); +printk ("%s%s(regs = %p tsk = %p)\n" , loglvl, __func__, regs, tsk);if (regs) {if (user_mode (regs))
@@ -114,11 +115,11 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) thread_saved_pc(tsk)); } -printk ("Call trace:\n" ); +printk ("%sCall trace:\n" , loglvl); do { /* skip until specified stack frame */ if (!skip) { - dump_backtrace_entry(frame.pc); + dump_backtrace_entry(frame.pc, loglvl); } else if (frame.fp == regs->regs[29]) { skip = 0; /*
@@ -128,7 +129,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)* at which an exception has taken place, use regs->pc * instead. */ -dump_backtrace_entry (regs->pc); +dump_backtrace_entry (regs->pc, loglvl); } }while (!unwind_frame (tsk, &frame));
@@ -137,7 +138,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)void show_stack (struct task_struct *tsk,unsigned long *sp) { -dump_backtrace (NULL , tsk); +dump_backtrace (NULL , tsk,KERN_DEFAULT );barrier (); }
Signature · 1 line
2.23.0
Will Deacon
maintainerRe: [PATCH 09/50] arm64: Add loglvl to dump_backtrace()
Quoted 30 lines · Dmitry Safonov
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_loglevelwhile 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 theprintk()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_backtrace()as a preparation for introducingshow_stack_loglvl().Cc: Catalin Marinas <[email protected]>
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#uSigned-off-by Dmitry Safonov <[email protected]>--- arch/arm64/include/asm/stacktrace.h | 3 ++- arch/arm64/kernel/process.c | 2 +- arch/arm64/kernel/traps.c | 17 +++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-)
[...]
Quoted 19 lines
arch/arm64/kernel/traps.c +2
-2@@ -52,9 +52,9 @@ static const char *handler[]= {int show_unhandled_signals =0 ; -static void dump_backtrace_entry (unsigned long where) +static void dump_backtrace_entry (unsigned long where,const char *loglvl) { -printk (" %pS\n" , (void *)where); +printk ("%s %pS\n" , loglvl, (void *)where); }static void dump_kernel_instr (const char *lvl,struct pt_regs *regs)@@ -82,12 +82,13 @@ static void dump_kernel_instr(const char *lvl, struct pt_regs *regs)printk ("%sCode: %s\n" , lvl, str); }
arch/arm64/kernel/traps.c static void dump_kernel_instr(const char *lvl, struct pt_regs *regs) · line 91
Quoted 10 lines
arch/arm64/kernel/traps.c +3
-2-void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk) +void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk, +const char *loglvl) {struct stackframe frame;int skip =0 ; -pr_debug ("%s(regs = %p tsk = %p)\n" , __func__, regs, tsk); +printk ("%s%s(regs = %p tsk = %p)\n" , loglvl, __func__, regs, tsk);
This one needs to stay as pr_debug().
Will
Re: [PATCH 09/50] arm64: Add loglvl to dump_backtrace()
Quoted 1 line · Will Deacon
On Wed, Nov 06, 2019 at 03:05:00AM +0000, Dmitry Safonov wrote:
[..]
Quoted 11 lines
Quoted 11 lines
arch/arm64/kernel/traps.c +2
-1@@ -82,12 +82,13 @@ static void dump_kernel_instr(const char *lvl, struct pt_regs *regs)printk ("%sCode: %s\n" , lvl, str); } -void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk) +void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk, +const char *loglvl) {struct stackframe frame;int skip =0 ;
Quoted 4 lines
arch/arm64/kernel/traps.c static void dump_kernel_instr(const char *lvl, struct pt_regs *regs) · line 91
Quoted 2 lines
arch/arm64/kernel/traps.c +1
-1-pr_debug ("%s(regs = %p tsk = %p)\n" , __func__, regs, tsk); +printk ("%s%s(regs = %p tsk = %p)\n" , loglvl, __func__, regs, tsk);This one needs to stay as
pr_debug().
Makes sense, it's debug rather part of backtrace, will fix.
Thanks,
Dmitry
PATCH 10/50 arm64: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Catalin Marinas <[email protected]>
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/arm64/kernel/traps.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/arm64/kernel/traps.c +8 -2
@@ -136,12 +136,18 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,put_task_stack (tsk); } -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,KERN_DEFAULT ); +dump_backtrace (NULL , tsk, loglvl);barrier (); } +void show_stack (struct task_struct *tsk,unsigned long *sp) +{ +show_stack_loglvl (tsk, sp,KERN_DEFAULT ); +} +#ifdef CONFIG_PREEMPT #define S_PREEMPT " PREEMPT"#else
Signature · 1 line
2.23.0
PATCH 11/50 c6x: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Aurelien Jacquiot <[email protected]>
Cc: Mark Salter <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/c6x/kernel/traps.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
arch/c6x/kernel/traps.c +15 -8
@@ -344,12 +344,13 @@ asmlinkage int process_exception(struct pt_regs *regs)static int kstack_depth_to_print =48 ; -static void show_trace (unsigned long *stack,unsigned long *endstack) +static void show_trace (unsigned long *stack,unsigned long *endstack, +const char *loglvl) {unsigned long addr;int i; -pr_debug ("Call trace:" ); +printk ("%sCall trace:" , loglvl); i =0 ;while (stack +1 <= endstack) { addr = *stack++;
@@ -364,16 +365,17 @@ static void show_trace(unsigned long *stack, unsigned long *endstack)if (__kernel_text_address (addr)) {#ifndef CONFIG_KALLSYMS if (i %5 ==0 ) -pr_debug ("\n " ); +printk ("%s\n " , loglvl);#endif -pr_debug (" [<%08lx>] %pS\n" , addr, (void *)addr); +printk ("%s [<%08lx>] %pS\n" , loglvl, addr, (void *)addr); i++; } } -pr_debug ("\n" ); +printk ("%s\n" , loglvl); } -void show_stack (struct task_struct *task,unsigned long *stack) +void show_stack_loglvl (struct task_struct *task,unsigned long *stack, +const char *loglvl) {unsigned long *p, *endstack;int i;
@@ -389,7 +391,7 @@ void show_stack(struct task_struct *task, unsigned long *stack) endstack = (unsigned long *)(((unsigned long )stack +THREAD_SIZE -1 ) & -THREAD_SIZE ); -pr_debug ("Stack from %08lx:" , (unsigned long )stack); +printk ("%sStack from %08lx:" , loglvl, (unsigned long )stack);for (i =0 , p = stack; i < kstack_depth_to_print; i++) {if (p +1 > endstack)break ;
@@ -398,7 +400,12 @@ void show_stack(struct task_struct *task, unsigned long *stack)pr_cont (" %08lx" , *p++); }pr_cont ("\n" ); -show_trace (stack, endstack); +show_trace (stack, endstack, loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *stack) +{ +show_stack_loglvl (task, stack,KERN_DEBUG ); }int is_valid_bugaddr (unsigned long addr)
Signature · 1 line
2.23.0
PATCH 12/50 csky: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Guo Ren <[email protected]>
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/csky/kernel/dumpstack.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
arch/csky/kernel/dumpstack.c +10 -4
@@ -5,7 +5,7 @@int kstack_depth_to_print =48 ; -void show_trace (unsigned long *stack) +static void show_trace (unsigned long *stack,const char *loglvl) {unsigned long *stack_end;unsigned long *stack_start;
@@ -17,7 +17,7 @@ void show_trace(unsigned long *stack) stack_end = (unsigned long *) (addr +THREAD_SIZE ); fp = stack; -pr_info ("\nCall Trace:" ); +printk ("%s\nCall Trace:" , loglvl);while (fp > stack_start && fp < stack_end) {#ifdef CONFIG_STACKTRACE
@@ -32,7 +32,8 @@ void show_trace(unsigned long *stack)pr_cont ("\n" ); } -void show_stack (struct task_struct *task,unsigned long *stack) +void show_stack_loglvl (struct task_struct *task,unsigned long *stack, +const char *loglvl) {if (!stack) {if (task)
@@ -45,5 +46,10 @@ void show_stack(struct task_struct *task, unsigned long *stack)#endif } -show_trace (stack); +show_trace (stack, loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *stack) +{ +show_stack_loglvl (task, stack,KERN_INFO ); }
Signature · 1 line
2.23.0
PATCH 13/50 h8300: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Yoshinori Sato <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/h8300/kernel/traps.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
arch/h8300/kernel/traps.c +12 -6
@@ -115,7 +115,8 @@ void die(const char *str, struct pt_regs *fp, unsigned long err)static int kstack_depth_to_print =24 ; -void show_stack (struct task_struct *task,unsigned long *esp) +void show_stack_loglvl (struct task_struct *task,unsigned long *esp, +const char *loglvl) {unsigned long *stack, addr;int i;
@@ -125,17 +126,17 @@ void show_stack(struct task_struct *task, unsigned long *esp) stack = esp; -pr_info ("Stack from %08lx:" , (unsigned long )stack); +printk ("%sStack from %08lx:" , loglvl, (unsigned long )stack);for (i =0 ; i < kstack_depth_to_print; i++) {if (((unsigned long )stack & (THREAD_SIZE -1 )) >=THREAD_SIZE -4 )break ;if (i %8 ==0 ) -pr_info (" " ); +printk ("%s " , loglvl);pr_cont (" %08lx" , *stack++); } -pr_info ("\nCall Trace:\n" ); +printk ("%s\nCall Trace:\n" , loglvl); i =0 ; stack = esp;while (((unsigned long )stack & (THREAD_SIZE -1 )) <THREAD_SIZE -4 ) {
@@ -150,10 +151,15 @@ void show_stack(struct task_struct *task, unsigned long *esp)*/ if (check_kernel_text (addr)) {if (i %4 ==0 ) -pr_info (" " ); +printk ("%s " , loglvl);pr_cont (" [<%08lx>]" , addr); i++; } } -pr_info ("\n" ); +printk ("%s\n" , loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *esp) +{ +show_stack_loglvl (task, esp,KERN_INFO ); }
Signature · 1 line
2.23.0
PATCH 14/50 hexagon: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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 good side-effect die() now prints the stacktrace with KERN_EMERG aligned with other messages.
Cc: Brian Cain <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/hexagon/kernel/traps.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
arch/hexagon/kernel/traps.c +17 -14
@@ -79,7 +79,7 @@ static const char *ex_name(int ex) }static void do_show_stack (struct task_struct *task,unsigned long *fp, -unsigned long ip) +unsigned long ip,const char *loglvl) {int kstack_depth_to_print =24 ;unsigned long offset, size;
@@ -93,9 +93,8 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp,if (task ==NULL ) task = current; -printk (KERN_INFO "CPU#%d, %s/%d, Call Trace:\n" , -raw_smp_processor_id (), task->comm, -task_pid_nr (task)); +printk ("%sCPU#%d, %s/%d, Call Trace:\n" , loglvl,raw_smp_processor_id (), + task->comm,task_pid_nr (task));if (fp ==NULL ) {if (task == current) {
@@ -108,7 +107,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp, }if ((((unsigned long ) fp) &0x3 ) || ((unsigned long ) fp <0x1000 )) { -printk (KERN_INFO "-- Corrupt frame pointer %p\n" , fp); +printk ("%s-- Corrupt frame pointer %p\n" , loglvl, fp);return ; }
@@ -125,8 +124,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp, name =kallsyms_lookup (ip, &size, &offset, &modname, tmpstr); -printk (KERN_INFO "[%p] 0x%lx: %s + 0x%lx" , fp, ip, name, - offset); +printk ("%s[%p] 0x%lx: %s + 0x%lx" , loglvl, fp, ip, name, offset);if (((unsigned long ) fp < low) || (high < (unsigned long ) fp))printk (KERN_CONT " (FP out of bounds!)" );if (modname)
@@ -136,8 +134,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp, newfp = (unsigned long *) *fp;if (((unsigned long ) newfp) &0x3 ) { -printk (KERN_INFO "-- Corrupt frame pointer %p\n" , - newfp); +printk ("%s-- Corrupt frame pointer %p\n" , loglvl, newfp);break ; }
@@ -147,7 +144,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp, + 8);if (regs->syscall_nr !=-1 ) { -printk (KERN_INFO "-- trap0 -- syscall_nr: %ld" , +printk ("%s-- trap0 -- syscall_nr: %ld" , loglvl, regs->syscall_nr);printk (KERN_CONT " psp: %lx elr: %lx\n" ,pt_psp (regs),pt_elr (regs));
@@ -155,7 +152,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp, }else {/* really want to see more ... */ kstack_depth_to_print +=6 ; -printk (KERN_INFO "-- %s (0x%lx) badva: %lx\n" , +printk ("%s-- %s (0x%lx) badva: %lx\n" , loglvl,ex_name (pt_cause (regs)),pt_cause (regs),pt_badva (regs)); }
@@ -178,10 +175,16 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp, } } -void show_stack (struct task_struct *task,unsigned long *fp) +void show_stack_loglvl (struct task_struct *task,unsigned long *fp, +const char *loglvl) {/* Saved link reg is one word above FP */ -do_show_stack (task, fp,0 ); +do_show_stack (task, fp,0 , loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *fp) +{ +show_stack_loglvl (task, fp,0 ,KERN_INFO ); }int die (const char *str,struct pt_regs *regs,long err)
@@ -207,7 +210,7 @@ int die(const char *str, struct pt_regs *regs, long err)print_modules ();show_regs (regs); -do_show_stack (current, ®s->r30,pt_elr (regs)); +do_show_stack (current, ®s->r30,pt_elr (regs),KERN_EMERG );bust_spinlocks (0 );add_taint (TAINT_DIE ,LOCKDEP_NOW_UNRELIABLE );
Signature · 1 line
2.23.0
PATCH 15/50 ia64: Pass log level as arg into ia64_do_show_stack()
In reply to Dmitry SafonovCurrently, 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 ia64_do_show_stack() as a preparation to introduce show_stack_loglvl().
Also, make ia64_do_show_stack() static as it's not used outside.
Cc: Fenghua Yu <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/ia64/include/asm/ptrace.h | 1 - arch/ia64/kernel/process.c | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
arch/ia64/include/asm/ptrace.h +0 -1
@@ -114,7 +114,6 @@ static inline long regs_return_value(struct pt_regs *regs)struct task_struct ;/* forward decl */ struct unw_frame_info ;/* forward decl */ -extern void ia64_do_show_stack (struct unw_frame_info *,void *);extern unsigned long ia64_get_user_rbs_end (struct task_struct *,struct pt_regs *,unsigned long *); extern long ia64_peek (struct task_struct *, struct switch_stack *, unsigned long,
arch/ia64/kernel/process.c +7 -6
@@ -64,12 +64,13 @@ EXPORT_SYMBOL(boot_option_idle_override);void (*pm_power_off) (void );EXPORT_SYMBOL (pm_power_off); -void +static void ia64_do_show_stack (struct unw_frame_info *info,void *arg) {unsigned long ip, sp, bsp; +const char *loglvl = arg; -printk ("\nCall Trace:\n" ); +printk ("%s\nCall Trace:\n" , loglvl); do { unw_get_ip(info, &ip); if (ip = 0)
@@ -77,9 +78,9 @@ ia64_do_show_stack (struct unw_frame_info *info, void *arg)unw_get_sp (info, &sp);unw_get_bsp (info, &bsp); -printk (" [<%016lx>] %pS\n" +printk ("%s [<%016lx>] %pS\n" " sp=%016lx bsp=%016lx\n" , - ip, (void *)ip, sp, bsp); + loglvl, ip, (void *)ip, sp, bsp); }while (unw_unwind (info) >=0 ); }
@@ -87,12 +88,12 @@ void show_stack (struct task_struct *task, unsigned long *sp) {if (!task) -unw_init_running (ia64_do_show_stack,NULL ); +unw_init_running (ia64_do_show_stack, (void *)KERN_DEFAULT );else {struct unw_frame_info info;unw_init_from_blocked_task (&info, task); -ia64_do_show_stack (&info,NULL ); +ia64_do_show_stack (&info, (void *)KERN_DEFAULT ); } }
Signature · 1 line
2.23.0
PATCH 16/50 ia64: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Fenghua Yu <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/ia64/kernel/process.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
arch/ia64/kernel/process.c +10 -3
@@ -85,18 +85,25 @@ ia64_do_show_stack (struct unw_frame_info *info, void *arg) }void -show_stack (struct task_struct *task,unsigned long *sp) +show_stack_loglvl (struct task_struct *task,unsigned long *sp, +const char *loglvl) {if (!task) -unw_init_running (ia64_do_show_stack, (void *)KERN_DEFAULT ); +unw_init_running (ia64_do_show_stack, (void *)loglvl);else {struct unw_frame_info info;unw_init_from_blocked_task (&info, task); -ia64_do_show_stack (&info, (void *)KERN_DEFAULT ); +ia64_do_show_stack (&info, (void *)loglvl); } } +void +show_stack (struct task_struct *task,unsigned long *sp) +{ +show_stack_loglvl (task, sp,KERN_DEFAULT ); +} +void show_regs (struct pt_regs *regs) {
Signature · 1 line
2.23.0
PATCH 17/50 m68k: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Geert Uytterhoeven <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/m68k/kernel/traps.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
arch/m68k/kernel/traps.c +11 -5
@@ -811,13 +811,13 @@ asmlinkage void buserr_c(struct frame *fp)static int kstack_depth_to_print =48 ; -void show_trace (unsigned long *stack) +static void show_trace (unsigned long *stack,const char *loglvl) {unsigned long *endstack;unsigned long addr;int i; -pr_info ("Call Trace:" ); +printk ("%sCall Trace:" , loglvl); addr = (unsigned long )stack +THREAD_SIZE -1 ; endstack = (unsigned long *)(addr & -THREAD_SIZE ); i =0 ;
@@ -935,7 +935,8 @@ void show_registers(struct pt_regs *regs)pr_cont ("\n" ); } -void show_stack (struct task_struct *task,unsigned long *stack) +void show_stack_loglvl (struct task_struct *task,unsigned long *stack, +const char *loglvl) {unsigned long *p;unsigned long *endstack;
@@ -949,7 +950,7 @@ void show_stack(struct task_struct *task, unsigned long *stack) } endstack = (unsigned long *)(((unsigned long )stack +THREAD_SIZE -1 ) & -THREAD_SIZE ); -pr_info ("Stack from %08lx:" , (unsigned long )stack); +printk ("%sStack from %08lx:" , loglvl, (unsigned long )stack); p = stack;for (i =0 ; i < kstack_depth_to_print; i++) {if (p +1 > endstack)
@@ -959,7 +960,12 @@ void show_stack(struct task_struct *task, unsigned long *stack)pr_cont (" %08lx" , *p++); }pr_cont ("\n" ); -show_trace (stack); +show_trace (stack, loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *stack) +{ +show_stack_loglvl (task, stack,KERN_INFO ); }/*
Signature · 1 line
2.23.0
PATCH 18/50 microblaze: Add loglvl to microblaze_unwind_inner()
In reply to Dmitry SafonovCurrently, 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 microblaze_unwind_inner() as a preparation for introducing show_stack_loglvl().
Cc: Michal Simek <[email protected]>
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/microblaze/kernel/unwind.c | 35 ++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-)
arch/microblaze/kernel/unwind.c +21 -14
@@ -162,16 +162,18 @@ static void microblaze_unwind_inner(struct task_struct *task,*/ #ifdef CONFIG_MMU static inline void unwind_trap (struct task_struct *task,unsigned long pc, -unsigned long fp,struct stack_trace *trace) +unsigned long fp,struct stack_trace *trace, +const char *loglvl) {/* To be implemented */ }#else static inline void unwind_trap (struct task_struct *task,unsigned long pc, -unsigned long fp,struct stack_trace *trace) +unsigned long fp,struct stack_trace *trace, +const char *loglvl) {const struct pt_regs *regs = (const struct pt_regs *) fp; -microblaze_unwind_inner (task, regs->pc, regs->r1, regs->r15, trace); +microblaze_unwind_inner (task, regs->pc, regs->r1, regs->r15, trace, loglvl); }#endif
@@ -184,11 +186,13 @@ static inline void unwind_trap(struct task_struct *task, unsigned long pc,* the caller's return address. * @trace : Where to store stack backtrace (PC values). * NULL == print backtrace to kernel log +* @loglvl : Used for printk log level if (trace == NULL). */ static void microblaze_unwind_inner (struct task_struct *task,unsigned long pc,unsigned long fp,unsigned long leaf_return, -struct stack_trace *trace) +struct stack_trace *trace, +const char *loglvl) {int ofs =0 ;
@@ -214,11 +218,11 @@ static void microblaze_unwind_inner(struct task_struct *task,const struct pt_regs *regs = (const struct pt_regs *) fp;#endif -pr_info ("HW EXCEPTION\n" ); +printk ("%sHW EXCEPTION\n" , loglvl);#ifndef CONFIG_MMU microblaze_unwind_inner (task, regs->r17 -4 , fp +EX_HANDLER_STACK_SIZ , - regs->r15, trace); + regs->r15, trace, loglvl);#endif return ; }
@@ -228,8 +232,8 @@ static void microblaze_unwind_inner(struct task_struct *task,if ((return_to >= handler->start_addr) && (return_to <= handler->end_addr)) {if (!trace) -pr_info ("%s\n" , handler->trap_name); -unwind_trap (task, pc, fp, trace); +printk ("%s%s\n" , loglvl, handler->trap_name); +unwind_trap (task, pc, fp, trace, loglvl);return ; } }
@@ -248,13 +252,13 @@ static void microblaze_unwind_inner(struct task_struct *task, }else {/* Have we reached userland? */ if (unlikely (pc ==task_pt_regs (task)->pc)) { -pr_info ("[<%p>] PID %lu [%s]\n" , - (void *) pc, +printk ("%s[<%p>] PID %lu [%s]\n" , + loglvl, (void *) pc, (unsigned long ) task->pid, task->comm);break ; }else -print_ip_sym (KERN_INFO , pc); +print_ip_sym (loglvl, pc); }/* Stop when we reach anything not part of the kernel */
@@ -285,11 +289,13 @@ static void microblaze_unwind_inner(struct task_struct *task,*/ void microblaze_unwind (struct task_struct *task,struct stack_trace *trace) { +const char *loglvl =KERN_INFO ; +if (task) {if (task == current) {const struct pt_regs *regs =task_pt_regs (task);microblaze_unwind_inner (task, regs->pc, regs->r1, - regs->r15, trace); + regs->r15, trace, loglvl); }else {struct thread_info *thread_info = (struct thread_info *)(task->stack);
@@ -299,7 +305,8 @@ void microblaze_unwind(struct task_struct *task, struct stack_trace *trace)microblaze_unwind_inner (task, (unsigned long ) &_switch_to, cpu_context->r1, - cpu_context->r15, trace); + cpu_context->r15, + trace, loglvl); } }else {unsigned long pc, fp;
@@ -314,7 +321,7 @@ void microblaze_unwind(struct task_struct *task, struct stack_trace *trace) );/* Since we are not a leaf function, use leaf_return = 0 */ -microblaze_unwind_inner (current, pc, fp,0 , trace); +microblaze_unwind_inner (current, pc, fp,0 , trace, loglvl); } }
Signature · 1 line
2.23.0
Michal Simek
maintainerRe: [PATCH 18/50] microblaze: Add loglvl to microblaze_unwind_inner()
Quoted 136 lines · Dmitry Safonov
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_loglevelwhile 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 theprintk()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
microblaze_unwind_inner()as a preparation for introducingshow_stack_loglvl().Cc: Michal Simek <[email protected]>
[1]: https://lore.kernel.org/lkml/[email protected]/T/#uSigned-off-by Dmitry Safonov <[email protected]>--- arch/microblaze/kernel/unwind.c | 35 ++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-)arch/microblaze/kernel/unwind.c +20
-13@@ -162,16 +162,18 @@ static void microblaze_unwind_inner(struct task_struct *task,*/ #ifdef CONFIG_MMU static inline void unwind_trap (struct task_struct *task,unsigned long pc, -unsigned long fp,struct stack_trace *trace) +unsigned long fp,struct stack_trace *trace, +const char *loglvl) {/* To be implemented */ }#else static inline void unwind_trap (struct task_struct *task,unsigned long pc, -unsigned long fp,struct stack_trace *trace) +unsigned long fp,struct stack_trace *trace, +const char *loglvl) {const struct pt_regs *regs = (const struct pt_regs *) fp; -microblaze_unwind_inner (task, regs->pc, regs->r1, regs->r15, trace); +microblaze_unwind_inner (task, regs->pc, regs->r1, regs->r15, trace, loglvl); }#endif @@ -184,11 +186,13 @@ static inline void unwind_trap(struct task_struct *task, unsigned long pc,* the caller's return address. * @trace : Where to store stack backtrace (PC values). * NULL == print backtrace to kernel log +* @loglvl : Used for printk log level if (trace == NULL). */ static void microblaze_unwind_inner (struct task_struct *task,unsigned long pc,unsigned long fp,unsigned long leaf_return, -struct stack_trace *trace) +struct stack_trace *trace, +const char *loglvl) {int ofs =0 ;@@ -214,11 +218,11 @@ static void microblaze_unwind_inner(struct task_struct *task,const struct pt_regs *regs = (const struct pt_regs *) fp;#endif -pr_info ("HW EXCEPTION\n" ); +printk ("%sHW EXCEPTION\n" , loglvl);#ifndef CONFIG_MMU microblaze_unwind_inner (task, regs->r17 -4 , fp +EX_HANDLER_STACK_SIZ , - regs->r15, trace); + regs->r15, trace, loglvl);#endif return ; }@@ -228,8 +232,8 @@ static void microblaze_unwind_inner(struct task_struct *task,if ((return_to >= handler->start_addr) && (return_to <= handler->end_addr)) {if (!trace) -pr_info ("%s\n" , handler->trap_name); -unwind_trap (task, pc, fp, trace); +printk ("%s%s\n" , loglvl, handler->trap_name); +unwind_trap (task, pc, fp, trace, loglvl);return ; } }@@ -248,13 +252,13 @@ static void microblaze_unwind_inner(struct task_struct *task, }else {/* Have we reached userland? */ if (unlikely (pc ==task_pt_regs (task)->pc)) { -pr_info ("[<%p>] PID %lu [%s]\n" , - (void *) pc, +printk ("%s[<%p>] PID %lu [%s]\n" , + loglvl, (void *) pc, (unsigned long ) task->pid, task->comm);break ; }else -print_ip_sym (KERN_INFO , pc); +print_ip_sym (loglvl, pc); }/* Stop when we reach anything not part of the kernel */ @@ -285,11 +289,13 @@ static void microblaze_unwind_inner(struct task_struct *task,*/ void microblaze_unwind (struct task_struct *task,struct stack_trace *trace) { +const char *loglvl =KERN_INFO ; +if (task) {if (task == current) {const struct pt_regs *regs =task_pt_regs (task);microblaze_unwind_inner (task, regs->pc, regs->r1, - regs->r15, trace); + regs->r15, trace, loglvl); }else {struct thread_info *thread_info = (struct thread_info *)(task->stack);@@ -299,7 +305,8 @@ void microblaze_unwind(struct task_struct *task, struct stack_trace *trace)microblaze_unwind_inner (task, (unsigned long ) &_switch_to, cpu_context->r1, - cpu_context->r15, trace); + cpu_context->r15, + trace, loglvl); } }else {unsigned long pc, fp;
arch/microblaze/kernel/unwind.c void microblaze_unwind(struct task_struct *task, struct stack_trace *trace) · line 327
Quoted 8 lines
arch/microblaze/kernel/unwind.c +1
-1@@ -314,7 +321,7 @@ void microblaze_unwind(struct task_struct *task, struct stack_trace *trace) );/* Since we are not a leaf function, use leaf_return = 0 */ -microblaze_unwind_inner (current, pc, fp,0 , trace); +microblaze_unwind_inner (current, pc, fp,0 , trace, loglvl); } }
I can't see any reaction from bots but you forget to update function declaration there which is causing build issue.
here is c&p patch.
Other then this it looks good to me.
(quoted diff) +0 -0
b/arch/microblaze/kernel/unwind.c
index 74dded96c10a..778a761af0a7 100644
arch/microblaze/kernel/unwind.c +0 -0
@@ -154,7 +154,8 @@ static int lookup_prev_stack_frame(unsigned long fp,
unsigned long pc,
static void microblaze_unwind_inner(struct task_struct *task,
unsigned long pc, unsigned long fp, unsigned long leaf_return,
- struct stack_trace *trace); + struct stack_trace *trace, + const char *loglvl);
/**
* unwind_trap - Unwind through a system trap, that stored previous state
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
kbuild test robot
build botRe: [PATCH 18/50] microblaze: Add loglvl to microblaze_unwind_inner()
In reply to Dmitry SafonovThank you for the patch! Yet something to improve:
Hi Dmitry,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.4-rc6 next-20191107]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Dmitry-Safonov/kallsyms-printk-Add-loglvl-to-print_ip_sym/20191108-124037 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 847120f859cc45e074204f4cf33c8df069306eb2 config: microblaze-nommu_defconfig (attached as .config) compiler: microblaze-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=microblaze
If you fix the issue, kindly add following tag
All error/warnings (new ones prefixed by >>):
arch/microblaze/kernel/unwind.c: In function 'unwind_trap':
>> arch/microblaze/kernel/unwind.c:176:2: error: too many arguments to function 'microblaze_unwind_inner'
microblaze_unwind_inner(task, regs->pc, regs->r1, regs->r15, trace, loglvl);
^~~~~~~~~~~~~~~~~~~~~~~
arch/microblaze/kernel/unwind.c:154:13: note: declared here
static void microblaze_unwind_inner(struct task_struct *task,
^~~~~~~~~~~~~~~~~~~~~~~
arch/microblaze/kernel/unwind.c: At top level:
>> arch/microblaze/kernel/unwind.c:191:13: error: conflicting types for 'microblaze_unwind_inner'
static void microblaze_unwind_inner(struct task_struct *task,
^~~~~~~~~~~~~~~~~~~~~~~
arch/microblaze/kernel/unwind.c:154:13: note: previous declaration of 'microblaze_unwind_inner' was here
static void microblaze_unwind_inner(struct task_struct *task,
^~~~~~~~~~~~~~~~~~~~~~~
>> arch/microblaze/kernel/unwind.c:154:13: warning: 'microblaze_unwind_inner' used but never definedvim +/microblaze_unwind_inner +176 arch/microblaze/kernel/unwind.c
153
> 154 static void microblaze_unwind_inner(struct task_struct *task,
155 unsigned long pc, unsigned long fp,
156 unsigned long leaf_return,
157 struct stack_trace *trace);
158
159 /**
160 * unwind_trap - Unwind through a system trap, that stored previous state
161 * on the stack.
162 */
163 #ifdef CONFIG_MMU
164 static inline void unwind_trap(struct task_struct *task, unsigned long pc,
165 unsigned long fp, struct stack_trace *trace,
166 const char *loglvl)
167 {
168 /* To be implemented */
169 }
170 #else
171 static inline void unwind_trap(struct task_struct *task, unsigned long pc,
172 unsigned long fp, struct stack_trace *trace,
173 const char *loglvl)
174 {
175 const struct pt_regs *regs = (const struct pt_regs *) fp;
> 176 microblaze_unwind_inner(task, regs->pc, regs->r1, regs->r15, trace, loglvl);
177 }
178 #endif
179
180 /**
181 * microblaze_unwind_inner - Unwind the stack from the specified point
182 * @task : Task whose stack we are to unwind (may be NULL)
183 * @pc : Program counter from which we start unwinding
184 * @fp : Frame (stack) pointer from which we start unwinding
185 * @leaf_return : Value of r15 at pc. If the function is a leaf, this is
186 * the caller's return address.
187 * @trace : Where to store stack backtrace (PC values).
188 * NULL == print backtrace to kernel log
189 * @loglvl : Used for printk log level if (trace == NULL).
190 */
> 191 static void microblaze_unwind_inner(struct task_struct *task,
192 unsigned long pc, unsigned long fp,
193 unsigned long leaf_return,
194 struct stack_trace *trace,
195 const char *loglvl) 196 {
197 int ofs = 0;
198
199 pr_debug(" Unwinding with PC=%p, FP=%p\n", (void *)pc, (void *)fp);
200 if (!pc || !fp || (pc & 3) || (fp & 3)) {
201 pr_debug(" Invalid state for unwind, aborting\n");
202 return;
203 }
204 for (; pc != 0;) {
205 unsigned long next_fp, next_pc = 0;
206 unsigned long return_to = pc + 2 * sizeof(unsigned long);
207 const struct trap_handler_info *handler =
208 µblaze_trap_handlers;
209
210 /* Is previous function the HW exception handler? */
211 if ((return_to >= (unsigned long)&_hw_exception_handler)
212 &&(return_to < (unsigned long)&ex_handler_unhandled)) {
213 /*
214 * HW exception handler doesn't save all registers,
215 * so we open-code a special case of unwind_trap()
216 */
217 #ifndef CONFIG_MMU
218 const struct pt_regs *regs =
219 (const struct pt_regs *) fp;
220 #endif
221 printk("%sHW EXCEPTION\n", loglvl);
222 #ifndef CONFIG_MMU
223 microblaze_unwind_inner(task, regs->r17 - 4,
224 fp + EX_HANDLER_STACK_SIZ,
225 regs->r15, trace, loglvl);
226 #endif
227 return;
228 }
229
230 /* Is previous function a trap handler? */
231 for (; handler->start_addr; ++handler) {
232 if ((return_to >= handler->start_addr)
233 && (return_to <= handler->end_addr)) {
234 if (!trace)
235 printk("%s%s\n", loglvl, handler->trap_name);
236 unwind_trap(task, pc, fp, trace, loglvl);
237 return;
238 }
239 }
240 pc -= ofs;
241
242 if (trace) {
243 #ifdef CONFIG_STACKTRACE
244 if (trace->skip > 0)
245 trace->skip--;
246 else
247 trace->entries[trace->nr_entries++] = pc;
248
249 if (trace->nr_entries >= trace->max_entries)
250 break;
251 #endif
252 } else {
253 /* Have we reached userland? */
254 if (unlikely(pc == task_pt_regs(task)->pc)) {
255 printk("%s[<%p>] PID %lu [%s]\n",
256 loglvl, (void *) pc,
257 (unsigned long) task->pid,
258 task->comm);
259 break;
260 } else
261 print_ip_sym(loglvl, pc);
262 }
263
264 /* Stop when we reach anything not part of the kernel */
265 if (!kernel_text_address(pc))
266 break;
267
268 if (lookup_prev_stack_frame(fp, pc, leaf_return, &next_fp,
269 &next_pc) == 0) {
270 ofs = sizeof(unsigned long);
271 pc = next_pc & ~3;
272 fp = next_fp;
273 leaf_return = 0;
274 } else {
275 pr_debug(" Failed to find previous stack frame\n");
276 break;
277 }
278
279 pr_debug(" Next PC=%p, next FP=%p\n",
280 (void *)next_pc, (void *)next_fp);
281 }
282 }
283
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
PATCH 19/50 microblaze: Add loglvl to microblaze_unwind()
In reply to Dmitry SafonovCurrently, 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 parameter to microblaze_unwind() as a preparation to add show_stack_loglvl().
Cc: Michal Simek <[email protected]>
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/microblaze/include/asm/unwind.h | 3 ++- arch/microblaze/kernel/stacktrace.c | 4 ++-- arch/microblaze/kernel/traps.c | 2 +- arch/microblaze/kernel/unwind.c | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-)
arch/microblaze/include/asm/unwind.h +2 -1
@@ -23,7 +23,8 @@ extern struct trap_handler_info microblaze_trap_handlers;extern const char _hw_exception_handler;extern const char ex_handler_unhandled; -void microblaze_unwind (struct task_struct *task,struct stack_trace *trace); +void microblaze_unwind (struct task_struct *task,struct stack_trace *trace, +const char *loglvl);#endif /* __MICROBLAZE_UNWIND_H */
arch/microblaze/kernel/stacktrace.c +2 -2
@@ -20,12 +20,12 @@ void save_stack_trace(struct stack_trace *trace) {/* Exclude our helper functions from the trace*/ trace->skip +=2 ; -microblaze_unwind (NULL , trace); +microblaze_unwind (NULL , trace,"" ); }EXPORT_SYMBOL_GPL (save_stack_trace);void save_stack_trace_tsk (struct task_struct *tsk,struct stack_trace *trace) { -microblaze_unwind (tsk, trace); +microblaze_unwind (tsk, trace,"" ); }EXPORT_SYMBOL_GPL (save_stack_trace_tsk);
arch/microblaze/kernel/traps.c +1 -1
@@ -68,7 +68,7 @@ void show_stack(struct task_struct *task, unsigned long *sp)print_hex_dump (KERN_INFO ,"" ,DUMP_PREFIX_ADDRESS ,32 ,4 , (void *)fp, words_to_show <<2 ,0 );pr_info ("\n\nCall Trace:\n" ); -microblaze_unwind (task,NULL ); +microblaze_unwind (task,NULL ,KERN_INFO );pr_info ("\n" );if (!task)
arch/microblaze/kernel/unwind.c +3 -3
@@ -286,11 +286,11 @@ static void microblaze_unwind_inner(struct task_struct *task,* @task : Task whose stack we are to unwind (NULL == current) * @trace : Where to store stack backtrace (PC values). * NULL == print backtrace to kernel log +* @loglvl : Used for printk log level if (trace == NULL). */ -void microblaze_unwind (struct task_struct *task,struct stack_trace *trace) +void microblaze_unwind (struct task_struct *task,struct stack_trace *trace, +const char *loglvl) { -const char *loglvl =KERN_INFO ; -if (task) {if (task == current) {const struct pt_regs *regs =task_pt_regs (task);
Signature · 1 line
2.23.0
PATCH 20/50 microblaze: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Michal Simek <[email protected]>
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/microblaze/kernel/traps.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
arch/microblaze/kernel/traps.c +12 -6
@@ -31,7 +31,8 @@ static int __init kstack_setup(char *s) }__setup ("kstack=" , kstack_setup); -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 words_to_show;u32 fp = (u32 ) sp;
@@ -50,7 +51,7 @@ void show_stack(struct task_struct *task, unsigned long *sp)if (kstack_depth_to_print && (words_to_show > kstack_depth_to_print)) words_to_show = kstack_depth_to_print; -pr_info ("Kernel Stack:\n" ); +printk ("%sKernel Stack:\n" , loglvl);/* * Make the first line an 'odd' size if necessary to get
@@ -65,14 +66,19 @@ void show_stack(struct task_struct *task, unsigned long *sp) words_to_show -= line1_words; } } -print_hex_dump (KERN_INFO ,"" ,DUMP_PREFIX_ADDRESS ,32 ,4 , (void *)fp, +print_hex_dump (loglvl,"" ,DUMP_PREFIX_ADDRESS ,32 ,4 , (void *)fp, words_to_show <<2 ,0 ); -pr_info ("\n\nCall Trace:\n" ); -microblaze_unwind (task,NULL ,KERN_INFO ); -pr_info ("\n" ); +printk ("%s\n\nCall Trace:\n" , loglvl); +microblaze_unwind (task,NULL , loglvl); +printk ("%s\n" , loglvl);if (!task) task = current;debug_show_held_locks (task); } + +void show_stack (struct task_struct *task,unsigned long *sp) +{ +show_stack_loglvl (task, sp,KERN_INFO ); +}
Signature · 1 line
2.23.0
PATCH 21/50 mips: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: James Hogan <[email protected]>
Cc: Paul Burton <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/mips/kernel/traps.c | 41 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-)
arch/mips/kernel/traps.c +24 -17
@@ -106,26 +106,26 @@ void (*board_bind_eic_interrupt)(int irq, int regset);void (*board_ebase_setup)(void );void (*board_cache_error_setup)(void ); -static void show_raw_backtrace (unsigned long reg29) +static void show_raw_backtrace (unsigned long reg29,const char *loglvl) {unsigned long *sp = (unsigned long *)(reg29 & ~3 );unsigned long addr; -printk ("Call Trace:" ); +printk ("%sCall Trace:" , loglvl);#ifdef CONFIG_KALLSYMS -printk ("\n" ); +printk ("%s\n" , loglvl);#endif while (!kstack_end (sp)) {unsigned long __user *p = (unsigned long __user *)(unsigned long )sp++;if (__get_user (addr, p)) { -printk (" (Bad stack address)" ); +printk ("%s (Bad stack address)" , loglvl);break ; }if (__kernel_text_address (addr)) -print_ip_sym (KERN_DEFAULT , addr); +print_ip_sym (loglvl, addr); } -printk ("\n" ); +printk ("%s\n" , loglvl); }#ifdef CONFIG_KALLSYMS
@@ -138,7 +138,8 @@ static int __init set_raw_show_trace(char *str)__setup ("raw_show_trace" , set_raw_show_trace);#endif -static void show_backtrace (struct task_struct *task,const struct pt_regs *regs) +static void show_backtrace (struct task_struct *task,const struct pt_regs *regs, +const char *loglvl) {unsigned long sp = regs->regs[29 ];unsigned long ra = regs->regs[31 ];
@@ -148,12 +149,12 @@ static void show_backtrace(struct task_struct *task, const struct pt_regs *regs) task = current;if (raw_show_trace ||user_mode (regs) || !__kernel_text_address (pc)) { -show_raw_backtrace (sp); +show_raw_backtrace (sp, loglvl);return ; } -printk ("Call Trace:\n" ); +printk ("%sCall Trace:\n" , loglvl);do { -print_ip_sym (KERN_DEFAULT , pc); +print_ip_sym (loglvl, pc); pc =unwind_stack (task, &sp, pc, &ra); }while (pc);pr_cont ("\n" );
@@ -164,19 +165,19 @@ static void show_backtrace(struct task_struct *task, const struct pt_regs *regs)* with at least a bit of error checking ... */ static void show_stacktrace (struct task_struct *task, -const struct pt_regs *regs) +const struct pt_regs *regs,const char *loglvl) {const int field =2 *sizeof (unsigned long );long stackdata;int i;unsigned long __user *sp = (unsigned long __user *)regs->regs[29 ]; -printk ("Stack :" ); +printk ("%sStack :" , loglvl); i =0 ;while ((unsigned long ) sp & (PAGE_SIZE -1 )) {if (i && ((i % (64 / field)) ==0 )) {pr_cont ("\n" ); -printk (" " ); +printk ("%s " , loglvl); }if (i >39 ) {pr_cont (" ..." );
@@ -192,10 +193,11 @@ static void show_stacktrace(struct task_struct *task, i++; }pr_cont ("\n" ); -show_backtrace (task, regs); +show_backtrace (task, regs, loglvl); } -void show_stack (struct task_struct *task,unsigned long *sp) +void show_stack_loglvl (struct task_struct *task,unsigned long *sp, +const char *loglvl) {struct pt_regs regs;mm_segment_t old_fs =get_fs ();
@@ -224,10 +226,15 @@ void show_stack(struct task_struct *task, unsigned long *sp)* the stack in the kernel (not user) address space. */ set_fs (KERNEL_DS ); -show_stacktrace (task, ®s); +show_stacktrace (task, ®s, loglvl);set_fs (old_fs); } +void show_stack (struct task_struct *task,unsigned long *sp) +{ + show_stack_loglvl(task, sp, KERN_DEFAULT) +} +static void show_code (unsigned int __user *pc) {long i;
@@ -376,7 +383,7 @@ void show_registers(struct pt_regs *regs)if (!user_mode (regs))/* Necessary for getting the correct stack content */ set_fs (KERNEL_DS ); -show_stacktrace (current, regs); +show_stacktrace (current, regs,KERN_DEFAULT );show_code ((unsigned int __user *) regs->cp0_epc);printk ("\n" );set_fs (old_fs);
Signature · 1 line
2.23.0
PATCH 22/50 nds32: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Greentime Hu <[email protected]>
Cc: Vincent Chen <[email protected]>
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/nds32/kernel/traps.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
arch/nds32/kernel/traps.c +14 -7
@@ -97,18 +97,19 @@ static void dump_instr(struct pt_regs *regs) }#define LOOP_TIMES (100) -static void __dump (struct task_struct *tsk,unsigned long *base_reg) +static void __dump (struct task_struct *tsk,unsigned long *base_reg, +const char *loglvl) {unsigned long ret_addr;int cnt =LOOP_TIMES , graph =0 ; -pr_emerg ("Call Trace:\n" ); +printk ("%sCall Trace:\n" , loglvl);if (!IS_ENABLED (CONFIG_FRAME_POINTER )) {while (!kstack_end (base_reg)) { ret_addr = *base_reg++;if (__kernel_text_address (ret_addr)) { ret_addr =ftrace_graph_ret_addr ( tsk, &graph, ret_addr,NULL ); -print_ip_sym (KERN_EMERG , ret_addr); +print_ip_sym (loglvl, ret_addr); }if (--cnt <0 )break ;
@@ -124,17 +125,18 @@ static void __dump(struct task_struct *tsk, unsigned long *base_reg) ret_addr =ftrace_graph_ret_addr ( tsk, &graph, ret_addr,NULL ); -print_ip_sym (KERN_EMERG , ret_addr); +print_ip_sym (loglvl, ret_addr); }if (--cnt <0 )break ; base_reg = (unsigned long *)next_fp; } } -pr_emerg ("\n" ); +printk ("%s\n" , 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) {unsigned long *base_reg;
@@ -151,10 +153,15 @@ void show_stack(struct task_struct *tsk, unsigned long *sp)else __asm__ __volatile__("\tori\t%0, $fp, #0\n" :"=r" (base_reg)); } -__dump (tsk, base_reg); +__dump (tsk, base_reg, loglvl);barrier (); } +void show_stack (struct task_struct *tsk,unsigned long *sp) +{ +show_stack_loglvl (tsk, sp,KERN_EMERG ); +} +DEFINE_SPINLOCK (die_lock);/*
Signature · 1 line
2.23.0
PATCH 23/50 nios2: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Ley Foon Tan <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/nios2/kernel/traps.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
arch/nios2/kernel/traps.c +15 -8
@@ -52,12 +52,14 @@ void _exception(int signo, struct pt_regs *regs, int code, unsigned long addr) }/* -* The show_stack is an external API which we do not use ourselves. +* The show_stack(), show_stack_loglvl() are external API +* which we do not use ourselves. */ int kstack_depth_to_print =48 ; -void show_stack (struct task_struct *task,unsigned long *stack) +void show_stack_loglvl (struct task_struct *task,unsigned long *stack, +const char *loglvl) {unsigned long *endstack, addr;int i;
@@ -72,16 +74,16 @@ void show_stack(struct task_struct *task, unsigned long *stack) addr = (unsigned long ) stack; endstack = (unsigned long *)PAGE_ALIGN (addr); -pr_emerg ("Stack from %08lx:" , (unsigned long )stack); +printk ("%sStack from %08lx:" , loglvl, (unsigned long )stack);for (i =0 ; i < kstack_depth_to_print; i++) {if (stack +1 > endstack)break ;if (i %8 ==0 ) -pr_emerg ("\n " ); -pr_emerg (" %08lx" , *stack++); +printk ("%s\n " , loglvl); +printk ("%s %08lx" , loglvl, *stack++); } -pr_emerg ("\nCall Trace:" ); +printk ("%s\nCall Trace:" , loglvl); i =0 ;while (stack +1 <= endstack) { addr = *stack++;
@@ -97,11 +99,16 @@ void show_stack(struct task_struct *task, unsigned long *stack) (addr <= (unsigned long) _etext))) {if (i %4 ==0 )pr_emerg ("\n " ); -pr_emerg (" [<%08lx>]" , addr); +printk ("%s [<%08lx>]" , loglvl, addr); i++; } } -pr_emerg ("\n" ); +printk ("%s\n" , loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *stack) +{ +show_stack_loglvl (task, stack,KERN_EMERG ); }void __init trap_init (void )
Signature · 1 line
2.23.0
PATCH 24/50 openrisc: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Jonas Bonn <[email protected]>
Cc: Stafford Horne <[email protected]>
Cc: Stefan Kristiansson <[email protected]>
Cc: openrisc at lists.librecores.org
[1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima at arista.com/T/#u
--- arch/openrisc/kernel/traps.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
arch/openrisc/kernel/traps.c +12 -4
@@ -41,18 +41,26 @@ unsigned long __user *lwa_addr;void print_trace (void *data,unsigned long addr,int reliable) { -pr_emerg ("[<%p>] %s%pS\n" , (void *) addr, reliable ?"" :"? " , +const char *loglvl = data; + +printk ("%s[<%p>] %s%pS\n" , loglvl, (void *) addr, reliable ?"" :"? " , (void *) addr); }/* displays a short stack trace */ -void show_stack (struct task_struct *task,unsigned long *esp) +void show_stack_loglvl (struct task_struct *task,unsigned long *esp, +const char *loglvl) {if (esp ==NULL ) esp = (unsigned long *)&esp; -pr_emerg ("Call trace:\n" ); -unwind_stack (NULL , esp, print_trace); +printk ("%sCall trace:\n" , loglvl); +unwind_stack ((void *)loglvl, esp, print_trace); +} + +void show_stack (struct task_struct *task,unsigned long *esp) +{ +show_stack_loglvl (task, esp,KERN_EMERG ); }void show_trace_task (struct task_struct *tsk)
Signature · 1 line
2.23.0
PATCH 25/50 parisc: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Helge Deller <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/parisc/kernel/traps.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
arch/parisc/kernel/traps.c +17 -11
@@ -49,7 +49,7 @@#include "../math-emu/math-emu.h" /* for handle_fpe() */ static void parisc_show_stack (struct task_struct *task, -struct pt_regs *regs); +struct pt_regs *regs,const char *loglvl);static int printbinary (char *buf,unsigned long x,int nbits) {
@@ -155,7 +155,7 @@ void show_regs(struct pt_regs *regs)printk ("%s IAOQ[1]: %pS\n" , level, (void *) regs->iaoq[1 ]);printk ("%s RP(r2): %pS\n" , level, (void *) regs->gr[2 ]); -parisc_show_stack (current, regs); +parisc_show_stack (current, regs,KERN_DEFAULT ); } }
@@ -170,37 +170,43 @@ static DEFINE_RATELIMIT_STATE(_hppa_rs, } -static void do_show_stack (struct unwind_frame_info *info) +static void do_show_stack (struct unwind_frame_info *info,const char *loglvl) {int i =1 ; -printk (KERN_CRIT "Backtrace:\n" ); +printk ("%sBacktrace:\n" , loglvl);while (i <=MAX_UNWIND_ENTRIES ) {if (unwind_once (info) <0 || info->ip ==0 )break ;if (__kernel_text_address (info->ip)) { -printk (KERN_CRIT " [<" RFMT ">] %pS\n" , - info->ip, (void *) info->ip); +printk ("%s [<" RFMT ">] %pS\n" , + loglvl, info->ip, (void *) info->ip); i++; } } -printk (KERN_CRIT "\n" ); +printk ("%s\n" , loglvl); }static void parisc_show_stack (struct task_struct *task, -struct pt_regs *regs) +struct pt_regs *regs,const char *loglvl) {struct unwind_frame_info info;unwind_frame_init_task (&info, task, regs); -do_show_stack (&info); +do_show_stack (&info, loglvl); +} + +void show_stack_loglvl (struct task_struct *t,unsigned long *sp, +const char *loglvl) +{ +parisc_show_stack (t,NULL , loglvl); }void show_stack (struct task_struct *t,unsigned long *sp) { -parisc_show_stack (t,NULL ); + show_stack_loglvl(t, sp, KERN_CRIT) }int is_valid_bugaddr (unsigned long iaoq)
@@ -446,7 +452,7 @@ void parisc_terminate(char *msg, struct pt_regs *regs, int code, unsigned long o/* show_stack(NULL, (unsigned long *)regs->gr[30]); */ struct unwind_frame_info info;unwind_frame_init (&info, current, regs); -do_show_stack (&info); +do_show_stack (&info,KERN_CRIT ); }printk ("\n" );
Signature · 1 line
2.23.0
PATCH 26/50 powerpc: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/powerpc/kernel/process.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
arch/powerpc/kernel/process.c +13 -5
@@ -2028,7 +2028,8 @@ unsigned long get_wchan(struct task_struct *p)static int kstack_depth_to_print =CONFIG_PRINT_STACK_DEPTH ; -void show_stack (struct task_struct *tsk,unsigned long *stack) +void show_stack_loglvl (struct task_struct *tsk,unsigned long *stack, +const char *loglvl) {unsigned long sp, ip, lr, newsp;int count =0 ;
@@ -2053,7 +2054,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack) } lr =0 ; -printk ("Call Trace:\n" ); +printk ("%sCall Trace:\n" , loglvl); do { if (!validate_sp(sp, tsk, STACK_FRAME_OVERHEAD)) break;
@@ -2062,7 +2063,8 @@ void show_stack(struct task_struct *tsk, unsigned long *stack) newsp = stack[0 ]; ip = stack[STACK_FRAME_LR_SAVE ];if (!firstframe || ip != lr) { -printk ("[" REG "] [" REG "] %pS" , sp, ip, (void *)ip); +printk ("%s[" REG "] [" REG "] %pS" , + loglvl, sp, ip, (void *)ip);#ifdef CONFIG_FUNCTION_GRAPH_TRACER ret_addr =ftrace_graph_ret_addr (current, &ftrace_idx, ip, stack);
@@ -2084,8 +2086,9 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)struct pt_regs *regs = (struct pt_regs *) (sp +STACK_FRAME_OVERHEAD ); lr = regs->link; -printk ("--- interrupt: %lx at %pS\n LR = %pS\n" , - regs->trap, (void *)regs->nip, (void *)lr); +printk ("%s--- interrupt: %lx at %pS\n LR = %pS\n" , + loglvl, regs->trap, + (void *)regs->nip, (void *)lr); firstframe =1 ; }
@@ -2095,6 +2098,11 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)put_task_stack (tsk); } +void show_stack (struct task_struct *tsk,unsigned long *stack) +{ +show_stack_loglvl (tsk, stack,KERN_DEFAULT ); +} +#ifdef CONFIG_PPC64 /* Called with hard IRQs off */ void notrace __ppc64_runlatch_on(void)
Signature · 1 line
2.23.0
Re: [PATCH 26/50] powerpc: Add show_stack_loglvl()
Quoted 4 lines · Dmitry Safonov
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).
Yes, I've had bug reports where the stacktrace is missing, which is annoying. Thanks for trying to fix the problem.
Quoted 19 lines
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_loglevelwhile 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 theprintk()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 substituteshow_stack().Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
Quoted 4 lines
Signed-off-by Dmitry Safonov <[email protected]>--- arch/powerpc/kernel/process.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
This looks good to me.
cheers
Quoted 59 lines
arch/powerpc/kernel/process.c +13
-5@@ -2028,7 +2028,8 @@ unsigned long get_wchan(struct task_struct *p)static int kstack_depth_to_print =CONFIG_PRINT_STACK_DEPTH ; -void show_stack (struct task_struct *tsk,unsigned long *stack) +void show_stack_loglvl (struct task_struct *tsk,unsigned long *stack, +const char *loglvl) {unsigned long sp, ip, lr, newsp;int count =0 ;@@ -2053,7 +2054,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack) } lr =0 ; -printk ("Call Trace:\n" ); +printk ("%sCall Trace:\n" , loglvl); do { if (!validate_sp(sp, tsk, STACK_FRAME_OVERHEAD)) break;@@ -2062,7 +2063,8 @@ void show_stack(struct task_struct *tsk, unsigned long *stack) newsp = stack[0 ]; ip = stack[STACK_FRAME_LR_SAVE ];if (!firstframe || ip != lr) { -printk ("[" REG "] [" REG "] %pS" , sp, ip, (void *)ip); +printk ("%s[" REG "] [" REG "] %pS" , + loglvl, sp, ip, (void *)ip);#ifdef CONFIG_FUNCTION_GRAPH_TRACER ret_addr =ftrace_graph_ret_addr (current, &ftrace_idx, ip, stack);@@ -2084,8 +2086,9 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)struct pt_regs *regs = (struct pt_regs *) (sp +STACK_FRAME_OVERHEAD ); lr = regs->link; -printk ("--- interrupt: %lx at %pS\n LR = %pS\n" , - regs->trap, (void *)regs->nip, (void *)lr); +printk ("%s--- interrupt: %lx at %pS\n LR = %pS\n" , + loglvl, regs->trap, + (void *)regs->nip, (void *)lr); firstframe =1 ; }@@ -2095,6 +2098,11 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)put_task_stack (tsk); } +void show_stack (struct task_struct *tsk,unsigned long *stack) +{ +show_stack_loglvl (tsk, stack,KERN_DEFAULT ); +} +#ifdef CONFIG_PPC64 /* Called with hard IRQs off */ void notrace __ppc64_runlatch_on(void)Signature · 1 line
2.23.0
Re: [PATCH 26/50] powerpc: Add show_stack_loglvl()
Quoted 33 lines · Michael Ellerman
Quoted 4 lines · Dmitry Safonov
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).Yes, I've had bug reports where the stacktrace is missing, which is annoying. Thanks for trying to fix the problem.
Quoted 19 lines
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_loglevelwhile 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 theprintk()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 substituteshow_stack().Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#uQuoted 4 lines
Signed-off-by Dmitry Safonov <[email protected]>--- arch/powerpc/kernel/process.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
Quoted 3 lines
This looks good to me.
Thanks for the review and time!
Signature · 1 line
Dmitry
PATCH 27/50 riscv: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Albert Ou <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/riscv/kernel/stacktrace.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
arch/riscv/kernel/stacktrace.c +10 -3
@@ -98,16 +98,23 @@ static void notrace walk_stackframe(struct task_struct *task,static bool print_trace_address (unsigned long pc,void *arg) { -print_ip_sym (KERN_DEFAULT , pc); +const char *loglvl = arg; + +print_ip_sym (loglvl, pc);return false; } -void show_stack (struct task_struct *task,unsigned long *sp) +void show_stack_loglvl (struct task_struct *task,unsigned long *sp, +const char *loglvl) {pr_cont ("Call Trace:\n" ); -walk_stackframe (task,NULL , print_trace_address,NULL ); +walk_stackframe (task,NULL , print_trace_address, (void *)loglvl); } +void show_stack (struct task_struct *task,unsigned long *sp) +{ +show_stack_loglvl (task, sp,KERN_DEFAULT ); +}static bool save_wchan (unsigned long pc,void *arg) {
Signature · 1 line
2.23.0
PATCH 28/50 s390: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Christian Borntraeger <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/s390/kernel/dumpstack.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
arch/s390/kernel/dumpstack.c +11 -5
@@ -123,20 +123,26 @@ int get_stack_info(unsigned long sp, struct task_struct *task,return -EINVAL ; } -void show_stack (struct task_struct *task,unsigned long *stack) +void show_stack_loglvl (struct task_struct *task,unsigned long *stack, +const char *loglvl) {struct unwind_state state; -printk ("Call Trace:\n" ); +printk ("%sCall Trace:\n" , loglvl);if (!task) task = current;unwind_for_each_frame (&state, task,NULL , (unsigned long ) stack) -printk (state.reliable ?" [<%016lx>] %pSR \n" : -"([<%016lx>] %pSR)\n" , - state.ip, (void *) state.ip); +printk (state.reliable ?"%s [<%016lx>] %pSR \n" : +"%s([<%016lx>] %pSR)\n" , + loglvl, state.ip, (void *) state.ip);debug_show_held_locks (task ? : current); } +void show_stack (struct task_struct *task,unsigned long *stack) +{ +show_stack_loglvl (task, stack,KERN_DEFAULT ); +} +static void show_last_breaking_event (struct pt_regs *regs) {printk ("Last Breaking-Event-Address:\n" );
Signature · 1 line
2.23.0
PATCH 29/50 sh: Add loglvl to dump_mem()
In reply to Dmitry SafonovCurrently, 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().
Cc: Rich Felker <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/sh/include/asm/kdebug.h | 3 ++- arch/sh/kernel/dumpstack.c | 17 +++++++++-------- arch/sh/kernel/traps.c | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-)
arch/sh/include/asm/kdebug.h +2 -1
@@ -13,6 +13,7 @@ enum die_val {/* arch/sh/kernel/dumpstack.c */ extern void printk_address (unsigned long address,int reliable); -extern void dump_mem (const char *str,unsigned long bottom,unsigned long top); +extern void dump_mem (const char *str,const char *loglvl, +unsigned long bottom,unsigned long top);#endif /* __ASM_SH_KDEBUG_H */
arch/sh/kernel/dumpstack.c +9 -8
@@ -16,30 +16,31 @@#include <asm/unwinder.h> #include <asm/stacktrace.h> -void dump_mem (const char *str,unsigned long bottom,unsigned long top) +void dump_mem (const char *str,const char *loglvl, +unsigned long bottom,unsigned long top) {unsigned long p;int i; -printk ("%s(0x%08lx to 0x%08lx)\n" , str, bottom, top); +printk ("%s%s(0x%08lx to 0x%08lx)\n" , loglvl, str, bottom, top);for (p = bottom & ~31 ; p < top; ) { -printk ("%04lx: " , p &0xffff ); +printk ("%s%04lx: " , loglvl, p &0xffff );for (i =0 ; i <8 ; i++, p +=4 ) {unsigned int val;if (p < bottom || p >= top) -printk (" " ); +printk ("%s " , loglvl);else {if (__get_user (val, (unsigned int __user *)p)) { -printk ("\n" ); +printk ("%s\n" , loglvl);return ; } -printk ("%08x " , val); +printk ("%s%08x " , loglvl, val); } } -printk ("\n" ); +printk ("%s\n" , loglvl); } }
@@ -156,7 +157,7 @@ void show_stack(struct task_struct *tsk, unsigned long *sp) sp = (unsigned long *)tsk->thread.sp; stack = (unsigned long )sp; -dump_mem ("Stack: " , stack,THREAD_SIZE + +dump_mem ("Stack: " ,KERN_DEFAULT , stack,THREAD_SIZE + (unsigned long )task_stack_page (tsk));show_trace (tsk, sp,NULL ); }
arch/sh/kernel/traps.c +2 -2
@@ -38,8 +38,8 @@ void die(const char *str, struct pt_regs *regs, long err) task_pid_nr(current), task_stack_page(current) + 1);if (!user_mode (regs) ||in_interrupt ()) -dump_mem ("Stack: " , regs->regs[15 ],THREAD_SIZE + - (unsigned long )task_stack_page (current)); +dump_mem ("Stack: " ,KERN_DEFAULT , regs->regs[15 ], +THREAD_SIZE + (unsigned long )task_stack_page (current));notify_die (DIE_OOPS , str, regs, err,255 ,SIGSEGV );
Signature · 1 line
2.23.0
PATCH 30/50 sh: Remove needless printk()
In reply to Dmitry SafonovCurrently `data' is always an empty line "".
No need for additional printk() call.
--- arch/sh/kernel/dumpstack.c | 1 - 1 file changed, 1 deletion(-)
arch/sh/kernel/dumpstack.c +0 -1
@@ -118,7 +118,6 @@ static int print_trace_stack(void *data, char *name)*/ static void print_trace_address (void *data,unsigned long addr,int reliable) { -printk ("%s" , (char *)data);printk_address (addr, reliable); }
Signature · 1 line
2.23.0
PATCH 31/50 sh: Add loglvl to printk_address()
In reply to Dmitry SafonovCurrently, 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 printk_address() as a preparation to introduce show_stack_loglvl().
As a good side-effect show_fault_oops() now prints the address with KERN_EMREG as the rest of output, making sure there won't be situation where "PC: " is printed without actual address.
Cc: Rich Felker <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/sh/include/asm/kdebug.h | 3 ++- arch/sh/kernel/dumpstack.c | 6 +++--- arch/sh/mm/fault.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-)
arch/sh/include/asm/kdebug.h +2 -1
@@ -12,7 +12,8 @@ enum die_val { };/* arch/sh/kernel/dumpstack.c */ -extern void printk_address (unsigned long address,int reliable); +extern void printk_address (unsigned long address,int reliable, +const char *loglvl);extern void dump_mem (const char *str,const char *loglvl,unsigned long bottom,unsigned long top);
arch/sh/kernel/dumpstack.c +3 -3
@@ -44,9 +44,9 @@ void dump_mem(const char *str, const char *loglvl, } } -void printk_address (unsigned long address,int reliable) +void printk_address (unsigned long address,int reliable,const char *loglvl) { -printk (" [<%p>] %s%pS\n" , (void *) address, +printk ("%s [<%p>] %s%pS\n" , loglvl, (void *) address, reliable ?"" :"? " , (void *) address); }
@@ -118,7 +118,7 @@ static int print_trace_stack(void *data, char *name)*/ static void print_trace_address (void *data,unsigned long addr,int reliable) { -printk_address (addr, reliable); +printk_address (addr, reliable, (char *)data); }static const struct stacktrace_ops print_trace_ops = {
arch/sh/mm/fault.c +1 -1
@@ -196,7 +196,7 @@ show_fault_oops(struct pt_regs *regs, unsigned long address)printk (KERN_CONT " at %08lx\n" , address);printk (KERN_ALERT "PC:" ); -printk_address (regs->pc,1 ); +printk_address (regs->pc,1 ,KERN_ALERT );show_pte (NULL , address); }
Signature · 1 line
2.23.0
PATCH 32/50 sh: Add loglvl to show_trace()
In reply to Dmitry SafonovCurrently, 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 parameter to show_trace() as a preparation to introduce show_stack_loglvl().
Cc: Rich Felker <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/sh/include/asm/processor_32.h | 2 +- arch/sh/kernel/dumpstack.c | 10 +++++----- arch/sh/kernel/process_32.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
arch/sh/include/asm/processor_32.h +1 -1
@@ -171,7 +171,7 @@ static __inline__ void enable_fpu(void)#define thread_saved_pc (tsk) (tsk->thread.pc)void show_trace (struct task_struct *tsk,unsigned long *sp, -struct pt_regs *regs); +struct pt_regs *regs,const char *loglvl);#ifdef CONFIG_DUMP_CODE void show_code (struct pt_regs *regs);
arch/sh/kernel/dumpstack.c +5 -5
@@ -127,16 +127,16 @@ static const struct stacktrace_ops print_trace_ops = { };void show_trace (struct task_struct *tsk,unsigned long *sp, -struct pt_regs *regs) +struct pt_regs *regs,const char *loglvl) {if (regs &&user_mode (regs))return ; -printk ("\nCall trace:\n" ); +printk ("%s\nCall trace:\n" , loglvl); -unwind_stack (tsk, regs, sp, &print_trace_ops,"" ); +unwind_stack (tsk, regs, sp, &print_trace_ops, (void *)loglvl); -printk ("\n" ); +printk ("%s\n" , loglvl);if (!tsk) tsk = current;
@@ -158,5 +158,5 @@ void show_stack(struct task_struct *tsk, unsigned long *sp) stack = (unsigned long )sp;dump_mem ("Stack: " ,KERN_DEFAULT , stack,THREAD_SIZE + (unsigned long )task_stack_page (tsk)); -show_trace (tsk, sp,NULL ); +show_trace (tsk, sp,NULL ,KERN_DEFAULT ); }
arch/sh/kernel/process_32.c +1 -1
@@ -59,7 +59,7 @@ void show_regs(struct pt_regs * regs)printk ("MACH: %08lx MACL: %08lx GBR : %08lx PR : %08lx\n" , regs->mach, regs->macl, regs->gbr, regs->pr); -show_trace (NULL , (unsigned long *)regs->regs[15 ], regs); +show_trace (NULL , (unsigned long *)regs->regs[15 ], regs,KERN_DEFAULT );show_code (regs); }
Signature · 1 line
2.23.0
PATCH 33/50 sh: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Rich Felker <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/sh/kernel/dumpstack.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/sh/kernel/dumpstack.c +9 -3
@@ -144,7 +144,8 @@ void show_trace(struct task_struct *tsk, unsigned long *sp,debug_show_held_locks (tsk); } -void show_stack (struct task_struct *tsk,unsigned long *sp) +void show_stack_loglvl (struct task_struct *tsk,unsigned long *sp, +const char *loglvl) {unsigned long stack;
@@ -156,7 +157,12 @@ void show_stack(struct task_struct *tsk, unsigned long *sp) sp = (unsigned long *)tsk->thread.sp; stack = (unsigned long )sp; -dump_mem ("Stack: " ,KERN_DEFAULT , stack,THREAD_SIZE + +dump_mem ("Stack: " , loglvl, stack,THREAD_SIZE + (unsigned long )task_stack_page (tsk)); -show_trace (tsk, sp,NULL ,KERN_DEFAULT ); +show_trace (tsk, sp,NULL , loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *sp) +{ +show_stack_loglvl (task, sp,KERN_DEFAULT ); }
Signature · 1 line
2.23.0
PATCH 34/50 sparc: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/sparc/kernel/process_32.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
arch/sparc/kernel/process_32.c +12 -5
@@ -145,10 +145,12 @@ void show_regs(struct pt_regs *r) }/* -* The show_stack is an external API which we do not use ourselves. +* The show_stack(), show_stack_loglvl() are external APIs which +* we do not use ourselves. * The oops is printed in die_if_kernel. */ -void show_stack (struct task_struct *tsk,unsigned long *_ksp) +void show_stack_loglvl (struct task_struct *task,unsigned long *sp, +const char *loglvl) {unsigned long pc, fp;unsigned long task_base;
@@ -170,11 +172,16 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)break ; rw = (struct reg_window32 *) fp; pc = rw->ins[7 ]; -printk ("[%08lx : " , pc); -printk ("%pS ] " , (void *) pc); +printk ("%s[%08lx : " , loglvl, pc); +printk ("%s%pS ] " , loglvl, (void *) pc); fp = rw->ins[6 ]; }while (++count <16 ); -printk ("\n" ); +printk ("%s\n" , loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *sp) +{ +show_stack_loglvl (task, sp,KERN_DEFAULT ); }/*
Signature · 1 line
2.23.0
Re: [PATCH 34/50] sparc: Add show_stack_loglvl()
From: Dmitry Safonov <[email protected]>
Date: Wed, 6 Nov 2019 03:05:25 +0000
Quoted 16 lines
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_loglevelwhile 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 theprintk()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.
Quoted 7 lines
Introduce
show_stack_loglvl(), that eventually will substituteshow_stack().Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#uSigned-off-by Dmitry Safonov <[email protected]>
Re: [PATCH 34/50] sparc: Add show_stack_loglvl()
Quoted 22 lines · David Miller
From: Dmitry Safonov <[email protected]>
Date: Wed, 6 Nov 2019 03:05:25 +0000Quoted 19 lines
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_loglevelwhile 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 theprintk()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 substituteshow_stack().
Quoted 6 lines
Quoted 4 lines
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#uSigned-off-by Dmitry Safonov <[email protected]>Acked-by David S. Miller <[email protected]>
Thanks for the review and time, David!
Signature · 1 line
Dmitry
kbuild test robot
build botRe: [PATCH 34/50] sparc: Add show_stack_loglvl()
In reply to Dmitry SafonovThank you for the patch! Yet something to improve:
Hi Dmitry,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.4-rc6 next-20191107]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Dmitry-Safonov/kallsyms-printk-Add-loglvl-to-print_ip_sym/20191108-124037 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 847120f859cc45e074204f4cf33c8df069306eb2 config: sparc-defconfig (attached as .config) compiler: sparc-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sparc
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
arch/sparc/kernel/process_32.c: In function 'show_stack_loglvl':
>> arch/sparc/kernel/process_32.c:160:7: error: 'tsk' undeclared (first use in this function); did you mean 'task'?
if (!tsk)
^~~
task
arch/sparc/kernel/process_32.c:160:7: note: each undeclared identifier is reported only once for each function it appears in
>> arch/sparc/kernel/process_32.c:163:25: error: '_ksp' undeclared (first use in this function); did you mean 'sp'?
if (tsk == current && !_ksp)
^~~~
spvim +160 arch/sparc/kernel/process_32.c
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 146
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 147 /*
17ea0216681912 arch/sparc/kernel/process_32.c Dmitry Safonov 2019-11-06 148 * The show_stack(), show_stack_loglvl() are external APIs which
17ea0216681912 arch/sparc/kernel/process_32.c Dmitry Safonov 2019-11-06 149 * we do not use ourselves.
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 150 * The oops is printed in die_if_kernel.
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 151 */
17ea0216681912 arch/sparc/kernel/process_32.c Dmitry Safonov 2019-11-06 152 void show_stack_loglvl(struct task_struct *task, unsigned long *sp,
17ea0216681912 arch/sparc/kernel/process_32.c Dmitry Safonov 2019-11-06 153 const char *loglvl)
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 154 {
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 155 unsigned long pc, fp;
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 156 unsigned long task_base;
4d7b92ad572b4b arch/sparc/kernel/process_32.c Sam Ravnborg 2009-01-02 157 struct reg_window32 *rw;
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 158 int count = 0;
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 159
89e3f23da9c827 arch/sparc/kernel/process_32.c Tejun Heo 2013-04-30 @160 if (!tsk)
89e3f23da9c827 arch/sparc/kernel/process_32.c Tejun Heo 2013-04-30 161 tsk = current;
89e3f23da9c827 arch/sparc/kernel/process_32.c Tejun Heo 2013-04-30 162
89e3f23da9c827 arch/sparc/kernel/process_32.c Tejun Heo 2013-04-30 @163 if (tsk == current && !_ksp)
89e3f23da9c827 arch/sparc/kernel/process_32.c Tejun Heo 2013-04-30 164 __asm__ __volatile__("mov %%fp, %0" : "=r" (_ksp));
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 165
89e3f23da9c827 arch/sparc/kernel/process_32.c Tejun Heo 2013-04-30 166 task_base = (unsigned long) task_stack_page(tsk);
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 167 fp = (unsigned long) _ksp;
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 168 do {
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 169 /* Bogus frame pointer? */
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 170 if (fp < (task_base + sizeof(struct thread_info)) ||
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 171 fp >= (task_base + (PAGE_SIZE << 1)))
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 172 break;
4d7b92ad572b4b arch/sparc/kernel/process_32.c Sam Ravnborg 2009-01-02 173 rw = (struct reg_window32 *) fp;
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 174 pc = rw->ins[7];
17ea0216681912 arch/sparc/kernel/process_32.c Dmitry Safonov 2019-11-06 175 printk("%s[%08lx : ", loglvl, pc);
17ea0216681912 arch/sparc/kernel/process_32.c Dmitry Safonov 2019-11-06 176 printk("%s%pS ] ", loglvl, (void *) pc);
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 177 fp = rw->ins[6];
^1da177e4c3f41 arch/sparc/kernel/process.c Linus Torvalds 2005-04-16 178 } while (++count < 16);
17ea0216681912 arch/sparc/kernel/process_32.c Dmitry Safonov 2019-11-06 179 printk("%s\n", loglvl);
17ea0216681912 arch/sparc/kernel/process_32.c Dmitry Safonov 2019-11-06 180 }
17ea0216681912 arch/sparc/kernel/process_32.c Dmitry Safonov 2019-11-06 181 :::::: The code@line 160 was first introduced by commit
:::::: 89e3f23da9c827bfa9806c3d4da83a12c1c8543a sparc32: make show_stack() acquire %fp if @_ksp is not specified
:::::: TO: Tejun Heo <[email protected]>
:::::: CC: Linus Torvalds <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
PATCH 35/50 um/sysrq: Remove needless variable sp
In reply to Dmitry Safonov`sp' is a needless excercise here.
--- arch/um/kernel/sysrq.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/um/kernel/sysrq.c +1 -3
@@ -27,7 +27,6 @@ static const struct stacktrace_ops stackops = {void show_stack (struct task_struct *task,unsigned long *stack) { -unsigned long *sp = stack;struct pt_regs *segv_regs = current->thread.segv_regs;int i;
@@ -38,10 +37,9 @@ void show_stack(struct task_struct *task, unsigned long *stack) }if (!stack) - sp =get_stack_pointer (task, segv_regs); + stack =get_stack_pointer (task, segv_regs);pr_info ("Stack:\n" ); - stack = sp;for (i =0 ; i <3 *STACKSLOTS_PER_LINE ; i++) {if (kstack_end (stack))break ;
Signature · 7 lines
2.23.0 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
PATCH 36/50 um: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Anton Ivanov <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/um/kernel/sysrq.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
arch/um/kernel/sysrq.c +16 -8
@@ -17,7 +17,9 @@static void _print_addr (void *data,unsigned long address,int reliable) { -pr_info (" [<%08lx>] %s%pS\n" , address, reliable ?"" :"? " , +const char *loglvl = data; + +printk ("%s [<%08lx>] %s%pS\n" , loglvl, address, reliable ?"" :"? " , (void *)address); }
@@ -25,7 +27,8 @@ static const struct stacktrace_ops stackops = { .address = _print_addr }; -void show_stack (struct task_struct *task,unsigned long *stack) +void show_stack_loglvl (struct task_struct *task,unsigned long *stack, +const char *loglvl) {struct pt_regs *segv_regs = current->thread.segv_regs;int i;
@@ -39,17 +42,22 @@ void show_stack(struct task_struct *task, unsigned long *stack)if (!stack) stack =get_stack_pointer (task, segv_regs); -pr_info ("Stack:\n" ); +printk ("%sStack:\n" , loglvl);for (i =0 ; i <3 *STACKSLOTS_PER_LINE ; i++) {if (kstack_end (stack))break ;if (i && ((i %STACKSLOTS_PER_LINE ) ==0 )) -pr_cont ("\n" ); +printk ("%s\n" , loglvl);pr_cont (" %08lx" , *stack++); } -pr_cont ("\n" ); +printk ("%s\n" , loglvl); + +printk ("%sCall Trace:\n" , loglvl); +dump_trace (current, &stackops, (void *)loglvl); +printk ("%s\n" , loglvl); +} -pr_info ("Call Trace:\n" ); -dump_trace (current, &stackops,NULL ); -pr_info ("\n" ); +void show_stack (struct task_struct *task,unsigned long *stack) +{ +show_stack_loglvl (task, stack,KERN_INFO ); }
Signature · 7 lines
2.23.0 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
PATCH 37/50 unicore32: Remove unused pmode argument in c_backtrace()
In reply to Dmitry SafonovThe pmode parameter isn't used in assembly - remove it. Second argument will be reused for printk() log level.
--- arch/unicore32/kernel/setup.h | 2 +- arch/unicore32/kernel/traps.c | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-)
arch/unicore32/kernel/setup.h +1 -1
@@ -29,7 +29,7 @@ extern void kernel_thread_helper(void);extern void __init early_signal_init (void ); extern asmlinkage void __backtrace(void); -extern asmlinkage void c_backtrace(unsigned long fp, int pmode); +extern asmlinkage void c_backtrace(unsigned long fp);extern void __show_regs (struct pt_regs *);
arch/unicore32/kernel/traps.c +5 -9
@@ -137,7 +137,7 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)static void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk) { -unsigned int fp, mode; +unsigned int fp;int ok =1 ;printk (KERN_DEFAULT "Backtrace: " );
@@ -145,16 +145,12 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)if (!tsk) tsk = current; -if (regs) { +if (regs) fp = regs->UCreg_fp; - mode =processor_mode (regs); - }else if (tsk != current) { +else if (tsk != current) fp =thread_saved_fp (tsk); - mode =0x10 ; - }else { +else asm("mov %0, fp" :"=r" (fp) : :"cc" ); - mode =0x10 ; - }if (!fp) {printk ("no frame pointer" );
@@ -167,7 +163,7 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)printk ("\n" );if (ok) -c_backtrace (fp, mode); +c_backtrace (fp); }void show_stack (struct task_struct *tsk,unsigned long *sp)
Signature · 1 line
2.23.0
PATCH 38/50 unicore32: Add loglvl to c_backtrace()
In reply to Dmitry SafonovCurrently, 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 parameter to c_backtrace() as a preparation for introducing show_stack_loglvl()
Cc: Guan Xuetao <[email protected]>
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/unicore32/kernel/setup.h | 2 +- arch/unicore32/kernel/traps.c | 2 +- arch/unicore32/lib/backtrace.S | 24 ++++++++++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-)
arch/unicore32/kernel/setup.h +1 -1
@@ -29,7 +29,7 @@ extern void kernel_thread_helper(void);extern void __init early_signal_init (void ); extern asmlinkage void __backtrace(void); -extern asmlinkage void c_backtrace(unsigned long fp); +extern asmlinkage void c_backtrace(unsigned long fp, const char *loglvl);extern void __show_regs (struct pt_regs *);
arch/unicore32/kernel/traps.c +1 -1
@@ -163,7 +163,7 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)printk ("\n" );if (ok) -c_backtrace (fp); +c_backtrace (fp,KERN_DEFAULT ); }void show_stack (struct task_struct *tsk,unsigned long *sp)
arch/unicore32/lib/backtrace.S +16 -8
@@ -16,6 +16,7 @@ #define sv_fp v5 #define sv_pc v6 #define offset v8 +#define loglvl v9 ENTRY(__backtrace) mov r0, fp
@@ -27,10 +28,11 @@ ENTRY(c_backtrace) ENDPROC(__backtrace) ENDPROC(c_backtrace) #else - stm.w (v4 - v8, lr), [sp-] @ Save an extra register + stm.w (v4 - v10, lr), [sp-] @ Save an extra register @ so we have a location... mov.a frame, r0 @ if frame pointer is zero beq no_frame @ we have no stack frames + mov loglvl, r1 1: stm.w (pc), [sp-] @ calculate offset of PC stored ldw.w r0, [sp]+, #4 @ by stmfd for this CPU
@@ -95,9 +97,10 @@ for_each_frame: bua for_each_frame 1006: adr r0, .Lbad - mov r1, frame + mov r1, loglvl + mov r2, frame b.l printk -no_frame: ldm.w (v4 - v8, pc), [sp]+ +no_frame: ldm.w (v4 - v10, pc), [sp]+ ENDPROC(__backtrace) ENDPROC(c_backtrace)
@@ -128,8 +131,11 @@ ENDPROC(c_backtrace) add v7, v7, #1 cxor.a v7, #6 cmoveq v7, #1 - cmoveq r1, #'\n' - cmovne r1, #' ' + bne 201f + adr r0, .Lcr + mov r1, loglvl + b.l printk +201: ldw.w r3, [stack]+, #-4 mov r2, reg csub.a r2, #8
@@ -141,18 +147,20 @@ ENDPROC(c_backtrace) add r2, r2, #0x10 @ so r2 need add 16 201: adr r0, .Lfp + mov r1, loglvl b.l printk 2: sub.a reg, reg, #1 bns 1b cxor.a v7, #0 beq 201f adr r0, .Lcr + mov r1, loglvl b.l printk 201: ldm.w (instr, reg, stack, v7, pc), [sp]+ -.Lfp: .asciz "%cr%d:%08x" -.Lcr: .asciz "\n" -.Lbad: .asciz "Backtrace aborted due to bad frame pointer <%p>\n" +.Lfp: .asciz "%sr%d:%08x " +.Lcr: .asciz "%s\n" +.Lbad: .asciz "%sBacktrace aborted due to bad frame pointer <%p>\n" .align .Ldsi: .word 0x92eec000 >> 14 @ stm.w sp, (... fp, ip, lr, pc) .word 0x92e10000 >> 14 @ stm.w sp, ()
Signature · 1 line
2.23.0
PATCH 39/50 unicore32: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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.
Cc: Guan Xuetao <[email protected]>
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/unicore32/kernel/traps.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
arch/unicore32/kernel/traps.c +17 -10
@@ -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); }
Signature · 1 line
2.23.0
PATCH 40/50 x86: Add missing const qualifiers for log_lvl
In reply to Dmitry SafonovCurrently, 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.
Keep log_lvl const show_trace_log_lvl() and printk_stack_address() as the new generic show_stack_loglvl() wants to have a proper const qualifier.
And gcc rightfully produces warnings in case it's not keept:arch/x86/kernel/dumpstack.c: In function ‘show_stack’:arch/x86/kernel/dumpstack.c:294:37: warning: passing argument 4 of ‘show_trace_log_lv ’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
294 | show_trace_log_lvl(task, NULL, sp, loglvl);
| ^~~~~~arch/x86/kernel/dumpstack.c:163:32: note: expected ‘char *’ but argument is of type ‘const char *’
163 | unsigned long *stack, char *log_lvl)
| ~~~~~~^~~~~~~
Cc: Borislav Petkov <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/x86/include/asm/stacktrace.h | 2 +- arch/x86/kernel/dumpstack.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/include/asm/stacktrace.h +1 -1
@@ -87,7 +87,7 @@ get_stack_pointer(struct task_struct *task, struct pt_regs *regs) }void show_trace_log_lvl (struct task_struct *task,struct pt_regs *regs, -unsigned long *stack,char *log_lvl); +unsigned long *stack,const char *log_lvl);/* The form of the top of the frame on the stack */ struct stack_frame {
arch/x86/kernel/dumpstack.c +2 -2
@@ -65,7 +65,7 @@ bool in_entry_stack(unsigned long *stack, struct stack_info *info) }static void printk_stack_address (unsigned long address,int reliable, -char *log_lvl) +const char *log_lvl) {touch_nmi_watchdog ();printk ("%s %s%pB\n" , log_lvl, reliable ?"" :"? " , (void *)address);
@@ -160,7 +160,7 @@ static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs, }void show_trace_log_lvl (struct task_struct *task,struct pt_regs *regs, -unsigned long *stack,char *log_lvl) +unsigned long *stack,const char *log_lvl) {struct unwind_state state;struct stack_info stack_info = {0 };
Signature · 1 line
2.23.0
PATCH 41/50 x86: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Borislav Petkov <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/x86/kernel/dumpstack.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/x86/kernel/dumpstack.c +8 -2
@@ -279,7 +279,8 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, } } -void show_stack (struct task_struct *task,unsigned long *sp) +void show_stack_loglvl (struct task_struct *task,unsigned long *sp, +const char *loglvl) { task = task ? : current;
@@ -290,7 +291,12 @@ void show_stack(struct task_struct *task, unsigned long *sp)if (!sp && task == current) sp =get_stack_pointer (current,NULL ); -show_trace_log_lvl (task,NULL , sp,KERN_DEFAULT ); +show_trace_log_lvl (task,NULL , sp, loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *sp) +{ +show_stack_loglvl (task, sp,KERN_DEFAULT ); }void show_stack_regs (struct pt_regs *regs)
Signature · 1 line
2.23.0
PATCH 42/50 xtensa: Add loglvl to show_trace()
In reply to Dmitry SafonovCurrently, 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 show_trace() as a preparation for introducing show_stack_loglvl().
Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/xtensa/kernel/traps.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
arch/xtensa/kernel/traps.c +10 -6
@@ -479,20 +479,24 @@ void show_regs(struct pt_regs * regs)static int show_trace_cb (struct stackframe *frame,void *data) { +const char *loglvl = data; +if (kernel_text_address (frame->pc)) -pr_cont (" [<%08lx>] %pB\n" , frame->pc, (void *)frame->pc); +printk ("%s [<%08lx>] %pB\n" , + loglvl, frame->pc, (void *)frame->pc);return 0 ; } -void show_trace (struct task_struct *task,unsigned long *sp) +static void show_trace (struct task_struct *task,unsigned long *sp, +const char *loglvl) {if (!sp) sp =stack_pointer (task); -pr_info ("Call Trace:\n" ); -walk_stackframe (sp, show_trace_cb,NULL ); +printk ("%sCall Trace:\n" , loglvl); +walk_stackframe (sp, show_trace_cb, (void *)loglvl);#ifndef CONFIG_KALLSYMS -pr_cont ("\n" ); +printk ("%s\n" , loglvl);#endif }
@@ -516,7 +520,7 @@ void show_stack(struct task_struct *task, unsigned long *sp)if (i %8 ==7 )pr_cont ("\n" ); } -show_trace (task, stack); +show_trace (task, stack,KERN_INFO ); }DEFINE_SPINLOCK (die_lock);
Signature · 1 line
2.23.0
PATCH 43/50 xtensa: Add show_stack_loglvl()
In reply to Dmitry SafonovCurrently, 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().
Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#u
--- arch/xtensa/kernel/traps.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
arch/xtensa/kernel/traps.c +11 -5
@@ -502,7 +502,8 @@ static void show_trace(struct task_struct *task, unsigned long *sp,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) {int i =0 ;unsigned long *stack;
@@ -511,16 +512,21 @@ void show_stack(struct task_struct *task, unsigned long *sp) sp =stack_pointer (task); stack = sp; -pr_info ("Stack:\n" ); +printk ("%sStack:\n" , loglvl);for (i =0 ; i < kstack_depth_to_print; i++) {if (kstack_end (sp))break ; -pr_cont (" %08lx" , *sp++); +printk ("%s %08lx" , loglvl, *sp++);if (i %8 ==7 ) -pr_cont ("\n" ); +printk ("%s\n" , loglvl); } -show_trace (task, stack,KERN_INFO ); +show_trace (task, stack, loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *sp) +{ +show_stack_loglvl (task, sp,KERN_INFO ); }DEFINE_SPINLOCK (die_lock);
Signature · 1 line
2.23.0
Max Filippov
maintainerRe: [PATCH 43/50] xtensa: Add show_stack_loglvl()
Hi Dmitry,
Quoted 70 lines · Dmitry Safonov
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_loglevelwhile 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 theprintk()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 substituteshow_stack().Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#uSigned-off-by Dmitry Safonov <[email protected]>--- arch/xtensa/kernel/traps.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)arch/xtensa/kernel/traps.c +11
-6@@ -502,7 +502,8 @@ static void show_trace(struct task_struct *task, unsigned long *sp,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) {int i =0 ;unsigned long *stack;@@ -511,16 +512,21 @@ void show_stack(struct task_struct *task, unsigned long *sp) sp =stack_pointer (task); stack = sp; -pr_info ("Stack:\n" ); +printk ("%sStack:\n" , loglvl);for (i =0 ; i < kstack_depth_to_print; i++) {if (kstack_end (sp))break ; -pr_cont (" %08lx" , *sp++); +printk ("%s %08lx" , loglvl, *sp++);if (i %8 ==7 ) -pr_cont ("\n" ); +printk ("%s\n" , loglvl); } -show_trace (task, stack,KERN_INFO ); +show_trace (task, stack, loglvl); +} + +void show_stack (struct task_struct *task,unsigned long *sp) +{ +show_stack_loglvl (task, sp,KERN_INFO ); }DEFINE_SPINLOCK (die_lock); --
Quoted 1 line
2.23.0
This change doesn't work well with printk timestamps, it changes the following output on xtensa architecture
[ 3.404675] Stack: [ 3.404861] a05773e2 00000018 bb03dc34 bb03dc30 a0008640 bb03dc70 ba9ba410 37c3f000 [ 3.405414] 37c3f000 d7c3f000 00000800 bb03dc50 a02b97ed bb03dc90 ba9ba400 ba9ba410 [ 3.405969] a05fc1bc bbff28dc 00000000 bb03dc70 a02b7fb9 bb03dce0
ba9ba410 a0579044
into this:
[ 3.056825] Stack: [ 3.056963] a04ebb20 [ 3.056995] bb03dc10 [ 3.057138] 00000001 [ 3.057277] bb03dc10 [ 3.057815] a00083ca [ 3.057965] bb03dc50 [ 3.058107] ba9ba410 [ 3.058247] 37c3f000 [ 3.058387] [ 3.058584] a05773e2 [ 3.058614] 00000001 [ 3.058755] a05ca0bc [ 3.058896] bb03dc30 [ 3.059035] a000865c [ 3.059180] bb03dc70 [ 3.059319] ba9ba410 [ 3.059459] 37c3f000 [ 3.059598] [ 3.059795] 37c3f000 [ 3.059824] d7c3f000 [ 3.059964] 00000800 [ 3.060103] bb03dc50 [ 3.060241] a02b9809 [ 3.060379] bb03dc90 [ 3.060519] ba9ba400 [ 3.060658] ba9ba410 [ 3.060796]
Signature · 2 lines
Thanks. -- Max
Re: [PATCH 43/50] xtensa: Add show_stack_loglvl()
Quoted 50 lines · Max Filippov
Hi Dmitry,
Quoted 47 lines · Dmitry Safonov
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_loglevelwhile 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 theprintk()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 substituteshow_stack().Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: [email protected]
[1]: https://lore.kernel.org/lkml/[email protected]/T/#uSigned-off-by Dmitry Safonov <[email protected]>--- arch/xtensa/kernel/traps.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)arch/xtensa/kernel/traps.c +2
-1@@ -502,7 +502,8 @@ static void show_trace(struct task_struct *task, unsigned long *sp,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) {int i =0 ;unsigned long *stack;@@ -511,16 +512,21 @@ void show_stack(struct task_struct *task, unsigned long *sp) sp =stack_pointer (task); stack = sp;
Quoted 8 lines
arch/xtensa/kernel/traps.c void show_stack(struct task_struct *task, unsigned long *sp) · line 520
Quoted 8 lines
arch/xtensa/kernel/traps.c +2
-2-pr_info ("Stack:\n" ); +printk ("%sStack:\n" , loglvl);for (i =0 ; i < kstack_depth_to_print; i++) {if (kstack_end (sp))break ; -pr_cont (" %08lx" , *sp++); +printk ("%s %08lx" , loglvl, *sp++);
KERN_CONT can be combined with any other loglevel.
So you could keep using pr_cont() together with explicit loglevel:
pr_cont("%s %08lx", loglvl, *sp++);It should fix the problems reported below.
Well, the preferred solution would be to snprintf() the continuous line into a temporary buffer. And printk() it when it is complete. pr_cont() is not reliable when more CPUs print at the same time.
Best Regards,
Petr
Quoted 44 lines
This change doesn't work well with printk timestamps, it changes the following output on xtensa architecture
[ 3.404675] Stack: [ 3.404861] a05773e2 00000018 bb03dc34 bb03dc30 a0008640 bb03dc70 ba9ba410 37c3f000 [ 3.405414] 37c3f000 d7c3f000 00000800 bb03dc50 a02b97ed bb03dc90 ba9ba400 ba9ba410 [ 3.405969] a05fc1bc bbff28dc 00000000 bb03dc70 a02b7fb9 bb03dce0
ba9ba410a0579044into this:
[ 3.056825] Stack: [ 3.056963] a04ebb20 [ 3.056995] bb03dc10 [ 3.057138] 00000001 [ 3.057277] bb03dc10 [ 3.057815] a00083ca [ 3.057965] bb03dc50 [ 3.058107] ba9ba410 [ 3.058247] 37c3f000 [ 3.058387] [ 3.058584] a05773e2 [ 3.058614] 00000001 [ 3.058755] a05ca0bc [ 3.058896] bb03dc30 [ 3.059035] a000865c [ 3.059180] bb03dc70 [ 3.059319] ba9ba410 [ 3.059459] 37c3f000 [ 3.059598] [ 3.059795] 37c3f000 [ 3.059824] d7c3f000 [ 3.059964] 00000800 [ 3.060103] bb03dc50 [ 3.060241] a02b9809 [ 3.060379] bb03dc90 [ 3.060519] ba9ba400 [ 3.060658] ba9ba410 [ 3.060796]Signature · 2 lines
Thanks. -- Max
Re: [PATCH 43/50] xtensa: Add show_stack_loglvl()
Quoted 1 line · Petr Mladek
On Tue 2019-11-05 20:13:22, Max Filippov wrote:
[..]
Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
arch/xtensa/kernel/traps.c +0
-0@@ -511,16 +512,21 @@ void show_stack(struct task_struct *task, unsigned long *sp) sp =stack_pointer (task); stack = sp;Quoted 8 lines
arch/xtensa/kernel/traps.c void show_stack(struct task_struct *task, unsigned long *sp) · line 520
Quoted 8 lines
arch/xtensa/kernel/traps.c +2
-2-pr_info ("Stack:\n" ); +printk ("%sStack:\n" , loglvl);for (i =0 ; i < kstack_depth_to_print; i++) {if (kstack_end (sp))break ; -pr_cont (" %08lx" , *sp++); +printk ("%s %08lx" , loglvl, *sp++);
KERN_CONTcan be combined with any other loglevel.
So you could keep usingpr_cont()together with explicit loglevel:
Quoted 1 line
pr_cont("%s %08lx", loglvl, *sp++);Yes, that's what I had, but than misread the printk() code and thought that it doesn't add '\n' to messages.. Will fix.
Quoted 5 lines
It should fix the problems reported below.
Well, the preferred solution would be to
snprintf()the continuous line into a temporary buffer. Andprintk()it when it is complete.pr_cont()is not reliable when more CPUs print at the same time.
Yep. Not sure if doing it now in those per-arch patches or keep the changes to minimum.
Quoted 33 lines
Quoted 33 lines
This change doesn't work well with printk timestamps, it changes the following output on xtensa architecture
[ 3.404675] Stack: [ 3.404861] a05773e2 00000018 bb03dc34 bb03dc30 a0008640 bb03dc70 ba9ba410 37c3f000 [ 3.405414] 37c3f000 d7c3f000 00000800 bb03dc50 a02b97ed bb03dc90 ba9ba400 ba9ba410 [ 3.405969] a05fc1bc bbff28dc 00000000 bb03dc70 a02b7fb9 bb03dce0
ba9ba410a0579044into this:
[ 3.056825] Stack: [ 3.056963] a04ebb20 [ 3.056995] bb03dc10 [ 3.057138] 00000001 [ 3.057277] bb03dc10 [ 3.057815] a00083ca [ 3.057965] bb03dc50 [ 3.058107] ba9ba410 [ 3.058247] 37c3f000 [ 3.058387] [ 3.058584] a05773e2 [ 3.058614] 00000001 [ 3.058755] a05ca0bc [ 3.058896] bb03dc30 [ 3.059035] a000865c [ 3.059180] bb03dc70 [ 3.059319] ba9ba410 [ 3.059459] 37c3f000 [ 3.059598] [ 3.059795] 37c3f000
Quoted 8 lines
Quoted 8 lines
[ 3.059824] d7c3f000 [ 3.059964] 00000800 [ 3.060103] bb03dc50 [ 3.060241] a02b9809 [ 3.060379] bb03dc90 [ 3.060519] ba9ba400 [ 3.060658] ba9ba410 [ 3.060796]
Hey Max,
thanks for the testing and the report - will fix it in v2.
Thanks,
Dmitry
Max Filippov
maintainerRe: [PATCH 43/50] xtensa: Add show_stack_loglvl()
In reply to Petr MladekQuoted 9 lines · Petr Mladek
Quoted 5 lines
arch/xtensa/kernel/traps.c void show_stack(struct task_struct *task, unsigned long *sp) · line 520
Quoted 5 lines
for (i = 0; i < kstack_depth_to_print; i++) { if (kstack_end(sp)) break;arch/xtensa/kernel/traps.c +1
-1-pr_cont (" %08lx" , *sp++); +printk ("%s %08lx" , loglvl, *sp++);
KERN_CONTcan be combined with any other loglevel.
So you could keep usingpr_cont()together with explicit loglevel:
Quoted 7 lines
pr_cont("%s %08lx", loglvl, *sp++);It should fix the problems reported below.
Well, the preferred solution would be to
snprintf()the continuous line into a temporary buffer. Andprintk()it when it is complete.pr_cont()is not reliable when more CPUs print at the same time.
Good point. Let me do this cleanup.
Signature · 2 lines
Thanks. -- Max
PATCH 44/50 sysrq: Use show_stack_loglvl()
In reply to Dmitry SafonovShow the stack trace on a CPU with the same log level as "CPU%d" header.
--- drivers/tty/sysrq.c | 2 +- include/linux/sched/debug.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/tty/sysrq.c +1 -1
@@ -220,7 +220,7 @@ static void showacpu(void *dummy)raw_spin_lock_irqsave (&show_lock, flags);pr_info ("CPU%d:\n" ,smp_processor_id ()); -show_stack (NULL ,NULL ); +show_stack_loglvl (NULL ,NULL ,KERN_INFO );raw_spin_unlock_irqrestore (&show_lock, flags); }
include/linux/sched/debug.h +2 -0
@@ -31,6 +31,8 @@ extern void show_regs(struct pt_regs *);* trace (or NULL if the entire call-chain of the task should be shown). */ extern void show_stack (struct task_struct *task,unsigned long *sp); +extern void show_stack_loglvl (struct task_struct *task,unsigned long *sp, +const char *loglvl);extern void sched_show_task (struct task_struct *p);
Signature · 1 line
2.23.0
PATCH 45/50 x86/amd_gart: Print stacktrace for a leak with KERN_ERR
In reply to Dmitry SafonovIt's under CONFIG_IOMMU_LEAK option which is enabled by debug config. Likely the backtrace is worth to be seen - so aligning with log level of error message in iommu_full().
--- arch/x86/kernel/amd_gart_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/amd_gart_64.c +1 -1
@@ -159,7 +159,7 @@ static void dump_leak(void)return ; dump =1 ; -show_stack (NULL ,NULL ); +show_stack_loglvl (NULL ,NULL ,KERN_ERR ); debug_dma_dump_mappings(NULL); }#endif
Signature · 1 line
2.23.0
PATCH 46/50 power: Use show_stack_loglvl()
In reply to Dmitry SafonovAligning with other watchdog messages just before panic - use KERN_EMERG.
--- drivers/base/power/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/main.c +1 -1
@@ -487,7 +487,7 @@ static void dpm_watchdog_handler(struct timer_list *t)struct dpm_watchdog *wd =from_timer (wd, t, timer);dev_emerg (wd->dev,"**** DPM device timeout ****\n" ); -show_stack (wd->tsk,NULL ); +show_stack_loglvl (wd->tsk,NULL ,KERN_EMERG );panic ("%s %s: unrecoverable failure\n" ,dev_driver_string (wd->dev),dev_name (wd->dev)); }
Signature · 1 line
2.23.0
PATCH 47/50 kdb: Don't play with console_loglevel
In reply to Dmitry SafonovPrint the stack trace with KERN_EMERG - it should be always visible.
Playing with console_loglevel is a bad idea as there may be more messages printed than wanted. Also the stack trace might be not printed at all if printk() was deferred and console_loglevel was raised back before the trace got flushed.
--- kernel/debug/kdb/kdb_bt.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
kernel/debug/kdb/kdb_bt.c +4 -7
@@ -21,22 +21,19 @@static void kdb_show_stack (struct task_struct *p,void *addr) { -int old_lvl = console_loglevel; - console_loglevel =CONSOLE_LOGLEVEL_MOTORMOUTH ; kdb_trap_printk++;kdb_set_current_task (p);if (addr) { -show_stack ((struct task_struct *)p, addr); +show_stack_loglvl (p, addr,KERN_EMERG ); }else if (kdb_current_regs) {#ifdef CONFIG_X86 -show_stack (p, &kdb_current_regs->sp); +show_stack_loglvl (p, &kdb_current_regs->sp,KERN_EMERG );#else -show_stack (p,NULL ); +show_stack_loglvl (p,NULL ,KERN_EMERG );#endif }else { -show_stack (p,NULL ); +show_stack_loglvl (p,NULL ,KERN_EMERG ); } - console_loglevel = old_lvl; kdb_trap_printk--; }
Signature · 1 line
2.23.0
PATCH 48/50 sched: Print stack trace with KERN_INFO
In reply to Dmitry SafonovAligning with other messages printed in sched_show_task() - use KERN_INFO to print the backtrace.
--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
@@ -5932,7 +5932,7 @@ void sched_show_task(struct task_struct *p) (unsigned long)task_thread_info(p)->flags);print_worker_info (KERN_INFO , p); -show_stack (p,NULL ); +show_stack_loglvl (p,NULL ,KERN_INFO );put_task_stack (p); }EXPORT_SYMBOL_GPL (sched_show_task);
Signature · 1 line
2.23.0
PATCH 49/50 kernel: Use show_stack_loglvl()
In reply to Dmitry SafonovAlign the last users of show_stack() by KERN_DEFAULT as the surrounding headers/messages.
--- kernel/locking/rtmutex-debug.c | 2 +- lib/dump_stack.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/locking/rtmutex-debug.c +1 -1
@@ -125,7 +125,7 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)printk ("\n%s/%d's [blocked] stackdump:\n\n" , task->comm,task_pid_nr (task)); -show_stack (task,NULL ); +show_stack_loglvl (task,NULL ,KERN_DEFAULT );printk ("\n%s/%d's [current] stackdump:\n\n" , current->comm,task_pid_nr (current));dump_stack ();
lib/dump_stack.c +1 -1
@@ -74,7 +74,7 @@ void show_regs_print_info(const char *log_lvl)static void __dump_stack (void ) {dump_stack_print_info (KERN_DEFAULT ); -show_stack (NULL ,NULL ); +show_stack_loglvl (NULL ,NULL ,KERN_DEFAULT ); }/**
Signature · 1 line
2.23.0
PATCH 50/50 kernel: Rename show_stack_loglvl() => show_stack()
In reply to Dmitry SafonovNow the last users of show_stack() got converted to use an explicit log level, show_stack_loglvl() can drop it's redundant suffix and become once again well known show_stack().
--- arch/alpha/kernel/traps.c | 8 +------- arch/arc/kernel/stacktrace.c | 8 +------- arch/arm/kernel/traps.c | 8 +------- arch/arm64/kernel/traps.c | 8 +------- arch/c6x/kernel/traps.c | 7 +------ arch/csky/kernel/dumpstack.c | 7 +------ arch/csky/kernel/ptrace.c | 4 ++-- arch/h8300/kernel/traps.c | 8 +------- arch/hexagon/kernel/traps.c | 8 +------- arch/ia64/kernel/mca.c | 2 +- arch/ia64/kernel/process.c | 11 ++--------- arch/m68k/kernel/traps.c | 11 +++-------- arch/microblaze/kernel/traps.c | 8 +------- arch/mips/kernel/traps.c | 8 +------- arch/nds32/kernel/traps.c | 8 +------- arch/nios2/kernel/traps.c | 12 +++--------- arch/openrisc/kernel/traps.c | 10 ++-------- arch/parisc/kernel/traps.c | 8 +------- arch/powerpc/kernel/process.c | 11 +++-------- arch/powerpc/kernel/stacktrace.c | 2 +- arch/riscv/kernel/stacktrace.c | 8 +------- arch/s390/kernel/dumpstack.c | 7 +------ arch/sh/kernel/dumpstack.c | 8 +------- arch/sh/kernel/process_64.c | 3 +-- arch/sparc/kernel/process_32.c | 11 ++--------- arch/sparc/kernel/process_64.c | 2 +- arch/um/drivers/mconsole_kern.c | 2 +- arch/um/kernel/sysrq.c | 7 +------ arch/unicore32/kernel/traps.c | 7 +------ arch/x86/kernel/amd_gart_64.c | 2 +- arch/x86/kernel/dumpstack.c | 7 +------ arch/xtensa/kernel/traps.c | 10 ++-------- drivers/base/power/main.c | 2 +- drivers/tty/sysrq.c | 2 +- include/linux/sched/debug.h | 5 ++--- kernel/debug/kdb/kdb_bt.c | 8 ++++---- kernel/locking/rtmutex-debug.c | 2 +- kernel/sched/core.c | 2 +- lib/dump_stack.c | 2 +- 39 files changed, 54 insertions(+), 200 deletions(-)
arch/alpha/kernel/traps.c +1 -7
@@ -144,8 +144,7 @@ dik_show_trace(unsigned long *sp, const char *loglvl)static int kstack_depth_to_print =24 ; -void show_stack_loglvl (struct task_struct *task,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *sp,const char *loglvl) {unsigned long *stack;int i;
@@ -174,11 +173,6 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *sp,dik_show_trace (sp, loglvl); } -void show_stack (struct task_struct *task,unsigned long *sp) -{ -show_stack_loglvl (task, sp,KERN_DEFAULT ); -} -void die_if_kernel (char * str,struct pt_regs *regs,long err,unsigned long *r9_15) {
arch/arc/kernel/stacktrace.c +1 -7
@@ -228,17 +228,11 @@ noinline void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs,EXPORT_SYMBOL (show_stacktrace);/* Expected by sched Code */ -void show_stack_loglvl (struct task_struct *tsk,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *tsk,unsigned long *sp,const char *loglvl) {show_stacktrace (tsk,NULL , loglvl); } -void show_stack (struct task_struct *tsk,unsigned long *sp) -{ -show_stack_loglvl (tsk, sp,KERN_DEFAULT ); -} -/* Another API expected by schedular, shows up in "ps" as Wait Channel * Of course just returning schedule( ) would be pointless so unwind until * the function is not in schedular code
arch/arm/kernel/traps.c +1 -7
@@ -246,18 +246,12 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, }#endif -void show_stack_loglvl (struct task_struct *tsk,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *tsk,unsigned long *sp,const char *loglvl) {dump_backtrace (NULL , tsk, loglvl);barrier (); } -void show_stack (struct task_struct *tsk,unsigned long *sp) -{ -show_stack_loglvl (tsk, sp,KERN_DEFAULT ); -} -#ifdef CONFIG_PREEMPT #define S_PREEMPT " PREEMPT"#else
arch/arm64/kernel/traps.c +1 -7
@@ -136,18 +136,12 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,put_task_stack (tsk); } -void show_stack_loglvl (struct task_struct *tsk,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *tsk,unsigned long *sp,const char *loglvl) {dump_backtrace (NULL , tsk, loglvl);barrier (); } -void show_stack (struct task_struct *tsk,unsigned long *sp) -{ -show_stack_loglvl (tsk, sp,KERN_DEFAULT ); -} -#ifdef CONFIG_PREEMPT #define S_PREEMPT " PREEMPT"#else
arch/c6x/kernel/traps.c +1 -6
@@ -374,7 +374,7 @@ static void show_trace(unsigned long *stack, unsigned long *endstack,printk ("%s\n" , loglvl); } -void show_stack_loglvl (struct task_struct *task,unsigned long *stack, +void show_stack (struct task_struct *task,unsigned long *stack,const char *loglvl) {unsigned long *p, *endstack;
@@ -403,11 +403,6 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *stack,show_trace (stack, endstack, loglvl); } -void show_stack (struct task_struct *task,unsigned long *stack) -{ -show_stack_loglvl (task, stack,KERN_DEBUG ); -} -int is_valid_bugaddr (unsigned long addr) {return __kernel_text_address (addr);
arch/csky/kernel/dumpstack.c +1 -6
@@ -32,7 +32,7 @@ static void show_trace(unsigned long *stack, const char *loglvl)pr_cont ("\n" ); } -void show_stack_loglvl (struct task_struct *task,unsigned long *stack, +void show_stack (struct task_struct *task,unsigned long *stack,const char *loglvl) {if (!stack) {
@@ -48,8 +48,3 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *stack,show_trace (stack, loglvl); } - -void show_stack (struct task_struct *task,unsigned long *stack) -{ -show_stack_loglvl (task, stack,KERN_INFO ); -}
arch/csky/kernel/ptrace.c +2 -2
@@ -235,7 +235,7 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs)trace_sys_exit (regs,syscall_get_return_value (current, regs)); } -extern void show_stack (struct task_struct *task,unsigned long *stack); +extern void show_stack (struct task_struct *task,unsigned long *stack,const char *loglvl);void show_regs (struct pt_regs *fp) {unsigned long *sp;
@@ -311,6 +311,6 @@ void show_regs(struct pt_regs *fp) }pr_cont ("\n" ); -show_stack (NULL , (unsigned long *)fp->regs[4 ]); +show_stack (NULL , (unsigned long *)fp->regs[4 ],KERN_INFO );return ; }
arch/h8300/kernel/traps.c +1 -7
@@ -115,8 +115,7 @@ void die(const char *str, struct pt_regs *fp, unsigned long err)static int kstack_depth_to_print =24 ; -void show_stack_loglvl (struct task_struct *task,unsigned long *esp, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *esp,const char *loglvl) {unsigned long *stack, addr;int i;
@@ -158,8 +157,3 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *esp, }printk ("%s\n" , loglvl); } - -void show_stack (struct task_struct *task,unsigned long *esp) -{ -show_stack_loglvl (task, esp,KERN_INFO ); -}
arch/hexagon/kernel/traps.c +1 -7
@@ -175,18 +175,12 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp, } } -void show_stack_loglvl (struct task_struct *task,unsigned long *fp, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *fp,const char *loglvl) {/* Saved link reg is one word above FP */ do_show_stack (task, fp,0 , loglvl); } -void show_stack (struct task_struct *task,unsigned long *fp) -{ -show_stack_loglvl (task, fp,0 ,KERN_INFO ); -} -int die (const char *str,struct pt_regs *regs,long err) { static struct {
arch/ia64/kernel/mca.c +1 -1
@@ -1630,7 +1630,7 @@ default_monarch_init_process(struct notifier_block *self, unsigned long val, voiif (read_trylock (&tasklist_lock)) { do_each_thread (g, t) {printk ("\nBacktrace of pid %d (%s)\n" , t->pid, t->comm); -show_stack (t,NULL ); +show_stack (t,NULL ,KERN_DEFAULT ); }while_each_thread (g, t);read_unlock (&tasklist_lock); }
arch/ia64/kernel/process.c +2 -9
@@ -85,8 +85,7 @@ ia64_do_show_stack (struct unw_frame_info *info, void *arg) }void -show_stack_loglvl (struct task_struct *task,unsigned long *sp, -const char *loglvl) +show_stack (struct task_struct *task,unsigned long *sp,const char *loglvl) {if (!task)unw_init_running (ia64_do_show_stack, (void *)loglvl);
@@ -98,12 +97,6 @@ show_stack_loglvl (struct task_struct *task, unsigned long *sp, } } -void -show_stack (struct task_struct *task,unsigned long *sp) -{ -show_stack_loglvl (task, sp,KERN_DEFAULT ); -} -void show_regs (struct pt_regs *regs) {
@@ -158,7 +151,7 @@ show_regs (struct pt_regs *regs) ((i == sof - 1) || (i % 3) == 2) ? "\n" : " "); } }else -show_stack (NULL ,NULL ); +show_stack (NULL ,NULL ,KERN_DEFAULT ); }/* local support for deprecated console_print */
arch/m68k/kernel/traps.c +3 -8
@@ -916,7 +916,7 @@ void show_registers(struct pt_regs *regs)default :pr_cont ("\n" ); } -show_stack (NULL , (unsigned long *)addr); +show_stack (NULL , (unsigned long *)addr,KERN_INFO );pr_info ("Code:" );set_fs (KERNEL_DS );
@@ -935,8 +935,8 @@ void show_registers(struct pt_regs *regs)pr_cont ("\n" ); } -void show_stack_loglvl (struct task_struct *task,unsigned long *stack, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *stack, +const char *loglvl) {unsigned long *p;unsigned long *endstack;
@@ -963,11 +963,6 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *stack,show_trace (stack, loglvl); } -void show_stack (struct task_struct *task,unsigned long *stack) -{ -show_stack_loglvl (task, stack,KERN_INFO ); -} -/* * The vector number returned in the frame pointer may also contain * the "fs" (Fault Status) bits on ColdFire. These are in the bottom
arch/microblaze/kernel/traps.c +1 -7
@@ -31,8 +31,7 @@ static int __init kstack_setup(char *s) }__setup ("kstack=" , kstack_setup); -void show_stack_loglvl (struct task_struct *task,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *sp,const char *loglvl) {unsigned long words_to_show;u32 fp = (u32 ) sp;
@@ -77,8 +76,3 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *sp,debug_show_held_locks (task); } - -void show_stack (struct task_struct *task,unsigned long *sp) -{ -show_stack_loglvl (task, sp,KERN_INFO ); -}
arch/mips/kernel/traps.c +1 -7
@@ -196,8 +196,7 @@ static void show_stacktrace(struct task_struct *task,show_backtrace (task, regs, loglvl); } -void show_stack_loglvl (struct task_struct *task,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *sp,const char *loglvl) {struct pt_regs regs;mm_segment_t old_fs =get_fs ();
@@ -230,11 +229,6 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *sp,set_fs (old_fs); } -void show_stack (struct task_struct *task,unsigned long *sp) -{ - show_stack_loglvl(task, sp, KERN_DEFAULT) -} -static void show_code (unsigned int __user *pc) {long i;
arch/nds32/kernel/traps.c +1 -7
@@ -135,8 +135,7 @@ static void __dump(struct task_struct *tsk, unsigned long *base_reg,printk ("%s\n" , loglvl); } -void show_stack_loglvl (struct task_struct *tsk,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *tsk,unsigned long *sp,const char *loglvl) {unsigned long *base_reg;
@@ -157,11 +156,6 @@ void show_stack_loglvl(struct task_struct *tsk, unsigned long *sp,barrier (); } -void show_stack (struct task_struct *tsk,unsigned long *sp) -{ -show_stack_loglvl (tsk, sp,KERN_EMERG ); -} -DEFINE_SPINLOCK (die_lock);/*
arch/nios2/kernel/traps.c +3 -9
@@ -52,14 +52,13 @@ void _exception(int signo, struct pt_regs *regs, int code, unsigned long addr) }/* -* The show_stack(), show_stack_loglvl() are external API -* which we do not use ourselves. +* The show_stack() is external API which we do not use ourselves. */ int kstack_depth_to_print =48 ; -void show_stack_loglvl (struct task_struct *task,unsigned long *stack, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *stack, +const char *loglvl) {unsigned long *endstack, addr;int i;
@@ -106,11 +105,6 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *stack,printk ("%s\n" , loglvl); } -void show_stack (struct task_struct *task,unsigned long *stack) -{ -show_stack_loglvl (task, stack,KERN_EMERG ); -} -void __init trap_init (void ) {/* Nothing to do here */
arch/openrisc/kernel/traps.c +2 -8
@@ -48,8 +48,7 @@ void print_trace(void *data, unsigned long addr, int reliable) }/* displays a short stack trace */ -void show_stack_loglvl (struct task_struct *task,unsigned long *esp, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *esp,const char *loglvl) {if (esp ==NULL ) esp = (unsigned long *)&esp;
@@ -58,11 +57,6 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *esp,unwind_stack ((void *)loglvl, esp, print_trace); } -void show_stack (struct task_struct *task,unsigned long *esp) -{ -show_stack_loglvl (task, esp,KERN_EMERG ); -} -void show_trace_task (struct task_struct *tsk) {/*
@@ -111,7 +105,7 @@ void show_registers(struct pt_regs *regs)if (in_kernel) {printk ("\nStack: " ); -show_stack (NULL , (unsigned long *)esp); +show_stack (NULL , (unsigned long *)esp,KERN_EMERG );printk ("\nCode: " );if (regs->pc <PAGE_OFFSET )
arch/parisc/kernel/traps.c +1 -7
@@ -198,17 +198,11 @@ static void parisc_show_stack(struct task_struct *task,do_show_stack (&info, loglvl); } -void show_stack_loglvl (struct task_struct *t,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *t,unsigned long *sp,const char *loglvl) {parisc_show_stack (t,NULL , loglvl); } -void show_stack (struct task_struct *t,unsigned long *sp) -{ - show_stack_loglvl(t, sp, KERN_CRIT) -} -int is_valid_bugaddr (unsigned long iaoq) {return 1 ;
arch/powerpc/kernel/process.c +3 -8
@@ -1431,7 +1431,7 @@ void show_regs(struct pt_regs * regs)printk ("NIP [" REG "] %pS\n" , regs->nip, (void *)regs->nip);printk ("LR [" REG "] %pS\n" , regs->link, (void *)regs->link);#endif -show_stack (current, (unsigned long *) regs->gpr[1 ]); +show_stack (current, (unsigned long *) regs->gpr[1 ],KERN_DEFAULT );if (!user_mode (regs))show_instructions (regs); }
@@ -2028,8 +2028,8 @@ unsigned long get_wchan(struct task_struct *p)static int kstack_depth_to_print =CONFIG_PRINT_STACK_DEPTH ; -void show_stack_loglvl (struct task_struct *tsk,unsigned long *stack, -const char *loglvl) +void show_stack (struct task_struct *tsk,unsigned long *stack, +const char *loglvl) {unsigned long sp, ip, lr, newsp;int count =0 ;
@@ -2098,11 +2098,6 @@ void show_stack_loglvl(struct task_struct *tsk, unsigned long *stack,put_task_stack (tsk); } -void show_stack (struct task_struct *tsk,unsigned long *stack) -{ -show_stack_loglvl (tsk, stack,KERN_DEFAULT ); -} -#ifdef CONFIG_PPC64 /* Called with hard IRQs off */ void notrace __ppc64_runlatch_on(void)
arch/powerpc/kernel/stacktrace.c +1 -1
@@ -260,7 +260,7 @@ static void raise_backtrace_ipi(cpumask_t *mask)pr_cont (" current pointer corrupt? (%px)\n" , p->__current);pr_warn ("Back trace of paca->saved_r1 (0x%016llx) (possibly stale):\n" , p->saved_r1); -show_stack (p->__current, (unsigned long *)p->saved_r1); +show_stack (p->__current, (unsigned long *)p->saved_r1,KERN_WARNING ); } }
arch/riscv/kernel/stacktrace.c +1 -7
@@ -104,18 +104,12 @@ static bool print_trace_address(unsigned long pc, void *arg)return false; } -void show_stack_loglvl (struct task_struct *task,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *sp,const char *loglvl) {pr_cont ("Call Trace:\n" );walk_stackframe (task,NULL , print_trace_address, (void *)loglvl); } -void show_stack (struct task_struct *task,unsigned long *sp) -{ -show_stack_loglvl (task, sp,KERN_DEFAULT ); -} -static bool save_wchan (unsigned long pc,void *arg) {if (!in_sched_functions (pc)) {
arch/s390/kernel/dumpstack.c +1 -6
@@ -123,7 +123,7 @@ int get_stack_info(unsigned long sp, struct task_struct *task,return -EINVAL ; } -void show_stack_loglvl (struct task_struct *task,unsigned long *stack, +void show_stack (struct task_struct *task,unsigned long *stack,const char *loglvl) {struct unwind_state state;
@@ -138,11 +138,6 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *stack,debug_show_held_locks (task ? : current); } -void show_stack (struct task_struct *task,unsigned long *stack) -{ -show_stack_loglvl (task, stack,KERN_DEFAULT ); -} -static void show_last_breaking_event (struct pt_regs *regs) {printk ("Last Breaking-Event-Address:\n" );
arch/sh/kernel/dumpstack.c +1 -7
@@ -144,8 +144,7 @@ void show_trace(struct task_struct *tsk, unsigned long *sp,debug_show_held_locks (tsk); } -void show_stack_loglvl (struct task_struct *tsk,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *tsk,unsigned long *sp,const char *loglvl) {unsigned long stack;
@@ -161,8 +160,3 @@ void show_stack_loglvl(struct task_struct *tsk, unsigned long *sp, (unsigned long)task_stack_page(tsk));show_trace (tsk, sp,NULL , loglvl); } - -void show_stack (struct task_struct *task,unsigned long *sp) -{ -show_stack_loglvl (task, sp,KERN_DEFAULT ); -}
arch/sh/kernel/process_64.c +1 -2
@@ -275,13 +275,12 @@ void show_regs(struct pt_regs *regs)* If we're in kernel mode, dump the stack too.. */ if (!user_mode (regs)) { -void show_stack (struct task_struct *tsk,unsigned long *sp);unsigned long sp = regs->regs[15 ] &0xffffffff ;struct task_struct *tsk =get_current (); tsk->thread.kregs = regs; -show_stack (tsk, (unsigned long *)sp); +show_stack (tsk, (unsigned long *)sp,KERN_DEFAULT ); } }
arch/sparc/kernel/process_32.c +2 -9
@@ -145,12 +145,10 @@ void show_regs(struct pt_regs *r) }/* -* The show_stack(), show_stack_loglvl() are external APIs which -* we do not use ourselves. +* The show_stack() is external API which we do not use ourselves. * The oops is printed in die_if_kernel. */ -void show_stack_loglvl (struct task_struct *task,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *sp,const char *loglvl) {unsigned long pc, fp;unsigned long task_base;
@@ -179,11 +177,6 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *sp,printk ("%s\n" , loglvl); } -void show_stack (struct task_struct *task,unsigned long *sp) -{ -show_stack_loglvl (task, sp,KERN_DEFAULT ); -} -/* * Free current thread data structures etc.. */
arch/sparc/kernel/process_64.c +1 -1
@@ -195,7 +195,7 @@ void show_regs(struct pt_regs *regs) regs->u_regs[15]);printk ("RPC: <%pS>\n" , (void *) regs->u_regs[15 ]);show_regwindow (regs); -show_stack (current, (unsigned long *) regs->u_regs[UREG_FP ]); +show_stack (current, (unsigned long *)regs->u_regs[UREG_FP ],KERN_DEFAULT ); }union global_cpu_snapshot global_cpu_snapshot[NR_CPUS ];
arch/um/drivers/mconsole_kern.c +1 -1
@@ -642,7 +642,7 @@ static void stack_proc(void *arg) {struct task_struct *task = arg; -show_stack (task,NULL ); +show_stack (task,NULL ,KERN_INFO ); }/*
arch/um/kernel/sysrq.c +1 -6
@@ -27,7 +27,7 @@ static const struct stacktrace_ops stackops = { .address = _print_addr }; -void show_stack_loglvl (struct task_struct *task,unsigned long *stack, +void show_stack (struct task_struct *task,unsigned long *stack,const char *loglvl) {struct pt_regs *segv_regs = current->thread.segv_regs;
@@ -56,8 +56,3 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *stack,dump_trace (current, &stackops, (void *)loglvl);printk ("%s\n" , loglvl); } - -void show_stack (struct task_struct *task,unsigned long *stack) -{ -show_stack_loglvl (task, stack,KERN_INFO ); -}
arch/unicore32/kernel/traps.c +1 -6
@@ -167,18 +167,13 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,c_backtrace (fp, loglvl); } -void show_stack_loglvl (struct task_struct *tsk,unsigned long *sp, +void show_stack (struct task_struct *tsk,unsigned long *sp,const char *loglvl) {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) {
arch/x86/kernel/amd_gart_64.c +1 -1
@@ -159,7 +159,7 @@ static void dump_leak(void)return ; dump =1 ; -show_stack_loglvl (NULL ,NULL ,KERN_ERR ); +show_stack (NULL ,NULL ,KERN_ERR ); debug_dma_dump_mappings(NULL); }#endif
arch/x86/kernel/dumpstack.c +1 -6
@@ -279,7 +279,7 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, } } -void show_stack_loglvl (struct task_struct *task,unsigned long *sp, +void show_stack (struct task_struct *task,unsigned long *sp,const char *loglvl) { task = task ? : current;
@@ -294,11 +294,6 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *sp,show_trace_log_lvl (task,NULL , sp, loglvl); } -void show_stack (struct task_struct *task,unsigned long *sp) -{ -show_stack_loglvl (task, sp,KERN_DEFAULT ); -} -void show_stack_regs (struct pt_regs *regs) {show_trace_log_lvl (current, regs,NULL ,KERN_DEFAULT );
arch/xtensa/kernel/traps.c +2 -8
@@ -502,8 +502,7 @@ static void show_trace(struct task_struct *task, unsigned long *sp,static int kstack_depth_to_print =24 ; -void show_stack_loglvl (struct task_struct *task,unsigned long *sp, -const char *loglvl) +void show_stack (struct task_struct *task,unsigned long *sp,const char *loglvl) {int i =0 ;unsigned long *stack;
@@ -524,11 +523,6 @@ void show_stack_loglvl(struct task_struct *task, unsigned long *sp,show_trace (task, stack, loglvl); } -void show_stack (struct task_struct *task,unsigned long *sp) -{ -show_stack_loglvl (task, sp,KERN_INFO ); -} -DEFINE_SPINLOCK (die_lock);void die (const char * str,struct pt_regs * regs,long err)
@@ -542,7 +536,7 @@ void die(const char * str, struct pt_regs * regs, long err) IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "");show_regs (regs);if (!user_mode (regs)) -show_stack (NULL , (unsigned long *)regs->areg[1 ]); +show_stack (NULL , (unsigned long *)regs->areg[1 ],KERN_INFO );add_taint (TAINT_DIE ,LOCKDEP_NOW_UNRELIABLE );spin_unlock_irq (&die_lock);
drivers/base/power/main.c +1 -1
@@ -487,7 +487,7 @@ static void dpm_watchdog_handler(struct timer_list *t)struct dpm_watchdog *wd =from_timer (wd, t, timer);dev_emerg (wd->dev,"**** DPM device timeout ****\n" ); -show_stack_loglvl (wd->tsk,NULL ,KERN_EMERG ); +show_stack (wd->tsk,NULL ,KERN_EMERG );panic ("%s %s: unrecoverable failure\n" ,dev_driver_string (wd->dev),dev_name (wd->dev)); }
drivers/tty/sysrq.c +1 -1
@@ -220,7 +220,7 @@ static void showacpu(void *dummy)raw_spin_lock_irqsave (&show_lock, flags);pr_info ("CPU%d:\n" ,smp_processor_id ()); -show_stack_loglvl (NULL ,NULL ,KERN_INFO ); +show_stack (NULL ,NULL ,KERN_INFO );raw_spin_unlock_irqrestore (&show_lock, flags); }
include/linux/sched/debug.h +2 -3
@@ -30,9 +30,8 @@ extern void show_regs(struct pt_regs *);* task), SP is the stack pointer of the first frame that should be shown in the back * trace (or NULL if the entire call-chain of the task should be shown). */ -extern void show_stack (struct task_struct *task,unsigned long *sp); -extern void show_stack_loglvl (struct task_struct *task,unsigned long *sp, -const char *loglvl); +extern void show_stack (struct task_struct *task,unsigned long *sp, +const char *loglvl);extern void sched_show_task (struct task_struct *p);
kernel/debug/kdb/kdb_bt.c +4 -4
@@ -24,15 +24,15 @@ static void kdb_show_stack(struct task_struct *p, void *addr) kdb_trap_printk++;kdb_set_current_task (p);if (addr) { -show_stack_loglvl (p, addr,KERN_EMERG ); +show_stack (p, addr,KERN_EMERG ); }else if (kdb_current_regs) {#ifdef CONFIG_X86 -show_stack_loglvl (p, &kdb_current_regs->sp,KERN_EMERG ); +show_stack (p, &kdb_current_regs->sp,KERN_EMERG );#else -show_stack_loglvl (p,NULL ,KERN_EMERG ); +show_stack (p,NULL ,KERN_EMERG );#endif }else { -show_stack_loglvl (p,NULL ,KERN_EMERG ); +show_stack (p,NULL ,KERN_EMERG ); } kdb_trap_printk--; }
kernel/locking/rtmutex-debug.c +1 -1
@@ -125,7 +125,7 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)printk ("\n%s/%d's [blocked] stackdump:\n\n" , task->comm,task_pid_nr (task)); -show_stack_loglvl (task,NULL ,KERN_DEFAULT ); +show_stack (task,NULL ,KERN_DEFAULT );printk ("\n%s/%d's [current] stackdump:\n\n" , current->comm,task_pid_nr (current));dump_stack ();
kernel/sched/core.c +1 -1
@@ -5932,7 +5932,7 @@ void sched_show_task(struct task_struct *p) (unsigned long)task_thread_info(p)->flags);print_worker_info (KERN_INFO , p); -show_stack_loglvl (p,NULL ,KERN_INFO ); +show_stack (p,NULL ,KERN_INFO );put_task_stack (p); }EXPORT_SYMBOL_GPL (sched_show_task);
lib/dump_stack.c +1 -1
@@ -74,7 +74,7 @@ void show_regs_print_info(const char *log_lvl)static void __dump_stack (void ) {dump_stack_print_info (KERN_DEFAULT ); -show_stack_loglvl (NULL ,NULL ,KERN_DEFAULT ); +show_stack (NULL ,NULL ,KERN_DEFAULT ); }/**
Signature · 1 line
2.23.0
kbuild test robot
build botRe: [PATCH 50/50] kernel: Rename show_stack_loglvl() => show_stack()
Thank you for the patch! Yet something to improve:
Hi Dmitry,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.4-rc6]
[cannot apply to next-20191108]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Dmitry-Safonov/kallsyms-printk-Add-loglvl-to-print_ip_sym/20191108-124037 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 847120f859cc45e074204f4cf33c8df069306eb2 config: s390-allnoconfig (attached as .config) compiler: s390-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=s390
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
arch/s390/kernel/dumpstack.c: In function 'show_regs':
>> arch/s390/kernel/dumpstack.c:178:3: error: too few arguments to function 'show_stack'
show_stack(NULL, (unsigned long *) regs->gprs[15]);
^~~~~~~~~~ arch/s390/kernel/dumpstack.c:126:6: note: declared here
void show_stack(struct task_struct *task, unsigned long *stack,
^~~~~~~~~~
vim +/show_stack +178 arch/s390/kernel/dumpstack.c
1bca09f7144450 Heiko Carstens 2013-03-14 171
1bca09f7144450 Heiko Carstens 2013-03-14 172 void show_regs(struct pt_regs *regs)
1bca09f7144450 Heiko Carstens 2013-03-14 173 {
a43cb95d547a06 Tejun Heo 2013-04-30 174 show_regs_print_info(KERN_DEFAULT);
1bca09f7144450 Heiko Carstens 2013-03-14 175 show_registers(regs);
1bca09f7144450 Heiko Carstens 2013-03-14 176 /* Show stack backtrace if pt_regs is from kernel mode */
1bca09f7144450 Heiko Carstens 2013-03-14 177 if (!user_mode(regs))
2b7b9817c2dbfc Heiko Carstens 2017-06-06 @178 show_stack(NULL, (unsigned long *) regs->gprs[15]);
1bca09f7144450 Heiko Carstens 2013-03-14 179 show_last_breaking_event(regs);
1bca09f7144450 Heiko Carstens 2013-03-14 180 }1bca09f7144450 Heiko Carstens 2013-03-14 181
:::::: The code at line 178 was first introduced by commit
:::::: 2b7b9817c2dbfce0501a313db817718fc5ef6524 s390/dumpstack: remove raw stack dump
:::::: TO: Heiko Carstens <[email protected]> :::::: CC: Martin Schwidefsky <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
Quoted 11 lines · Dmitry Safonov
Add log level argument to
show_stack().
Done in three stages:
1. Introducingshow_stack_loglvl()for every architecture
2. Migrating old users with an explicit log level
3. Renamingshow_stack_loglvl()intoshow_stack()Justification:
o It's a design mistake to move a business-logic decision into platform realization detail.
o I have currently two patches sets that would benefit from this work:
Removingconsole_logleveljumps in sysrq driver [1]
Just to clarify. The problem in sysrq driver is a bit different. It modifies console_loglevel to show even less important message on the console.
IMHO, it should be solved by printing the header line with pr_error(). It is not ideal. A cleaner solution might be to introduce another loglevel that will always get pushed to the console. But I am not sure if it is worth this single line.
Quoted 8 lines
Hung task warning before panic [2] - suggested by Tetsuo (but he probably didn't realise what it would involve).
o While doing (1), (2) the backtraces were adjusted to headers and other messages for each situation - so there won't be a situation when the backtrace is printed, but the headers are missing because they have lesser log level (or the reverse).
o As the result in (2) plays withconsole_loglevelfor kdb are removed.
Quoted 6 lines
The least important for upstream, but maybe still worth to note that every company I've worked in so far had an off-list patch to print backtrace with the needed log level (but only for the architecture they cared about).
If you have other ideas how you will benefit fromshow_stack()with a log level - please, reply to this cover letter.
I agree with all the other justification.
I would add. The backtrace is really useful for debugging. It should be possible to print it even in less critical situations.
I am afraid that many people use WARN() for this purpose. But WARN() is not always appropriate. WARN() misuse huts when panic_on_warn option is used.
Best Regards,
Petr
Quoted 13 lines · Petr Mladek
Quoted 11 lines · Dmitry Safonov
Add log level argument to
show_stack().
Done in three stages:
1. Introducingshow_stack_loglvl()for every architecture
2. Migrating old users with an explicit log level
3. Renamingshow_stack_loglvl()intoshow_stack()Justification:
o It's a design mistake to move a business-logic decision into platform realization detail.
o I have currently two patches sets that would benefit from this work:
Removingconsole_logleveljumps in sysrq driver [1]
Quoted 8 lines
Just to clarify. The problem in sysrq driver is a bit different. It modifies
console_loglevelto show even less important message on the console.IMHO, it should be solved by printing the header line with
pr_error(). It is not ideal. A cleaner solution might be to introduce another loglevel that will always get pushed to the console. But I am not sure if it is worth this single line.
I believe why it's not done - there is a comment in sysrq code that said the userspace relies on the loglevel of sysrq messages (and may trigger alerts from emerg/err log level):
* Raise the apparent loglevel to maximum so that the sysrq header
* is shown to provide the user with positive feedback. We do not
* simply emit this at KERN_EMERG as that would change message
* routing in the consumers of /proc/kmsg.
But I don't mind any solution.
Quoted 15 lines
Quoted 8 lines
Hung task warning before panic [2] - suggested by Tetsuo (but he probably didn't realise what it would involve).
o While doing (1), (2) the backtraces were adjusted to headers and other messages for each situation - so there won't be a situation when the backtrace is printed, but the headers are missing because they have lesser log level (or the reverse).
o As the result in (2) plays withconsole_loglevelfor kdb are removed.Quoted 6 lines
The least important for upstream, but maybe still worth to note that every company I've worked in so far had an off-list patch to print backtrace with the needed log level (but only for the architecture they cared about).
If you have other ideas how you will benefit fromshow_stack()with a log level - please, reply to this cover letter.
Quoted 8 lines
I agree with all the other justification.
I would add. The backtrace is really useful for debugging. It should be possible to print it even in less critical situations.
I am afraid that many people use
WARN()for this purpose. ButWARN()is not always appropriate.WARN()misuse huts whenpanic_on_warnoption is used.
Thanks, Petr.
Signature · 1 line
Dmitry
Quoted 4 lines · Petr Mladek
I agree with all the other justification.
I would add. The backtrace is really useful for debugging. It should be possible to print it even in less critical situations.
Hmm, I don't know.
Do we really need debug/info level backtraces? May be all backtraces can be converted to something more severe (so we can stop playing games with loglvl) and then we can clean up "(ab)users"?
-ss
Quoted 8 lines · Sergey Senozhatsky
Quoted 4 lines · Petr Mladek
I agree with all the other justification.
I would add. The backtrace is really useful for debugging. It should be possible to print it even in less critical situations.
Hmm, I don't know.
Do we really need debug/info level backtraces?
debug is exactly the loglevel where registry content and backtrace might be very useful. It is not always important to reach the console.
Quoted 3 lines
May be all backtraces can be converted to something more severe (so we can stop playing games with loglvl) and then we can clean up "(ab)users"?
IMHO, we should distinguish warning, error, crit, alert, emerg situations. Backtraces and any related messages should be filtered the same way. Any information might be useless without the context.
I agree that it is complicated to pass the loglevel as a parameter. It would be better define the default log level for a given code section. It might be stored in task_struct for the normal context and in per-CPU variables for interrupt contexts.
Best Regards,
Petr
On (19/11/08 14:04), Petr Mladek wrote:
[..]
Quoted 5 lines
I agree that it is complicated to pass the loglevel as a parameter. It would be better define the default log level for a given code section. It might be stored in
task_structfor the normal context and in per-CPU variables for interrupt contexts.
I do recall that we talked about per-CPU printk state bit which would start/end "just print it" section. We probably can extend it to "just log_store" type of functionality. Doesn't look like a very bad idea. "This task/context is in trouble, whatever it printk()-s is important".
Per-console loglevel also might help sometimes. Slower consoles would ->write() only critical messages, faster consoles everything.
Passing log_level as part of message payload, which printk machinery magically hides is not entirely exciting. What we have in the code now - printk("%s blah\n", lvl) - is not what we see in the logs. Because the leading '%s' becomes special. And printk()/sprintf() documentation should reflect that: '%s' prints a string, but sometimes it doesn't.
-ss
Quoted 11 lines · Sergey Senozhatsky
On (19/11/08 14:04), Petr Mladek wrote:
[..]Quoted 5 lines
I agree that it is complicated to pass the loglevel as a parameter. It would be better define the default log level for a given code section. It might be stored in
task_structfor the normal context and in per-CPU variables for interrupt contexts.I do recall that we talked about per-CPU printk state bit which would start/end "just print it" section. We probably can extend it to "just
log_store" type of functionality. Doesn't look like a very bad idea.
The problem with per-CPU printk is that we would need to disable interrupts. It is not always wanted. Also people might not expect this from a printk() API.
Quoted 1 line
"This task/context is in trouble, whatever it printk()-s is important".
It might be a minimal loglevel. More important messages would still be printed() with the higher loglevel.
But yes, this per-code-section loglevel is problematic. The feedback against the patchset shows that people want it also the other way. I mean to keep pr_debug() as pr_debug().
A solution might be to use the per-code-section loglevel only instead of some special loglevel.
Quoted 2 lines
Per-console loglevel also might help sometimes. Slower consoles would ->write() only critical messages, faster consoles everything.
This looks like another problem to me. Anyway, this filtering will work better when the loglevel will be consistent across the related lines.
Quoted 6 lines
Passing
log_levelas part of message payload, which printk machinery magically hides is not entirely exciting. What we have in the code now -printk("%s blah\n", lvl)- is not what we see in the logs. Because the leading '%s' becomes special. And printk()/sprintf() documentation should reflect that: '%s' prints a string, but sometimes it doesn't.
I personally do not see this as a big problem.
The explicitly passed loglevel makes me feel more confident that all needed printk() calls were updated. But it might be a false feeling. I do not really have any strong preference.
Best Regards,
Petr
On (19/11/11 10:12), Petr Mladek wrote:
[..]
Quoted 6 lines
Quoted 3 lines
I do recall that we talked about per-CPU printk state bit which would start/end "just print it" section. We probably can extend it to "just
log_store" type of functionality. Doesn't look like a very bad idea.The problem with per-CPU printk is that we would need to disable interrupts.
Or disable preemption and have loglevel per-CPU and per-context. preempt_count can navigate us to the right context loglevel on particular CPU. I'm talking here only about backtrace (error) reporting contexts. Those can be atomic perfectly fine.
I posted a silly code snippet.
[..]
Quoted 3 lines
But yes, this per-code-section loglevel is problematic. The feedback against the patchset shows that people want it also the other way. I mean to keep
pr_debug()aspr_debug().
Hmm. Right.
Quoted 2 lines
A solution might be to use the per-code-section loglevel only instead of some special loglevel.
So maybe we can "overwrite" only KERN_DEFAULT loglevels? We certainly should not mess with SCHED or with anything in between EMERG and ERR.
Quoted 3 lines
The explicitly passed loglevel makes me feel more confident that all needed
printk()calls were updated. But it might be a false feeling. I do not really have any strong preference.
I'm not like really objecting, just trying to explore some other options.
-ss
On (19/11/12 13:44), Sergey Senozhatsky wrote:
[..]
Quoted 10 lines
Quoted 3 lines
But yes, this per-code-section loglevel is problematic. The feedback against the patchset shows that people want it also the other way. I mean to keep
pr_debug()aspr_debug().Hmm. Right.
Quoted 2 lines
A solution might be to use the per-code-section loglevel only instead of some special loglevel.
So maybe we can "overwrite" only
KERN_DEFAULTloglevels?
LOGLEVEL_DEFAULT, LOGLEVEL_NOTICE, LOGLEVEL_INFO?
So we can downgrade some messages (log_store() only) or promote some messages.
DEBUG perhaps should stay debug.
Quoted 2 lines
We certainly should not mess with SCHED or with anything in between EMERG and ERR.
[EMERG, WARN]
-ss
Quoted 18 lines · Sergey Senozhatsky
On (19/11/12 13:44), Sergey Senozhatsky wrote:
[..]Quoted 10 lines
Quoted 3 lines
But yes, this per-code-section loglevel is problematic. The feedback against the patchset shows that people want it also the other way. I mean to keep
pr_debug()aspr_debug().Hmm. Right.
Quoted 2 lines
A solution might be to use the per-code-section loglevel only instead of some special loglevel.
So maybe we can "overwrite" only
KERN_DEFAULTloglevels?
LOGLEVEL_DEFAULT,LOGLEVEL_NOTICE,LOGLEVEL_INFO?So we can downgrade some messages (
log_store()only) or promote some messages.
Quoted 6 lines
DEBUG perhaps should stay debug.
Quoted 2 lines
We certainly should not mess with SCHED or with anything in between EMERG and ERR.
[EMERG, WARN]
This is getting too complicated. It would introduce too many hidden rules. While the explicitly passed loglevel parameter is straightforward and clear.
I am getting more inclined to the solution introduced by this patchset. It looks reasonable for the different use-cases.
Best Regards,
Petr
On (19/11/12 09:35), Petr Mladek wrote:
[..]
Quoted 3 lines
This is getting too complicated. It would introduce too many hidden rules. While the explicitly passed loglevel parameter is straightforward and clear.
If loglevel is DEFAULT or NOTICE or INFO then we can overwrite it (either downgrade or upgrade). That's one rule, basically. Not too complicated, I guess.
Quoted 2 lines
I am getting more inclined to the solution introduced by this patchset. It looks reasonable for the different use-cases.
No pressure from my side. Up to arch maintainers.
-ss
Quoted 9 lines · Sergey Senozhatsky
On (19/11/12 09:35), Petr Mladek wrote:
[..]Quoted 3 lines
This is getting too complicated. It would introduce too many hidden rules. While the explicitly passed loglevel parameter is straightforward and clear.
If loglevel is DEFAULT or NOTICE or INFO then we can overwrite it (either downgrade or upgrade). That's one rule, basically. Not too complicated, I guess.
Can be taken even a bit further than
show_stack(NULL, NULL, LOGLEVEL_DEBUG); or show_stack(NULL, NULL, LOGLEVEL_ERR);
For instance,
spin_lock_irqsave(&rq->lock, flags); printk_emergency_enter(LOGLEVEL_SCHED); ... show_stack(...); printk(); printk(); ... spin_unlock_irqrestore(&rq->lock, flags);
or
spin_lock_irqsave(&uart_port->lock, flags); printk_emergency_enter(LOGLEVEL_SCHED); ... printk(); printk(); ...
and so on.
-ss
Quoted 28 lines · Sergey Senozhatsky
Quoted 9 lines · Sergey Senozhatsky
On (19/11/12 09:35), Petr Mladek wrote:
[..]Quoted 3 lines
This is getting too complicated. It would introduce too many hidden rules. While the explicitly passed loglevel parameter is straightforward and clear.
If loglevel is DEFAULT or NOTICE or INFO then we can overwrite it (either downgrade or upgrade). That's one rule, basically. Not too complicated, I guess.
Can be taken even a bit further than
show_stack(NULL, NULL, LOGLEVEL_DEBUG); or show_stack(NULL, NULL, LOGLEVEL_ERR);For instance,
spin_lock_irqsave(&rq->lock, flags); printk_emergency_enter(LOGLEVEL_SCHED); ... show_stack(...); printk(); printk(); ... spin_unlock_irqrestore(&rq->lock, flags);
Quoted 8 lines
or
spin_lock_irqsave(&uart_port->lock, flags); printk_emergency_enter(LOGLEVEL_SCHED); ... printk(); printk(); ...
Yeah, that makes sense.
I believe it's up to you, Petr and Steven to decide what's better for printk(). I mean, after all you care for all this code.
I guess I've pointed that in my point of view price for one-time testing code is cheaper than adding a new printk feature to swap log levels on the fly. But again, it's just how I see it - if we fix those printing problems, than in half year we will forget they ever existed, but in your proposal, there will still be some clever printk code.
On the other side, also worth to note that current patches set fix problems for kdb (and for my hung task printing patch), but it's incomplete for sysrq driver. I've gone through functions used by sysrq driver and the same changes introducing log level parameter would be needed for: sched_show_task(), debug_show_all_locks(), show_regs(), show_state(), show_mem(). Some of them don't need any platform changes, but at least show_regs() needs.
So, you also need to have that in mind making the decision.
Thanks,
Dmitry
Quoted 3 lines · Dmitry Safonov
I guess I've pointed that in my point of view price for one-time testing code is cheaper than adding a new printk feature to swap log levels on the fly.
[..]
Quoted 4 lines
I've gone through functions used by sysrq driver and the same changes introducing log level parameter would be needed for:
sched_show_task(),debug_show_all_locks(),show_regs(),show_state(),show_mem(). Some of them don't need any platform changes, but at leastshow_regs()needs.
Good points and nice conclusion.
Well, here we go. There is a number of generally useful functions that print nice data and where people might want to have better loglevel control (for debugging purposes). show_stack() is just one of them. Patching all those functions, which you have mentioned above, is hardly a fun task to do. Hence the printk() per-CPU per-context loglevel proposition. The code there is not clever or complicated and is meant for debugging purposes only, but with just 3 lines of code one can do some stuff:
/* @BTW you can't do this with "%s" KERN_FOO ;P */
+ printk_emergency_enter(LOGLEVEL_SCHED);
+ debug_show_all_locks();
+ printk_emergency_exit();
Now...
I'm not sure if this whole thing is up to "printk maintainers only". If no one is going to use "emergency printk contexts" then there is no point in having that code in the kernel.
-ss
Quoted 10 lines · Sergey Senozhatsky
Quoted 3 lines · Dmitry Safonov
I guess I've pointed that in my point of view price for one-time testing code is cheaper than adding a new printk feature to swap log levels on the fly.
[..]
Quoted 4 lines
I've gone through functions used by sysrq driver and the same changes introducing log level parameter would be needed for:
sched_show_task(),debug_show_all_locks(),show_regs(),show_state(),show_mem(). Some of them don't need any platform changes, but at leastshow_regs()needs.
Quoted 5 lines
Good points and nice conclusion.
Well, here we go. There is a number of generally useful functions that print nice data and where people might want to have better loglevel control (for debugging purposes).
show_stack()is just one of them.
Could you please provide some examples so that we get an idea about the scope, usefulness, and requirements?
Review
Quoted 10 lines
Patching all
those functions, which you have mentioned above, is hardly a fun task to do. Hence theprintk()per-CPU per-context loglevel proposition. The code there is not clever or complicated and is meant for debugging purposes only, but with just 3 lines of code one can do some stuff:/* @BTW you can't do this with "%s" KERN_FOO ;P */(quoted diff) +3
-0+ printk_emergency_enter(LOGLEVEL_SCHED); + debug_show_all_locks(); + printk_emergency_exit();
But this will not solve situations where the original loglevel should stay from any reason. It happened in this patchset, see
https://lkml.kernel.org/r/[email protected]
https://lkml.kernel.org/r/20191106132516.GC5808@willie-the-truck
We would need to investigate more potential users of this feature to see eventual requirements. If there are too many exceptions and modes then the generic API might get pretty complicated.
At the moment, I am in favor of this patchset. It is huge and needed a lot of manual work. But the result is straightforward and easy to understand.
Best Regards,
Petr
Steven Rostedt
maintainerQuoted 3 lines · On Wed, 13 Nov 2019 09:47:22 +0100 Petr Mladek <[email protected]> wrote:
At the moment, I am in favor of this patchset. It is huge and needed a lot of manual work. But the result is straightforward and easy to understand.
I'm in favor of this patchset too. If there's other areas that need to adjust the current loglevel (say per task context), then we can cross that bridge when the need arises. But I don't want to over engineer this as the stack trace logic should have a way to explicitly state how important this stack trace really is (or better yet, we should be removing stack traces that are not important!)
-- Steve
Hi Sergey,
On 11/13/19 6:33 AM, Sergey Senozhatsky wrote:
[..]
Review
Quoted 12 lines
Well, here we go. There is a number of generally useful functions that print nice data and where people might want to have better loglevel control (for debugging purposes).
show_stack()is just one of them. Patching all those functions, which you have mentioned above, is hardly a fun task to do. Hence theprintk()per-CPU per-context loglevel proposition. The code there is not clever or complicated and is meant for debugging purposes only, but with just 3 lines of code one can do some stuff:/* @BTW you can't do this with "%s" KERN_FOO ;P */(quoted diff) +3
-0+ printk_emergency_enter(LOGLEVEL_SCHED); + debug_show_all_locks(); + printk_emergency_exit();
Not that I want to critic your proposal more, but just to clarify what I've meant by "cleaver and complicated":
I don't think semantically there is any difference between:
printk_emergency_enter(LOGLEVEL_SCHED);printk();printk_emergency_exit();
vsprintk("%s ...", KERN_SHED, ...);
I was speaking about complexity not about usage, but about realization inside printk_emergency_enter(): there will be some business logic that will do "it's NMI? Use loglevel given. it's KERN_ALERT? Don't downgrade the loglevel..." and other smart details those are really logic which one have to think about and later maintain.
There will be also minor issues like people inserting print with one log level and seeing it in dmesg with another, but I presume those printk_enter() and printk_exit() will cover little amount of code without much nesting [as long as it's not getting overused]. And also it can be documented and people will learn about another feature of printk().
And this year I've seen the presentation "Why printk() is so complicated?" and I presumed that the approach is to keep things as simple as possible.
In conclusion:
I see that your proposal also solves the problem [except preemption and some pr_debug() that shouldn't be printed]. And I think your approach is better in the sense of short-term (we won't have any missed %s KERN_ in linux-next), but in a long-term it adds some amount of business logic to printk and another feature.
Just in case: again, I don't mind, it's up to you, maintainers of printk. It's also not very fun for me to create those patches. But they fix console_loglevel issues (I hope we could un-export it in the end) and also I need it for my other patches those will produce warnings with debug loglevel when configured through sysctl.
Thanks,
Dmitry
Quoted 4 lines · Dmitry Safonov
It's also not very fun for me to create those patches.
But they fixconsole_loglevelissues (I hope we could un-export it in the end) and also I need it for my other patches those will produce warnings with debug loglevel when configured through sysctl.
No objections.
-ss
Steven Rostedt
maintainerQuoted 11 lines · On Tue, 12 Nov 2019 13:44:47 +0900 Sergey Senozhatsky…
Quoted 6 lines
Quoted 3 lines
I do recall that we talked about per-CPU printk state bit which would start/end "just print it" section. We probably can extend it to "just
log_store" type of functionality. Doesn't look like a very bad idea.The problem with per-CPU printk is that we would need to disable interrupts.
Or disable preemption and have loglevel per-CPU and per-context.
preempt_countcan navigate us to the right context loglevel on particular CPU. I'm talking here only about backtrace (error) reporting contexts. Those can be atomic perfectly fine.
With my real-time hat on, I'm totally against disabling of preemption for this purpose.
-- Steve
Hi Sergey, Petr,
Quoted 8 lines · Sergey Senozhatsky
On (19/11/08 14:04), Petr Mladek wrote:
[..]Quoted 5 lines
I agree that it is complicated to pass the loglevel as a parameter. It would be better define the default log level for a given code section. It might be stored in
task_structfor the normal context and in per-CPU variables for interrupt contexts.
Quoted 4 lines
I do recall that we talked about per-CPU printk state bit which would start/end "just print it" section. We probably can extend it to "just
log_store" type of functionality. Doesn't look like a very bad idea. "This task/context is in trouble, whatever it printk()-s is important".
I don't see how bits on task_struct or in per-cpu are easier than supplying a log level parameter down the stack.
How would it work if sysrq_handle_crash() called by key-press? How would that interact with deferred printing?
How would it make visible prints from current context, but not from something that preempted it?
Furthermore, what problems are you trying to solve with this design? Only sysrq driver? Kdb?
In my perspective it sounds too complicated and over-engineered for something that has two-three users.
Also I've tried to point that I need to print backtrace sometimes with KERN_DEBUG loglevel to use it in production for early notices those needs to go only to log files and currently each architecture decides which log level it prefers.
And what's so complicated about this patches set? I see only side of the testing, but the build-testing is covered with 0day bot and cost nothing and any visible regression may be found during -next period. While introducing those printk-sections may subtly break things.
I mean, I definitely know less about printk() and its internals than you
- so my points may be a no-sense.
What I'm going to do - is to fix all build and reported issues, I'll send v2 this week and feel free to NAK it, I will forget about those patches and won't be offended.
I don't see many people those are "hey, we'll benefit from this". And doing this patches set was neither quite fun (dirty business), nor something I can be later proud of (hey, I've introduced the log level parameter to printing functions!).
Thanks,
Dima
On (19/11/11 19:47), Dmitry Safonov wrote:
[..]
Quoted 6 lines
I don't see how bits on
task_structor in per-cpu are easier than supplying a log level parameter down the stack.
How would it work ifsysrq_handle_crash()called by key-press? How would that interact with deferred printing?
How would it make visible prints from current context, but not from something that preempted it?
[..]
per-context log_level works pretty much the same way as per-message log_level.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // static DEFINE_PER_CPU(int, cpu_loglevels[4]); // @INITME.. LOGLEVEL_DEBUG + 1?
static int __printing_context(void)
{
unsigned int preempt = preempt_count();
if (!(preempt & (NMI_MASK | HARDIRQ_MASK | SOFITRQ_OFFSET)))
return 0;
if (preempt & SOFITRQ_OFFSET)
return 1;
if (preempt & HARDIRQ_MASK)
return 2;
return 3;
}static int adj_context_loglevel(int level)
{
int ctx = __printing_context();
int cpu_level = this_cpu_read(cpu_loglevels[ctx]);
// this one is important
if (level == LOGLEVEL_SCHED)
return level;
// we are not in emergency context
if (cpu_level == LOGLEVEL_DEBUG + 1)
return level;
// we better not override these
if (LOGLEVEL_EMERG <= level && level <= LOGLEVEL_ERR)
return level;
return cpu_level;
}void printk_emergency_enter(int log_level)
{
int ctx;
preempt_disable();
ctx = __printing_context();
this_cpu_write(cpu_loglevels[ctx], log_level);
}void printk_emergency_exit(void)
{
int ctx = __printing_context();
this_cpu_write(cpu_loglevels[ctx], LOGLEVEL_DEBUG + 1);
preempt_enable();
}void vprintk_emit(...)
{
level = adj_context_loglevel(level);
}//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // //
static void __show_stack(struct task_struct *task, unsigned long *sp)
{
printk();
...
printk();
}void show_stack(struct task_struct *task, unsigned long *sp, int log_level)
{
printk_emergency_enter(log_level);
__show_stack(task, sp);
printk_emergency_exit();
}// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
show_stack() never schedules, disabling preemption around it should not change anything. Should it be interrupted, we will handle it via preempt count.
printk_emergency_enter(log_level) handles every printk() that __show_stack() and friends do. Not worse than printk("%s Stack", lvl); all over the place.
Quoted 3 lines
What I'm going to do - is to fix all build and reported issues, I'll send v2 this week and feel free to NAK it, I will forget about those patches and won't be offended.
Lovely.
And - no, I'm not going to NAK platform specific changes. Just so you know.
*All* I'm talking about is an alternative, less "go and touch a ton of platform code" approach. The argument "I patched so many files that I'm not even going to discuss anything now" is not productive, to say the least. Hope this clarifies.
-ss
Hi Sergey,
Quoted 1 line · Sergey Senozhatsky
On (19/11/11 19:47), Dmitry Safonov wrote:
[..]
Quoted 11 lines
Quoted 3 lines
What I'm going to do - is to fix all build and reported issues, I'll send v2 this week and feel free to NAK it, I will forget about those patches and won't be offended.
Lovely.
And - no, I'm not going to NAK platform specific changes. Just so you know.*All* I'm talking about is an alternative, less "go and touch a ton of platform code" approach. The argument "I patched so many files that I'm not even going to discuss anything now" is not productive, to say the least. Hope this clarifies.
It probably was a wrong impression from the both sides.
My impression was "You touch every architecture - we won't even consider that". Sorry for the the wrong impression from my side - I'm open for discussion.
In my point of view the cost of one-time [mostly build] testing every architecture is cheaper than introducing some new smart code that will live forever. Though, again you and Petr understand more than me in printk() code, so I'm not any insisting.
I'll reply to your suggestion tomorrow, it's a bit late in my tz.
Thanks,
Dmitry
On (19/11/12 02:40), Dmitry Safonov wrote:
[..]
Quoted 3 lines
In my point of view the cost of one-time [mostly build] testing every architecture is cheaper than introducing some new smart code that will live forever.
Well, there may be the need to pass loglevel deeper due to "hey __show_stack() on that arch invokes bar(), which invokes foo() and now foo() does printk(), but we don't see it". The context which decided to backtaraces decided to do so for a reason, probably, so I guess we can look at it as "a special error reporting code block".
The proposed patch set passes loglevel via slightly unusual channel - via sprintf(). We probably can do it, but I would prefer to minimize the number of such printk-s in the kernel. The code snippet which I posted also does pretty unusual thing w.r.t loglevel. Both approaches are "non-standard" from that POV.
Quoted 1 line
I'll reply to your suggestion tomorrow, it's a bit late in my tz.
Sure.
To anyone who will comment on that code snippet - this is not a "look, here is what you need to do" type of proposal. Just an alternative approach with its pros and cons.
We had several requests over the years to have something like "forcibly allow all underlying printk-s from here to here" or "forcibly suppress or postpone underlying printk-s from here to here", etc.
-ss
Quoted 12 lines · Sergey Senozhatsky
On (19/11/12 02:40), Dmitry Safonov wrote:
[..]Quoted 3 lines
In my point of view the cost of one-time [mostly build] testing every architecture is cheaper than introducing some new smart code that will live forever.
Well, there may be the need to pass loglevel deeper due to "hey
__show_stack()on that arch invokesbar(), which invokesfoo()and nowfoo()doesprintk(), but we don't see it". The context which decided to backtaraces decided to do so for a reason, probably, so I guess we can look at it as "a special error reporting code block".
Quoted 5 lines
The proposed patch set passes loglevel via slightly unusual channel - via
sprintf(). We probably can do it, but I would prefer to minimize the number of such printk-s in the kernel. The code snippet which I posted also does pretty unusual thing w.r.t loglevel. Both approaches are "non-standard" from that POV.
I don't strongly disagree, but if you look at those results:
git grep 'printk("%s.*", \(lvl\|level\)'
it seems to be used in quite a few places.
Thanks,
Dmitry
On (19/11/13 02:41), Dmitry Safonov wrote:
[..]
Quoted 5 lines
I don't strongly disagree, but if you look at those results:
git grep 'printk("%s.*", \(lvl\|level\)'it seems to be used in quite a few places.
Yes, you are right, it is used in some places. That's why I said that I'd prefer to keep that number low (minimize it). But it's not 0 (that ship has sailed).
-ss
Steven Rostedt
maintainerQuoted 11 lines · On Tue, 12 Nov 2019 11:17:47 +0900 Sergey Senozhatsky…
void
show_stack(struct task_struct *task, unsigned long *sp, int log_level){ printk_emergency_enter(log_level); __show_stack(task, sp); printk_emergency_exit(); }// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
show_stack()never schedules, disabling preemption around it should not change anything. Should it be interrupted, we will handle it via preempt count.
Please no! The whole point of the printk rewrite was to allow for printk to be preemptible and used in more contexts. The show_stack() can be all over the place and is not a fast function. Let's not disable preemption for it.
-- Steve
On (19/11/13 10:39), Steven Rostedt wrote:
[..]
Quoted 8 lines
Quoted 8 lines
void
show_stack(struct task_struct *task, unsigned long *sp, int log_level){ printk_emergency_enter(log_level); __show_stack(task, sp); printk_emergency_exit(); }// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
Quoted 8 lines
Quoted 3 lines
show_stack()never schedules, disabling preemption around it should not change anything. Should it be interrupted, we will handle it via preempt count.Please no! The whole point of the printk rewrite was to allow for printk to be preemptible and used in more contexts. The
show_stack()can be all over the place and is not a fast function. Let's not disable preemption for it.
I never said that this code should be used all over the place. What I did say several times was that this code is for quick debugging, when one sits behind a slow serial console and wants to tweak loglevel of all printk-s of a particular context/function only.
-ss
Peter Zijlstra
maintainerQuoted 6 lines · Dmitry Safonov
Add log level argument to
show_stack().
Done in three stages:
1. Introducingshow_stack_loglvl()for every architecture
2. Migrating old users with an explicit log level
3. Renamingshow_stack_loglvl()intoshow_stack()
Quoted 12 lines
Justification:
o It's a design mistake to move a business-logic decision into platform realization detail.
o I have currently two patches sets that would benefit from this work:
Removingconsole_logleveljumps in sysrq driver [1]
Hung task warning before panic [2] - suggested by Tetsuo (but he probably didn't realise what it would involve).
o While doing (1), (2) the backtraces were adjusted to headers and other messages for each situation - so there won't be a situation when the backtrace is printed, but the headers are missing because they have lesser log level (or the reverse).
o As the result in (2) plays withconsole_loglevelfor kdb are removed.
I really don't understand that word salad. Why are you doing this?
Hi Peter,
Quoted 20 lines · Peter Zijlstra
Quoted 6 lines · Dmitry Safonov
Add log level argument to
show_stack().
Done in three stages:
1. Introducingshow_stack_loglvl()for every architecture
2. Migrating old users with an explicit log level
3. Renamingshow_stack_loglvl()intoshow_stack()Quoted 12 lines
Justification:
o It's a design mistake to move a business-logic decision into platform realization detail.
o I have currently two patches sets that would benefit from this work:
Removingconsole_logleveljumps in sysrq driver [1]
Hung task warning before panic [2] - suggested by Tetsuo (but he probably didn't realise what it would involve).
o While doing (1), (2) the backtraces were adjusted to headers and other messages for each situation - so there won't be a situation when the backtrace is printed, but the headers are missing because they have lesser log level (or the reverse).
o As the result in (2) plays withconsole_loglevelfor kdb are removed.
Quoted 2 lines
I really don't understand that word salad. Why are you doing this?
Sorry, I should have tried to describe better.
I'm trying to remove external users of console_loglevel by following reasons:
- changing console_loglevel on SMP means that unwanted messages from other CPUs will appear (that have lower log level)
- on UMP unwanted messages may appear if the code is preempted while it hasn't set the console_loglevel back to old
- rising console_loglevel to print wanted message(s) may not work at all if printk() has being delayed and the console_loglevel is already set back to old value
Sysrq driver changes console_loglevel because it needs to print message with a specific log level (the code said userspace relies on this). Kdb changes console_loglevel to print backtrace as the log level depends on architecture realisation.
I also have patches in wip those needs to print backtrace with specific loglevel (higher when it's critical, lower when it's notice and shouldn't go to serial console).
Besides on local tests I see hits those have headers (messages like "Backtrace: ") without an actual backtrace and the reverse - a backtrace without a reason for it. It's quite annoying and worth addressing by syncing headers log levels to backtraces.
Thanks,
Dmitry
Peter Zijlstra
maintainerQuoted 23 lines · Dmitry Safonov
Hi Peter,
Quoted 20 lines · Peter Zijlstra
Quoted 18 lines · Dmitry Safonov
Add log level argument to
show_stack().
Done in three stages:
1. Introducingshow_stack_loglvl()for every architecture
2. Migrating old users with an explicit log level
3. Renamingshow_stack_loglvl()intoshow_stack()Justification:
o It's a design mistake to move a business-logic decision into platform realization detail.
o I have currently two patches sets that would benefit from this work:
Removingconsole_logleveljumps in sysrq driver [1]
Hung task warning before panic [2] - suggested by Tetsuo (but he probably didn't realise what it would involve).
o While doing (1), (2) the backtraces were adjusted to headers and other messages for each situation - so there won't be a situation when the backtrace is printed, but the headers are missing because they have lesser log level (or the reverse).
o As the result in (2) plays withconsole_loglevelfor kdb are removed.
Quoted 7 lines
Quoted 2 lines
I really don't understand that word salad. Why are you doing this?
Sorry, I should have tried to describe better.
I'm trying to remove external users of
console_loglevelby following reasons:
I suppose since all my machines have 'debug ignore_loglevel earlyprintk=serial,ttyS0,115200 console=ttyS0,115200' I don't have this experience.
Quoted 7 lines
- changing
console_loglevelon SMP means that unwanted messages from other CPUs will appear (that have lower log level)
- on UMP unwanted messages may appear if the code is preempted while it hasn't set theconsole_loglevelback to old
- risingconsole_loglevelto print wanted message(s) may not work at all ifprintk()has being delayed and theconsole_loglevelis already set back to old value
Sure, frobbing the global console_loglevel is bad.
Quoted 3 lines
I also have patches in wip those needs to print backtrace with specific loglevel (higher when it's critical, lower when it's notice and shouldn't go to serial console).
(everything always should go to serial, serial is awesome :-)
Quoted 4 lines
Besides on local tests I see hits those have headers (messages like "Backtrace: ") without an actual backtrace and the reverse - a backtrace without a reason for it. It's quite annoying and worth addressing by syncing headers log levels to backtraces.
I suppose I'm surprised there are backtraces that are not important. Either badness happened and it needs printing, or the user asked for it and it needs printing.
Perhaps we should be removing backtraces if they're not important instead of allowing to print them as lower loglevels?
Russell King - ARM Linux admin
maintainerQuoted 3 lines · Peter Zijlstra
I suppose I'm surprised there are backtraces that are not important. Either badness happened and it needs printing, or the user asked for it and it needs printing.
Or utterly meaningless.
Quoted 2 lines
Perhaps we should be removing backtraces if they're not important instead of allowing to print them as lower loglevels?
Definitely! WARN_ON() is well overused - and as is typical, used without much thought. Bound to happen after Linus got shirty about BUG_ON() being over used. Everyone just grabbed the next nearest thing to assert().
As a kind of example, I've recently come across one WARN_ON() in a driver subsystem (that shall remain nameless at the moment) which very likely has multiple different devices on a platform. The WARN_ON() triggers as a result of a problem with the hardware, but because it's a WARN_ON(), you've no idea which device has a problem. The backtrace is mostly meaningless. So you know that a problem has occurred, but the kernel prints *useless* backtrace to let you know, and totally omits the *useful* information.
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Geert Uytterhoeven
maintainerHi Russell,
(reduced CC list)
Quoted 7 lines · Russell King - ARM Linux admin
Quoted 3 lines · Peter Zijlstra
I suppose I'm surprised there are backtraces that are not important. Either badness happened and it needs printing, or the user asked for it and it needs printing.
Or utterly meaningless.
Quoted 7 lines
Quoted 2 lines
Perhaps we should be removing backtraces if they're not important instead of allowing to print them as lower loglevels?
Definitely!
WARN_ON()is well overused - and as is typical, used without much thought. Bound to happen after Linus got shirty aboutBUG_ON()being over used. Everyone just grabbed the next nearest thing toassert().
Which is what checkpatch.pl suggests...
Quoted 8 lines
As a kind of example, I've recently come across one
WARN_ON()in a driver subsystem (that shall remain nameless at the moment) which very likely has multiple different devices on a platform. TheWARN_ON()triggers as a result of a problem with the hardware, but because it's aWARN_ON(), you've no idea which device has a problem. The backtrace is mostly meaningless. So you know that a problem has occurred, but the kernel prints *useless* backtrace to let you know, and totally omits the *useful* information.
So that callsite should be converted to use dev_WARN(), with a suitable message.
Perhaps checkpatch should be updated, to suggest {,dev_}WARN() instead of WARN_ON(), and add a check for the latter, too?
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Steven Rostedt
maintainerQuoted 15 lines · On Wed, 6 Nov 2019 23:25:13 +0000 Russell King - ARM Linux admin…
Quoted 3 lines · Peter Zijlstra
I suppose I'm surprised there are backtraces that are not important. Either badness happened and it needs printing, or the user asked for it and it needs printing.
Or utterly meaningless.
Quoted 2 lines
Perhaps we should be removing backtraces if they're not important instead of allowing to print them as lower loglevels?
Definitely!
WARN_ON()is well overused - and as is typical, used without much thought. Bound to happen after Linus got shirty aboutBUG_ON()being over used. Everyone just grabbed the next nearest thing toassert().
Quoted 9 lines
As a kind of example, I've recently come across one
WARN_ON()in a driver subsystem (that shall remain nameless at the moment) which very likely has multiple different devices on a platform. TheWARN_ON()triggers as a result of a problem with the hardware, but because it's aWARN_ON(), you've no idea which device has a problem. The backtrace is mostly meaningless. So you know that a problem has occurred, but the kernel prints *useless* backtrace to let you know, and totally omits the *useful* information.
I would like to bring up a topic for the next maintainers summit (although I may not even be there), that we define a clear use of WARN_ON(). I use it only if the code does something I do not expect it to do, and is considered a bug in the code if it triggers. But it appears that some drivers use it for "oh I didn't realize this hardware does something I didn't expect". And is ignored when the warn on is triggered and reported, with "you have buggy hardware" but my hardware appears to work just fine!
-- Steve
Quoted 1 line · Peter Zijlstra
On Wed, Nov 06, 2019 at 04:27:33PM +0000, Dmitry Safonov wrote:
[..]
Quoted 8 lines
Quoted 4 lines
Sorry, I should have tried to describe better.
I'm trying to remove external users of
console_loglevelby following reasons:I suppose since all my machines have 'debug
ignore_loglevelearlyprintk=serial,ttyS0,115200 console=ttyS0,115200' I don't have this experience.
Yeah, I remember you avoid all those functionalities of printk(), fair enough. On the other side, regular users and I'm betting most of the non-tuned distributions use /proc/sys/kernel/printk by default. (Checking on my Arch & Fedora - loglevel 4 from the box)
Quoted 8 lines
Quoted 7 lines
- changing
console_loglevelon SMP means that unwanted messages from other CPUs will appear (that have lower log level)
- on UMP unwanted messages may appear if the code is preempted while it hasn't set theconsole_loglevelback to old
- risingconsole_loglevelto print wanted message(s) may not work at all ifprintk()has being delayed and theconsole_loglevelis already set back to old value
Quoted 7 lines
Sure, frobbing the global
console_loglevelis bad.Quoted 3 lines
I also have patches in wip those needs to print backtrace with specific loglevel (higher when it's critical, lower when it's notice and shouldn't go to serial console).
(everything always should go to serial, serial is awesome :-)
Personally I agree. Unfortunately, here @Arista there are switches (I'm speaking about the order of thousands at least) those have baud-rate 9600. It's a bit expensive being elaborate with such setup.
Quoted 11 lines
Quoted 4 lines
Besides on local tests I see hits those have headers (messages like "Backtrace: ") without an actual backtrace and the reverse - a backtrace without a reason for it. It's quite annoying and worth addressing by syncing headers log levels to backtraces.
I suppose I'm surprised there are backtraces that are not important. Either badness happened and it needs printing, or the user asked for it and it needs printing.
Perhaps we should be removing backtraces if they're not important instead of allowing to print them as lower loglevels?
Well, the use-case for lower log-level is that everything goes into logs (/var/log/dmesg or /var/log/messages whatever rsyslog has settting).
That has it's value:
- after a failure (i.e. panic) messages, those were only signs that something goes wrong can be seen in logs which can give ideas what has happened.
- before the failure, those messages go to telemetry and can be auto-magically processed remotely to take a decision (e.g. balance the traffic away).
I wish all the information could be gathered in the userspace, but many existing kernel/driver messages are valuable. A more detailed example is hung task detector: we want to have the backtrace for a task that is in uninterruptible state too long, but only in logs as printing on serial console may lead to holding console lock and watchdog. Besides customer notifications and investigations, I see the value of such "bottleneck" warnings during long-running integration tests.
Thanks,
Dmitry
Russell King - ARM Linux admin
maintainerQuoted 49 lines · Dmitry Safonov
Quoted 1 line · Peter Zijlstra
On Wed, Nov 06, 2019 at 04:27:33PM +0000, Dmitry Safonov wrote:
[..]
Quoted 8 lines
Quoted 4 lines
Sorry, I should have tried to describe better.
I'm trying to remove external users of
console_loglevelby following reasons:I suppose since all my machines have 'debug
ignore_loglevelearlyprintk=serial,ttyS0,115200 console=ttyS0,115200' I don't have this experience.Yeah, I remember you avoid all those functionalities of
printk(), fair enough. On the other side, regular users and I'm betting most of the non-tuned distributions use/proc/sys/kernel/printkby default. (Checking on my Arch & Fedora - loglevel 4 from the box)Quoted 8 lines
Quoted 7 lines
- changing
console_loglevelon SMP means that unwanted messages from other CPUs will appear (that have lower log level)
- on UMP unwanted messages may appear if the code is preempted while it hasn't set theconsole_loglevelback to old
- risingconsole_loglevelto print wanted message(s) may not work at all ifprintk()has being delayed and theconsole_loglevelis already set back to old valueQuoted 7 lines
Sure, frobbing the global
console_loglevelis bad.Quoted 3 lines
I also have patches in wip those needs to print backtrace with specific loglevel (higher when it's critical, lower when it's notice and shouldn't go to serial console).
(everything always should go to serial, serial is awesome :-)
Personally I agree. Unfortunately, here @Arista there are switches (I'm speaking about the order of thousands at least) those have baud-rate 9600. It's a bit expensive being elaborate with such setup.
Quoted 11 lines
Quoted 4 lines
Besides on local tests I see hits those have headers (messages like "Backtrace: ") without an actual backtrace and the reverse - a backtrace without a reason for it. It's quite annoying and worth addressing by syncing headers log levels to backtraces.
I suppose I'm surprised there are backtraces that are not important. Either badness happened and it needs printing, or the user asked for it and it needs printing.
Perhaps we should be removing backtraces if they're not important instead of allowing to print them as lower loglevels?
Quoted 7 lines
Well, the use-case for lower log-level is that everything goes into logs (
/var/log/dmesgor/var/log/messageswhatever rsyslog has settting).That has it's value:
- after a failure (i.e. panic) messages, those were only signs that something goes wrong can be seen in logs which can give ideas what has happened.
No they don't. When the kernel panics, userspace generally stops running, so rsyslog won't be able to write them to /var/log/messages.
How, by "kernel panics" I mean a real kernel panic, which probably isn't what you're talking about there. You are probably talking about the whole shebang of non-fatal kernel oops, kernel warnings and the like. If so, I'd ask you to stop confuzzilating terminology.
If you really want to capture such events, then you need to have the kernel write the panic to (e.g.) flash - see the mtdoops driver.
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Quoted 1 line · Russell King - ARM Linux admin
On Fri, Nov 08, 2019 at 04:28:30PM +0000, Dmitry Safonov wrote:
[..]
Quoted 12 lines
Quoted 8 lines
Well, the use-case for lower log-level is that everything goes into logs (
/var/log/dmesgor/var/log/messageswhatever rsyslog has settting).That has it's value:
- after a failure (i.e. panic) messages, those were only signs that something goes wrong can be seen in logs which can give ideas what has happened.No they don't. When the kernel panics, userspace generally stops running, so rsyslog won't be able to write them to
/var/log/messages.
Quoted 7 lines
How, by "kernel panics" I mean a real kernel panic, which probably isn't what you're talking about there. You are probably talking about the whole shebang of non-fatal kernel oops, kernel warnings and the like. If so, I'd ask you to stop confuzzilating terminology.
If you really want to capture such events, then you need to have the kernel write the panic to (e.g.) flash - see the mtdoops driver.
I was talking about things prior the panic: OOMs, MMC write/read warnings, hung tasks, we also have local patches to produce a warning if the mutex is being held for too long or a task is starving on CPU time by hard/soft irqs (I hope I will design something like that for upstream). I've found those warnings useful to:
(a) have an early message when the things are starting going bad.
(b) analyze contentions or too large scale for a box or faulty hardware for non-reproducible issues just from logs.
We use kexec to save the dmesg ringbuffer content after the panic.
Thanks,
Dmitry
Steven Rostedt
maintainerQuoted 3 lines · On Wed, 6 Nov 2019 21:34:40 +0100 Peter Zijlstra <[email protected]> wrote:
I suppose I'm surprised there are backtraces that are not important. Either badness happened and it needs printing, or the user asked for it and it needs printing.
Unfortunately that is the case. As my tests will fail if a backtrace is detected.
Quoted 3 lines
Perhaps we should be removing backtraces if they're not important instead of allowing to print them as lower loglevels?
I usually end up removing backtraces for my tests, so I'm for this. Specifically this happens in the drm and i915 drivers :-p
-- Steve