Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp292809ybx; Wed, 6 Nov 2019 00:17:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyn9ZLxrJFNbOS/7BmvJ9Of+azr7K+AiATRMciUVrg2G5+lv8gKY40uSGebcinbfIGXfsYV X-Received: by 2002:a50:b558:: with SMTP id z24mr1252392edd.67.1573028251702; Wed, 06 Nov 2019 00:17:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573028251; cv=none; d=google.com; s=arc-20160816; b=aPV0EzwsJ8SWDREhG9PJoEWU5MABmQLOD49g2JWN1jrs4rUHWT8ARNkCoIk/8tDa76 AZyuNkzOPs29TUpsn2B/jGk7ww8wjDInOSoK+ldRnLO+r+hyTbp2qtgPgG/NwUzq03Wx +JuI53mrzloJ2zGo1UpvaCKKEHJQ8H+jwk56kEk6RwwN6ludBmQtWsRDu1j/R5RO2jX9 pCAwdwKgfpVZhvXpdJeAM5ynJfD00hGK5mZnOCSbQiG4cSuCjrbPfen7+a++uDked6lI /IucSRtKO4GZkux1GE7aL61oopmkW+9K5JQUafDmE7BL4wdv16WmNccu4qPj3ifq7r9P af1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=vVlgu/QBTyeMtFSzBcO6sCDKqfthIb4s2wYXjRqDOUI=; b=Plf5lC5eXHVHKQKBEk20uGCShl9DK7fCzP7TeNdvXTg1iS09nzDvMwuVSdV1Ae1f7E g3tX0S2Qk4Ni83Ygcg7fr7EFy2zxcu3FMLorlbitwdrjgdonYcpff1lPfIefyWbdxBtQ IFct8WhsqO/6nzMrGniZz+Hya/GlQjNkoU6rba/U21eaiQqfZ8QWQtTAjaRR7xntcEvG S658Z388cM55T0kM1U40CAUT9r8uDBDg+/2Jht2sC+BYHZrHIzsVcRA5oHAeNobR0CJc RaUYZvpLXS8dPLhe/+7g6lpYHxmDw340Z0NjjI+tpuBr9WchtW/1joM22Bux3RC1q+lO +Sww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si4043106edu.135.2019.11.06.00.17.08; Wed, 06 Nov 2019 00:17:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731385AbfKFIPs (ORCPT + 99 others); Wed, 6 Nov 2019 03:15:48 -0500 Received: from mx2.suse.de ([195.135.220.15]:44090 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729951AbfKFIPs (ORCPT ); Wed, 6 Nov 2019 03:15:48 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DE6FDB011; Wed, 6 Nov 2019 08:15:44 +0000 (UTC) Date: Wed, 6 Nov 2019 09:15:41 +0100 From: Petr Mladek To: Max Filippov Cc: Dmitry Safonov , LKML , Dmitry Safonov <0x7f454c46@gmail.com>, Andrew Morton , Greg Kroah-Hartman , Ingo Molnar , Jiri Slaby , Sergey Senozhatsky , Steven Rostedt , Tetsuo Handa , Chris Zankel , "open list:TENSILICA XTENSA PORT (xtensa)" Subject: Re: [PATCH 43/50] xtensa: Add show_stack_loglvl() Message-ID: <20191106081541.soxefwyvu3o72tqg@pathway.suse.cz> References: <20191106030542.868541-1-dima@arista.com> <20191106030542.868541-44-dima@arista.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2019-11-05 20:13:22, Max Filippov wrote: > Hi Dmitry, > > On Tue, Nov 5, 2019 at 7:08 PM 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: Chris Zankel > > Cc: Max Filippov > > Cc: linux-xtensa@linux-xtensa.org > > [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u > > Signed-off-by: Dmitry Safonov > > --- > > arch/xtensa/kernel/traps.c | 16 +++++++++++----- > > 1 file changed, 11 insertions(+), 5 deletions(-) > > > > diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c > > index cbc0d673f542..ba6c150095c6 100644 > > --- a/arch/xtensa/kernel/traps.c > > +++ b/arch/xtensa/kernel/traps.c > > @@ -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++); 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 > 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] > > -- > Thanks. > -- Max