Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp110771ybx; Wed, 6 Nov 2019 14:04:07 -0800 (PST) X-Google-Smtp-Source: APXvYqx/pfgzUvGOTDn3oeQW6ETL5ydrG/AEkBNGGB7J6z513yzkpDJW4mohJZPUTzbjqk1a7nKx X-Received: by 2002:aa7:d64e:: with SMTP id v14mr41746edr.88.1573077846925; Wed, 06 Nov 2019 14:04:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573077846; cv=none; d=google.com; s=arc-20160816; b=0HwPhzym1DotNJA6X5584Y6VysBCTWdA32Fl5Tu4dvmEg1GVE1vQITcJgRAmxZW+Gp uTbhsfIjhU44DbL5xNK34HyJBW40z1oSCclmJVc3UKvFLqiPtovopFCiDPoulFiLsyOw nQ787k5W5AHO4Ivp2fw9C1uHIidntlGuge3m3o8sJA//3/cTokPnxoegnoFjPSea2CES aiVUt79ey+kl6KLvxrahtZ9PcCjzwtfaFbmQvJvzbJM02UMRsROopOhIw1WiCOSHIOyk tLOZewetXf7G53EMbCCjarejBLT5Rj5OUw+RVDEpK2aZKkeFUVe6/KMxEv13VgThL1hl 3lHA== 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=y3o8l4teeUkfXISUOAxa3pHTPdubgp1E+n1um6h/pcQ=; b=Iz6hxGTPQrvZlFUyKHmKE3UEMgsHpPr2poDAAvIH/DkdQZnwY72Rcad8U07rez9qxu 3DAYZg3wPBPvv6vJQP9SW5PPgkhR1jYCXuxVH0aVT14Bq2wavvjUkZDsZNCwlVKdYDBH eBnBqhD1roqZmRxLMwNHix0MuZIbKPoi2znaNuFxXtD5W4bk+XBd/qu4Vmd5bUCqkUen M+7wueds8xsTgKo5rDTk0p5Yy5DeChuTvFMOwfbPz1yfDzMjZq7JEQj1rp3c8/C6qbHC 2K/e6MjC0A8P/Wj63ccd2qr3hYakrXQWX0bdL+rnQOgZhCMM88f7h0wWf2ScZP/g0H4+ PlhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i8V+RCk5; 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 t30si13843960edt.330.2019.11.06.14.03.41; Wed, 06 Nov 2019 14:04:06 -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=i8V+RCk5; 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 S1732717AbfKFWA0 (ORCPT + 99 others); Wed, 6 Nov 2019 17:00:26 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:40003 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727700AbfKFWA0 (ORCPT ); Wed, 6 Nov 2019 17:00:26 -0500 Received: by mail-yw1-f66.google.com with SMTP id n82so273862ywc.7 for ; Wed, 06 Nov 2019 14:00:26 -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=y3o8l4teeUkfXISUOAxa3pHTPdubgp1E+n1um6h/pcQ=; b=i8V+RCk5wjwjk4V7CqTktL4fgprLf7fter8Klj1wmtmhT6ZzFVA3VSByZDeiRYTgbr NlRfKzfKPQKlHt1L7m8v9K69wLeeMyt4n+odUwkCO4aQuhVEeGPmOk2ToCCQjZJEz3ty q7f39mpXnkWwrudtzI6UwZF67uE+uz4qh1JHieAXKsY4E2jbHoIIeME7Db4X/mkbW11u 4wclqG9ZAygVS76IsNI2qy0rVnZUL2bnGIait6aCLDmlR+05HUUk8D8XKgy9mMp83IpE 6mtWGWF1BdaggdI+ErUxNyNos6SuO47L6wA6kpj6+BYOQxb8WBgje8G4owlrnTPZ9Hb7 ET+A== 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=y3o8l4teeUkfXISUOAxa3pHTPdubgp1E+n1um6h/pcQ=; b=GbM1i0FuhlBCNLAzxpvxPROgTWRI5y3tgltY2LLObyLeiKzf1/I5fSCN5WcXFLHvK0 fBaOkw+fvj5iZYV1qUZYX3HWGBgyH53etSq+g66st4PX2j5AbtJ168WD2K79V3dtCXLZ g2ZS3UE6BQETB9dMBtmZCRhQHXjymhsP8PEdZZj672eu3Jc6J0ps20g5r155WVd3KCA2 C2imug4bAhPWCpwf6VaoS+WIB+TMpOqvyEm0bLRQT6vQ7yfX07r83+eMu6aC4ix8075O jUmWs66i16XRq2NO264O6mwSCvDxxz/9lp+NwvayVi1QpCeR4tOrU14xvm8zx7ZF5hJo Ggvw== X-Gm-Message-State: APjAAAU7j8zOuTP1pX5VJ+y2IinlYtIFTxPVefVA1mHXn6X/IdhBjqjQ Oq6s/8iSRniIJQLOoKOm4NZUceI3RYyJgxsouKs= X-Received: by 2002:a81:5b43:: with SMTP id p64mr3367068ywb.234.1573077625667; Wed, 06 Nov 2019 14:00:25 -0800 (PST) MIME-Version: 1.0 References: <20191106181617.1832-1-jcmvbkbc@gmail.com> <27720768-9fb7-0382-e1ef-ac9760cdf5cc@arista.com> In-Reply-To: <27720768-9fb7-0382-e1ef-ac9760cdf5cc@arista.com> From: Max Filippov Date: Wed, 6 Nov 2019 14:00:14 -0800 Message-ID: Subject: Re: [PATCH] xtensa: improve stack dumping To: Dmitry Safonov Cc: "open list:TENSILICA XTENSA PORT (xtensa)" , Chris Zankel , LKML , Petr Mladek 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 Wed, Nov 6, 2019 at 12:51 PM Dmitry Safonov wrote: > On 11/6/19 6:16 PM, Max Filippov 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++); > > buf is on the stack, does sprintf() put null-terminator for hex? It should put null-terminator regardless of the format string. > > if (i % 8 == 7) > > - pr_cont("\n"); > > + pr_info("%s\n", buf); > > } > > + if (i % 8) > > + pr_info("%s\n", buf); > > If the stack trace ends with (i % 8 == 7), you'll double-print the last > line? No, I don't think so. 'For' loop condition is checked after i++, so if loop ends with i % 8 == 7 then its last iteration was done with i % 8 == 6 and thus the buf haven't been printed. -- Thanks. -- Max