Re: [PATCHv3 25/50] parisc: Add show_stack_loglvl()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18.04.20 22:19, Dmitry Safonov wrote:
> Currently, the log-level of show_stack() depends on a platform
> realization. It creates situations where the headers are printed with
> lower log level or higher than the stacktrace (depending on
> a platform or user).
>
> Furthermore, it forces the logic decision from user to an architecture
> side. In result, some users as sysrq/kdb/etc are doing tricks with
> temporary rising console_loglevel while printing their messages.
> And in result it not only may print unwanted messages from other CPUs,
> but also omit printing at all in the unlucky case where the printk()
> was deferred.
>
> Introducing log-level parameter and KERN_UNSUPPRESSED [1] seems
> an easier approach than introducing more printk buffers.
> Also, it will consolidate printings with headers.
>
> Introduce show_stack_loglvl(), that eventually will substitute
> show_stack().
>
> Cc: Helge Deller <deller@xxxxxx>
> Cc: "James E.J. Bottomley" <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>
> Cc: linux-parisc@xxxxxxxxxxxxxxx
> [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@xxxxxxxxxx/T/#u
> Signed-off-by: Dmitry Safonov <dima@xxxxxxxxxx>
> ---
>  arch/parisc/kernel/traps.c | 28 +++++++++++++++++-----------
>  1 file changed, 17 insertions(+), 11 deletions(-)

Acked-by: Helge Deller <deller@xxxxxx>

Thanks!
Helge


>
> diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
> index 82fc01189488..c2411de3730f 100644
> --- a/arch/parisc/kernel/traps.c
> +++ b/arch/parisc/kernel/traps.c
> @@ -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");
>





[Index of Archives]     [Linux SoC]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux