Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp317043ybc; Tue, 12 Nov 2019 01:53:20 -0800 (PST) X-Google-Smtp-Source: APXvYqx+bP9NkhxvWYRzHAx6YlLLmApuQA5Lx6UzgdO77lj8H4ia3/ckD1ihkv/eepiryAl7+ifP X-Received: by 2002:aa7:d4d8:: with SMTP id t24mr31790346edr.40.1573552400633; Tue, 12 Nov 2019 01:53:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573552400; cv=none; d=google.com; s=arc-20160816; b=tho5sxII1twhIqFtv/MgScUwH13O8mu64JT4sOIj03Pfp4GN3RIdr5oDcEhydE3zNC SMu8/TWQWME8dKNUYn3lA1WFlb3sULlarWGAUO0NBRLT0T2S4/rGu/TjHiKUTvc6GW6T WmVl0mo6Fpsl7Hb3w5o6gotX8Qdp/q1nVoNiGDPSQfh1TKe3we1L+VBQKdrppE/sDBYM YlQCC3fOx55boc8cM/9sbuWJ4W/ZAi11fW+ksEBigbMgcLY926oZoOQbT2lpp/324ur+ AoyaRPUM60xb0Ph7/J4MRnjsjGXxVivJsPPpmVX1Apmqdee5gZ99FZcCOQW+lLU7jBgR LTpA== 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=47c+Hss7akvjPdsgY7yJoeWH7YQOsvWro/b9N0IbQpE=; b=NrR6vf+T9i+Lc47KxLyicoimcq+NDbtfr/LEy6FrhxZXxuq0eobBSq3s2qitfksph3 cGnNDq1hX02pVRdrV8gNGrBoJ3cDXDEj684s9RHNaFN5KDaPH0GAIzptIjqmjhwGVTNo qhmWURMIv3b/nmUelcXPzzLS21++PRZnXg84RdEe+UxYDgYK9mpFoneQQ8APzgOTLmgc sYe2jnOjkcb70Q1+F0DepHsvD+C3D7yp0OsnWorqrXyV9HWmVxzVwxO4pNCmHgF+I6ch bUi0uWggQrNG2T7Rw1wvf52u1aIB0hYDHSMM1g2O/4445oA5bQS5SkkcGWPtY0KUS/+Y M2Lw== 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 k18si15349534edj.94.2019.11.12.01.52.56; Tue, 12 Nov 2019 01:53:20 -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 S1727366AbfKLJtU (ORCPT + 99 others); Tue, 12 Nov 2019 04:49:20 -0500 Received: from mx2.suse.de ([195.135.220.15]:57866 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727352AbfKLJtU (ORCPT ); Tue, 12 Nov 2019 04:49:20 -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 2D48DB039; Tue, 12 Nov 2019 09:49:18 +0000 (UTC) Date: Tue, 12 Nov 2019 10:49:17 +0100 From: Petr Mladek To: Max Filippov Cc: linux-xtensa@linux-xtensa.org, Chris Zankel , linux-kernel@vger.kernel.org, Dmitry Safonov , Joe Perches Subject: Re: [PATCH v2] xtensa: improve stack dumping Message-ID: <20191112094917.fl57dhtennwo2tlz@pathway.suse.cz> References: <20191108004448.5386-1-jcmvbkbc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191108004448.5386-1-jcmvbkbc@gmail.com> 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 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. > 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 *). > > - 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 Best Regards, Petr