Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1056289ybx; Thu, 7 Nov 2019 06:39:19 -0800 (PST) X-Google-Smtp-Source: APXvYqx4eZISnIsgQzcKgt13cXOB9GVsUzRgcvldddLHXvB5ARWVSBJi8UZ7WK2a3VDQy5QDBcE7 X-Received: by 2002:a05:6402:1718:: with SMTP id y24mr3846585edu.220.1573137559380; Thu, 07 Nov 2019 06:39:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573137559; cv=none; d=google.com; s=arc-20160816; b=bAdTtSMO7G6SGgd5/iVS0NdefOiqTbvfIlcEw9Xn9BJ8P7rrk82ionHlcn3jVismBN lrmf7V0Y/N7h77K2pHA4d+5tqInYi3jS5YP92k1VHp+WNCSdzixeHdecf7itmthNmuzr DiPEPnDgwJXUf9plfP0pKfzvKGPTjhwnhANTYPHbb8BBWaSGzMDomQGdBRe8zPw3Ao4e 0c5JPTaMtOpoQpeSMcc/gpL5RHquG0ez0aaOfhX7Khmqc6dOshnYxT6fxWS/zjxLLdsF TvrynIBz+//DYeokDmp5Hp1gy8cQ8/jIEd/tu23F7Ne1iU9DbAgNkOwoHJaX5SOaJIve i2bw== 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=uFa5UV4+maBrTCTv3p5p+xDEhN+nE8N24iPZWCEB8lw=; b=J9AvHmRpsmGhGc3C3PTOegi5Vp9w5DtoaXGEPor6l1OhdY/DdcrXF9kngG26rjCpag ZtK+GPe56CkT1XOoxU/roND0j0ooY88XeZhvmmuRPdMSu3Bc6o2hZR/YwZm+hMJK7DOS Wu354dpgkUTjkdv13wUtrc0PDPDbyj8nsNsDqL1oqLc/UNvLPSGcUnYqofp9fOzV8pBS 6GjRUDFVlvsfd3ToDxsDxgTpF1NXNT9O4J3Ly8ZC10W8YlAB0we6yT71fGzaErFm1ZM9 gXSv7McMWNkZWSVJTPKKBbMcgPCBtCiD2ZP6KtCuoAhGqeD3htRFMxTgpFa+Uq6Y6VrS 6IGg== 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 mj10si1429570ejb.7.2019.11.07.06.38.53; Thu, 07 Nov 2019 06:39:19 -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 S1729524AbfKGOiN (ORCPT + 99 others); Thu, 7 Nov 2019 09:38:13 -0500 Received: from mx2.suse.de ([195.135.220.15]:40374 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727849AbfKGOiN (ORCPT ); Thu, 7 Nov 2019 09:38:13 -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 6C281ACA5; Thu, 7 Nov 2019 14:38:11 +0000 (UTC) Date: Thu, 7 Nov 2019 15:38:10 +0100 From: Petr Mladek To: Max Filippov Cc: Joe Perches , "open list:TENSILICA XTENSA PORT (xtensa)" , Chris Zankel , LKML , Dmitry Safonov Subject: Re: [PATCH] xtensa: improve stack dumping Message-ID: <20191107143810.oon6bj7dc7xqcyxe@pathway.suse.cz> References: <20191106181617.1832-1-jcmvbkbc@gmail.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 Wed 2019-11-06 16:21:51, Max Filippov wrote: > On Wed, Nov 6, 2019 at 2:34 PM Joe Perches wrote: > > > @@ -512,10 +510,12 @@ void show_stack(struct task_struct *task, unsigned long *sp) > > > for (i = 0; i < kstack_depth_to_print; i++) { > > > if (kstack_end(sp)) > > > break; > > > - pr_cont(" %08lx", *sp++); > > > + sprintf(buf + (i % 8) * 9, " %08lx", *sp++); > > > if (i % 8 == 7) > > > - pr_cont("\n"); > > > + pr_info("%s\n", buf); > > > } > > > + if (i % 8) > > > + pr_info("%s\n", buf); > > > > Could this be done using hex_dump_to_buffer > > by precalculating kstack_end ? > > I've got this, but it doesn't look very attractive to me: > > void show_stack(struct task_struct *task, unsigned long *sp) > { > unsigned long *stack; > int len; > > if (!sp) > sp = stack_pointer(task); > stack = sp; > > len = min((-(unsigned long)stack) & (THREAD_SIZE - 4), > kstack_depth_to_print * 4ul); > > pr_info("Stack:\n"); > > for (; len > 0; len -= 32) { > char buf[9 * 8 + 1]; > > hex_dump_to_buffer(sp, min(len, 32), 32, 4, > buf, sizeof(buf), false); > pr_info(" %08lx: %s\n", (unsigned long)sp, buf); > sp += 8; > } I wonder if the cycle actually could get replaced by a single call: print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 1, sp, len, false); print_hex_dump() currently does not allow to print 8 bytes per-line. Either 16 is acceptable or hex_dump() function could be updated. Best Regards, Petr