Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp735147ybc; Tue, 12 Nov 2019 08:24:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwM2TOJqN8kVHKaOARlkb7a/ZHM8vJoSS6096WpNyApP88F9+hLUvG3Nj2/TX0Y/vySjFvQ X-Received: by 2002:a17:906:6011:: with SMTP id o17mr28062246ejj.172.1573575899313; Tue, 12 Nov 2019 08:24:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573575899; cv=none; d=google.com; s=arc-20160816; b=IjVBWhMB7Asemt7PmjrM6qDbqmYa1ta02T3q7em0omOKC4tQ93o3yvyYWqcatur7/n h5/lgDPBzFAgrm1quCRIo7WAFEhVXO3kNUmucjvOmzzcEpdwdWfbZPVgWorLAf2Ts9KJ j5TowVKdbr4GunQb7kA7zBQ/ZpB2/qTIxKZUa2GmHVxpBa8emSn4/vy/0hZa9aTkIdVp OwsBWQD14Q1F5p41qOXul7Eq20RqGg5PggHbGGVAVmwDTAcQh78rAXa5ufUNpzHQFdyx EwGX5iAPVhB+pszMGxVQkTAEInfwTwzuQrRxi82N22kKDIVhaojd4uwgYJRUwCRvUblQ pTVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2Q1cQSXXccuUTN1Ss9zMJqdgVizhYDIhjY92yJUaC6I=; b=gYu3pffg1Db9C2ewuIVmCqVdrZLMnKLS2LEslOt7DBKFPbG+W+jPOrEli/2c3N+iGz otpiVa+6tsL1urU5KgSMvu1R9i2dflOd7VStNAcGqQmE+pxdmZDs8Q8c1GilclyO12aU mXdAbFbGgiS1Rqr/Bn2vUYvMZPmFUC1ZLE3h8Hv06Rk1TJEfXkqIn5dTtKxvTCbeml6P +aeg0NGhXWUFKrUAJcodGGVXYF+XrYuHJK3KxvvaceRRusz10RAee2k5qQ3ZYhgdDLRF GAn0+gLv0Uzu5eskWzHvZYKqEfXHOnrORxZomTp/zC3J5CI4oEFq8VDf4x+CTX90goO8 sdQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O3piHuow; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h21si14325613edh.110.2019.11.12.08.24.35; Tue, 12 Nov 2019 08:24:59 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O3piHuow; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726978AbfKLQXu (ORCPT + 99 others); Tue, 12 Nov 2019 11:23:50 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:37192 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbfKLQXu (ORCPT ); Tue, 12 Nov 2019 11:23:50 -0500 Received: by mail-yw1-f66.google.com with SMTP id v84so6618881ywc.4 for ; Tue, 12 Nov 2019 08:23:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2Q1cQSXXccuUTN1Ss9zMJqdgVizhYDIhjY92yJUaC6I=; b=O3piHuow5ELlk8jDb5ZoGxiSQ5RhIR/9v5R0S9tcVkF625c5F2WV4F0L4GHHgmeuQX Dm/0PuHlzjay/3EnbTB9HSxsYCV7Y2DFFhRqoItbnp6Ri8b/o1S2+kGiv4RoYFqiuA+w daYR3Rdl48LwhuyDQaE6i/GQq4kiXnFbOJAJcFhU69XFgtntpty6+29BfM9yTPc53OGB bMWqXc7+OqQFhkXWaewAHJ1GkKeyRvLDYptaf+LgAqGmtiyX97tsjlE5rOStoGLeBbUg RDn3Z1j147Et2O3iPQ1h+aK6IR1ESrYQhHSJvQxT59Ay0ToeqJ3vPxV585mKB6RV77zI MioA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2Q1cQSXXccuUTN1Ss9zMJqdgVizhYDIhjY92yJUaC6I=; b=X5anxE/4bqWyBGPUoCX0St2sT1/8JjDxoyJR1lh1Gvb2YAIsQqVeVP+6EvMb7FsxPq 9pxw9kcIwn1nZLQWTcqVuPDbn8NM5a+7neIu2mASvDqm9qDWrjQM95a47tdKLGSlQPcx 6vyu7FMSBhZ+CDZYOUIq18TLCg5sXsT162EwpZr7TSqG1sc4DElJ2EPXbb/5mphze8+f 1W7nn6i+SjgaF8jpx5MW0QpoDlxZOJ0PtfFlfxeesl3XM/nhGuZnBn5F6a3vFBry25Zo +ZNfFX49eRLQ++Nd6CTClqGcaQHhRg8YWiIVIVbamodXxG8glRNmG1nlvOixI4R515Yd T2gQ== X-Gm-Message-State: APjAAAWrTyhMGdYfOTu6hYM7xrDIYuJIPCyBqyNkxAAiiKf1ZD077wFL e/rBZRKo4SnuXn04aO67GBTDhkTdq7+jUPcXhHA= X-Received: by 2002:a81:ad60:: with SMTP id l32mr21343115ywk.388.1573575829291; Tue, 12 Nov 2019 08:23:49 -0800 (PST) MIME-Version: 1.0 References: <20191108004448.5386-1-jcmvbkbc@gmail.com> <20191112094917.fl57dhtennwo2tlz@pathway.suse.cz> In-Reply-To: <20191112094917.fl57dhtennwo2tlz@pathway.suse.cz> From: Max Filippov Date: Tue, 12 Nov 2019 08:23:38 -0800 Message-ID: Subject: Re: [PATCH v2] xtensa: improve stack dumping To: Petr Mladek Cc: "open list:TENSILICA XTENSA PORT (xtensa)" , Chris Zankel , LKML , Dmitry Safonov , Joe Perches Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 12, 2019 at 1:49 AM Petr Mladek wrote: > > On Thu 2019-11-07 16:44:48, Max Filippov wrote: > > Calculate printable stack size and use print_hex_dump instead of > > opencoding it. > > Make size of stack dump configurable. > > Drop extra newline output in show_trace as its output format does not > > depend on CONFIG_KALLSYMS. > > > diff --git a/arch/xtensa/Kconfig.debug b/arch/xtensa/Kconfig.debug > > index 39de98e20018..83cc8d12fa0e 100644 > > --- a/arch/xtensa/Kconfig.debug > > +++ b/arch/xtensa/Kconfig.debug > > @@ -31,3 +31,10 @@ config S32C1I_SELFTEST > > It is easy to make wrong hardware configuration, this test should catch it early. > > > > Say 'N' on stable hardware. > > + > > +config PRINT_STACK_DEPTH > > + int "Stack depth to print" if DEBUG_KERNEL > > + default 64 > > + help > > + This option allows you to set the stack depth that the kernel > > + prints in stack traces. > > I would split this into separate patch. Sure, I'll split it out. > > diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c > > index 4a6c495ce9b6..fe090ab1cab8 100644 > > --- a/arch/xtensa/kernel/traps.c > > +++ b/arch/xtensa/kernel/traps.c > > @@ -491,32 +491,24 @@ void show_trace(struct task_struct *task, unsigned long *sp) > > > > pr_info("Call Trace:\n"); > > walk_stackframe(sp, show_trace_cb, NULL); > > -#ifndef CONFIG_KALLSYMS > > - pr_cont("\n"); > > -#endif > > } > > > > -static int kstack_depth_to_print = 24; > > +static int kstack_depth_to_print = CONFIG_PRINT_STACK_DEPTH; > > > > void show_stack(struct task_struct *task, unsigned long *sp) > > { > > - int i = 0; > > - unsigned long *stack; > > + size_t len; > > > > if (!sp) > > sp = stack_pointer(task); > > - stack = sp; > > > > - pr_info("Stack:\n"); > > + len = min((-(unsigned long)sp) & (THREAD_SIZE - 4), > > + kstack_depth_to_print * 4ul); > > I would replace the hardcoded 4 with sizeof(void *). It's not necessarily pointers, more like register-wide entries on the stack. Ok, I guess I'll give it a name. > > - for (i = 0; i < kstack_depth_to_print; i++) { > > - if (kstack_end(sp)) > > - break; > > - pr_cont(" %08lx", *sp++); > > - if (i % 8 == 7) > > - pr_cont("\n"); > > - } > > - show_trace(task, stack); > > + pr_info("Stack:\n"); > > + print_hex_dump(KERN_INFO, " ", DUMP_PREFIX_NONE, 32, 4, > > + sp, len, false); > > + show_trace(task, sp); > > } > > The conversion looks fine to me. It is up to you (as a maintainer) > what you do with the above proposal for two cosmetic changes ;-) > Either way, feel free to use: > > Reviewed-by: Petr Mladek Thanks for the review. -- Max