Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1122344ybc; Tue, 12 Nov 2019 14:48:38 -0800 (PST) X-Google-Smtp-Source: APXvYqzZkELv1hTX5HqGQfjnl5Vpheg6R+7/bwW6fx2VeHX5irCmbEyPuFpJI9jqc5hSSoQBUJt/ X-Received: by 2002:aa7:c1d4:: with SMTP id d20mr120380edp.273.1573598918642; Tue, 12 Nov 2019 14:48:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573598918; cv=none; d=google.com; s=arc-20160816; b=kd1UlmygIiBDIHcCeS1ZTXOwbwqDzMmbzjBMAhlRXnlySna55xphXDt5Kp59gZJRNc /XFmahpj+hN7jbqLLItdoBxnEgYgmI7CUqJItLSkeZVGWFVhERq8PZQMuO3o7m2ynO5u RXTsQ3aiINf7PrqwWV1wVcqJmU+/LiVN5GApOQi8HoqFpeybD2PXtN3R0TqbJFkAGn+o K/57Rt63WSB3ojskQQ9W31xwzhd0tws0oZ61wa3leywBmIxymEJV/ryQNkf8ShT34ZNR DguJHS9vL7P2wiuGl2LEojLTkRxaQ9PuOK4XaMuF1MThEPac82xfCkQcHwmM/MYfIz9j PwBg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BqdCzBL4fzIXodZM8rkfZwLaj0b1Yk/Q6aPJ7Os6kwc=; b=y+xjuzuSdOGUdTswC8c9MLuIUsbMHdZcE9FfsBcdt757yNaxY/2bh3jgYRrL3XSH6b Xi5BpUFMhsBwflWY+T+0yaq9Fv7/6OIpzGhuD+IiZ1bLUF0I4oIex+ebRJqGnhKOcGdK 1/p9Im2+IRR3QQND/7vqP0e7TJKvN8r0DMK0Tcb70PIv6bDHUB8i9kne2oOArx3RGwDc AE6d4Kk9ZouGOqpKnTaiKL/rv6THYkeE/bXLbB5oTRIm153y9le+s5X3OQI5+GnHCE+N YGpV5SYfvS6PjhK+t0mkz5TaHdax57AI1gJUgHEO7/8wuHq+DQQ6XXwlS9L/UwdGgOKr WOpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="P/1fMe+w"; 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 b17si14591076edj.417.2019.11.12.14.48.14; Tue, 12 Nov 2019 14:48:38 -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="P/1fMe+w"; 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 S1727196AbfKLWpR (ORCPT + 99 others); Tue, 12 Nov 2019 17:45:17 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38398 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726906AbfKLWpQ (ORCPT ); Tue, 12 Nov 2019 17:45:16 -0500 Received: by mail-lj1-f196.google.com with SMTP id v8so278141ljh.5 for ; Tue, 12 Nov 2019 14:45:15 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=BqdCzBL4fzIXodZM8rkfZwLaj0b1Yk/Q6aPJ7Os6kwc=; b=P/1fMe+wWJX6jbZLLBGY43qw5To0b0bMXsmhg4Xzi7df/LmWiEtUG+9FZJBIKjgq77 jGsBMRPolKqk+zUbDMcWiKiGsB/TMmUncwm8yq9/OD1frdeqR6jsN+CTw/68ahtqlOK5 EpMoXR+iQhtsyjDCmkz31fNJ6Qm6/S9Vr23Hx+WRxcZiIjLj2oJCG1uac83V9UbZBqt6 rd9lteccBEdsmaKpBby6jWo3CAI0Xgfx9AbBKtGlWr+hUmE/6ha3+FT/Gw7YqEpLXOL8 piF2PbrZS2lZTF1UjPa/z3ukWhK71JU2BsBlbp2UE/33GkUw7z8HPF71PiZuDMTz3aB3 kgQw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=BqdCzBL4fzIXodZM8rkfZwLaj0b1Yk/Q6aPJ7Os6kwc=; b=ChIqSyjx10QthVKbBw4XQZUFozjmXb4Im2iSE3GvFoYHSA5CkYOFwMfD0pcpb5cHjN 7b5f7JuQfdXlUXDk/tnvwlpIBp5hbqO88/3maIoizWN/l7gVHX2nUpdjUoL8nCNzgwXY VVQm/npcPI86q5yqUdSbw+aFL4iYf03k4GRNTg4s28MMOo22rnco8J1pNtR5qkMl4uu7 BJaRL+KXIxe1HEqZgQwuJVZmHZlDMWoOsxTUVxPMQLQE7tnwpcYBinfotXKhzJAhVEzY 5FinsbTFojbpTAP8xJ5YKdn9j05YEOKL5KKUNclX61qEQj30BvNxMw2IuYH/kjt5npw/ zL3A== X-Gm-Message-State: APjAAAVTfTqsbb3HvZm2lJlKwjYWaEXiHA1rGCwY6O8hn6hdotlvr7GD oXF6l4YQr+lVpcHCOq2J8Bc= X-Received: by 2002:a2e:9194:: with SMTP id f20mr127776ljg.154.1573598714419; Tue, 12 Nov 2019 14:45:14 -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 x16sm38677ljd.69.2019.11.12.14.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2019 14:45:13 -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 v3 1/2] xtensa: improve stack dumping Date: Tue, 12 Nov 2019 14:44:42 -0800 Message-Id: <20191112224443.12267-2-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191112224443.12267-1-jcmvbkbc@gmail.com> References: <20191112224443.12267-1-jcmvbkbc@gmail.com> 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. Drop extra newline output in show_trace as its output format does not depend on CONFIG_KALLSYMS. Reviewed-by: Petr Mladek Signed-off-by: Max Filippov --- Changes v2->v3: - split Kconfig change into separate patch - use symbolic names instead of hardcoded numbers Changes v1->v2: - use print_hex_dump. arch/xtensa/kernel/traps.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c index 4a6c495ce9b6..be26ec6c0e0e 100644 --- a/arch/xtensa/kernel/traps.c +++ b/arch/xtensa/kernel/traps.c @@ -491,32 +491,27 @@ 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; +#define STACK_DUMP_ENTRY_SIZE 4 +#define STACK_DUMP_LINE_SIZE 32 +static size_t kstack_depth_to_print = 24; 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((-(size_t)sp) & (THREAD_SIZE - STACK_DUMP_ENTRY_SIZE), + kstack_depth_to_print * STACK_DUMP_ENTRY_SIZE); - 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, + STACK_DUMP_LINE_SIZE, STACK_DUMP_ENTRY_SIZE, + sp, len, false); + show_trace(task, sp); } DEFINE_SPINLOCK(die_lock); -- 2.20.1