Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1748791ybx; Thu, 7 Nov 2019 16:46:00 -0800 (PST) X-Google-Smtp-Source: APXvYqyCUdpcO3SVG7ZV/Rc7Re2X53ZzPmysMxE15RlXIOutbp2yhlV5gLum/ac5aFUw7XLIy9bL X-Received: by 2002:a17:906:234e:: with SMTP id m14mr5898323eja.94.1573173959929; Thu, 07 Nov 2019 16:45:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573173959; cv=none; d=google.com; s=arc-20160816; b=yi5zL5pNsKUi6jGooCbOzWSfs2VLM4Lx+9My929wnceopJaILT9SkkrKDglil7HtW8 2OdezoBtxpBVXlaGY0SelONDyKP4w037Nm4ibiAsNiF7vvFQPMDC2ehxb/iP/7d2pabj AYPT3MrETVqFA9hIGILWcPe56GUkbHzucd97NFJpKXIehkNh1JKpCPtsv/wfU0dBFBdH zqvs3TYy5h2zMJLStGxIXr74JzQIepPk8JdqJps8RF9rtEG+WdMTsldjbADO/4npwC06 dZ+Qrd+jI1YXf7CrluJXTIxcRZT7iNlIFFaYS+sSA9RmgZgmaV4gToKj4l0WLJ+U1duw yaxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SncMCZY11gPJIfKbfsmrvxmuN/67o00wSU4yUgQ2zL0=; b=y0YQn55PiSfBJF+h+LCf02t+lkUFxg5NllsfnE9YGwGm9kw3x5R9TSqPoj5y5n7//W uW8DWPPmFYKefMotaulFu2pj9292aZ6d3cnZNpWYrQFOXMV6iBQZ2ZDB9cDhBwRIXi8L rgq8ylwgWd5S5eOIs/yeD8Y+ZwS2VGa4f4CaXCw+/n9bZrCTsGSDP6/FBBdWT/1y6vTp ykiZzY9uGJJCHNVzQfw9+O1oBBxB6BhY65VkPJaFvK+4Q389wWQu++O2pOxVeN1XZWlf Oo/Uge/wqvxkAsoo5A7BrFG7uvRj0s0Us7b3TNBaOnxa7D/zUPOOAF7Ew2uFrqkYJgC2 zhSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JG+3TGFr; 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 dd5si2687618ejb.179.2019.11.07.16.45.36; Thu, 07 Nov 2019 16:45: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=JG+3TGFr; 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 S1727695AbfKHApC (ORCPT + 99 others); Thu, 7 Nov 2019 19:45:02 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:44845 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725930AbfKHApB (ORCPT ); Thu, 7 Nov 2019 19:45:01 -0500 Received: by mail-lf1-f67.google.com with SMTP id v4so3043160lfd.11 for ; Thu, 07 Nov 2019 16:45:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SncMCZY11gPJIfKbfsmrvxmuN/67o00wSU4yUgQ2zL0=; b=JG+3TGFrcv/9M9GIXFwmuqadILvxRaOJD6hZNFXM928X+RZ2USWGkQ1+IuQWVZ/NMK ZtJo2s+KTeIF3ceufpu/jBJzuz/WxGSbfnss4XgB+ne5tX73CYGixbfD6KrymjvndVkE JHQ8+4jmZA81gPeoTmM61ZEQIZ5dwHFQ3W6Nrjl6bxU7KxkA54JtN0tHzz6jx1kXvsD7 JQMRWR+qlCJyR7aOroxmXMaMZzfw+GRo10VTJPgRmNk5acjYCYT+NzPYorkCFbaa+nVm FMLdBRKPu4JE02giveSEKuwW0owEIaumTYmRfU0C00ZIJ1VvWv7vp/UV9hefbUcpWcNE FB2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SncMCZY11gPJIfKbfsmrvxmuN/67o00wSU4yUgQ2zL0=; b=naSWimY9Mcv9c4WPEGB46c7b4TkaT1u8dp85LO3z2lfjF3MR6KyGhitxpPLzWuN+Xf GQDlIUCMpk9o0O5Y2wHB9xIfK3oWJMMU+K2E+MCVg0BbIVbZYG4kvBPgi+pRdAAatGDu 9N2pw2SSXGKD4RLviim2/lCNrmIWYAbyMu76yVtx+F6ESkdamEBubfTJtDHHPZMQJJIg 7Ye8JDNXW9DCzwxzkuixh+NC95K+cwR8JeZ7F3wiTEapEwKkSLKhxphJ6P2cuZRvou4u Dueb+uZIxRv/PaV6kB/qsbMFix39ieu1TJfXdiGBjYFaAOzunLqc6f2whIDopcO9s4wD TwAg== X-Gm-Message-State: APjAAAVeuOL9uSJbZBjN1t26j9q/SH/VRTTKaizdM1JBUL9I8idd93To v0mj9tmKQ8GTpwiwRZnyIeE= X-Received: by 2002:a19:fc1e:: with SMTP id a30mr4467814lfi.167.1573173899613; Thu, 07 Nov 2019 16:44:59 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id y6sm2029544ljn.40.2019.11.07.16.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 16:44:58 -0800 (PST) From: Max Filippov To: linux-xtensa@linux-xtensa.org Cc: Chris Zankel , linux-kernel@vger.kernel.org, Dmitry Safonov , Petr Mladek , Joe Perches , Max Filippov Subject: [PATCH v2] xtensa: improve stack dumping Date: Thu, 7 Nov 2019 16:44:48 -0800 Message-Id: <20191108004448.5386-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Max Filippov --- Changes v1->v2: - use print_hex_dump. arch/xtensa/Kconfig.debug | 7 +++++++ arch/xtensa/kernel/traps.c | 24 ++++++++---------------- 2 files changed, 15 insertions(+), 16 deletions(-) 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. 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); - 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); } DEFINE_SPINLOCK(die_lock); -- 2.20.1