Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp615369ybj; Thu, 7 May 2020 03:40:24 -0700 (PDT) X-Google-Smtp-Source: APiQypKE/pfFbnhMcmRkvCJXtvAvsDU3ae4P3TRSGsjyqf3Rfanp/6jcsdjfSVyIKTEBTRsGoVnK X-Received: by 2002:a17:906:9706:: with SMTP id k6mr11814465ejx.103.1588848023950; Thu, 07 May 2020 03:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588848023; cv=none; d=google.com; s=arc-20160816; b=b9FoEQaCHu1Ccc9QHHkWSyBj6kMDw8bMt1UC50VeQN5rHM5JKI0fFnosPhCfhOLFXo /z3nQfzZsWI2z0u1V6kKTOVy0dfDTI933BNnMTdQvHiR63e1PjBYaoH5gPMCY7zGofnI Dzf9nNZK6XhW9ofGYKRn9XcbwQWusmriBJbWTnbcHdsiWFBzKkPVlk5GBIQ/yFO0FSjc bGY8ovEJczEIta2K7ua1v6evUEy0vecmHxMzWoqhTU7KXjbF2lXlE31AhYPohY1TjK3J r4vKxBBDd6FnBsShW4SgaM1aM0iU0YNYsKn+MfNAd6wETXAWB2tvhtHAuJ/R+otnAsSw R9tQ== 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:dkim-filter; bh=B7EfioEe1RRKN3M74HtxQvobPG5NMUGMFYHo0+IEkRQ=; b=BT65Xg6aKQvlRu+OhbMUOwK4tfmqo9aw8WArfsHpvv7bSiXQeqHVeRlQ38Cm6eraaO Lt06/xSXCxQwA5RDfWaebWQTlOR0sZ13Nm8+qJUDiMzprrK0vwDSJgaCf9uPKD6rYk4l F8Mw/3t1gOInRKCa9LwA+plSUqR9dH8tATxZaxQJtxNKORHV6Q9L9pvW/eTo0zPOkg4I BfEaGHY1Tq8SBJLgHkwIZ2ToZP5V4b6/Dy3KgAyl4CsW9asjeqmFuwmwdeDT1DVofjmF 5DOG8sz+lcGWOiQ5JAm8s3Eegags4KMHINKOvn02XYG8UDqS8VzQr9xuoEsnnTTcMUO9 mDRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=qfhb4KAs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by4si1048372edb.231.2020.05.07.03.39.58; Thu, 07 May 2020 03:40:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=qfhb4KAs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726382AbgEGKgo (ORCPT + 99 others); Thu, 7 May 2020 06:36:44 -0400 Received: from conssluserg-06.nifty.com ([210.131.2.91]:47791 "EHLO conssluserg-06.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbgEGKgo (ORCPT ); Thu, 7 May 2020 06:36:44 -0400 Received: from mail-vs1-f44.google.com (mail-vs1-f44.google.com [209.85.217.44]) (authenticated) by conssluserg-06.nifty.com with ESMTP id 047Aa5qY014965 for ; Thu, 7 May 2020 19:36:06 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 047Aa5qY014965 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1588847767; bh=B7EfioEe1RRKN3M74HtxQvobPG5NMUGMFYHo0+IEkRQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=qfhb4KAsmhFIhm+sylcShPBeUPhL1sjIWR97L7jZhN8YBOLtO1C8IC63cgwkMoicR /lNiCDXIYi6qPJ/akRXz2WPYscWYLkmp3XQf1exth4lsB2iqJiFRgBy239WJWFXmpM 4QskmOcUNjevLXrzlwPrpTz+nxUp+GDMArkc1DXOuMSrfjIRof3ymfKI9/xN6gL6/T gd/Ff9PfAv+Qyq3zzPk/x8gvPFocp1+WZMrqZYDjgMTsQDMnlnwGKzoj6pooydJ1zo SaWvDsmfDqQvRJnuv29kTIHbQm8eIoJLdWSoM/EtgHkq84CqdIvdsVX7bpSSgbzt55 c5/BjQJVcTQdQ== X-Nifty-SrcIP: [209.85.217.44] Received: by mail-vs1-f44.google.com with SMTP id m24so3024641vsq.10 for ; Thu, 07 May 2020 03:36:06 -0700 (PDT) X-Gm-Message-State: AGi0PuammPZDgLkIbxSrrRUQjyioseckbACKl9MESp5C7T8PrI2Wi+TM jx2bNz7E0b9B8Br78yN6L2pNcKOIk7BZaDNhB4o= X-Received: by 2002:a05:6102:3c7:: with SMTP id n7mr11095677vsq.179.1588847765172; Thu, 07 May 2020 03:36:05 -0700 (PDT) MIME-Version: 1.0 References: <1588250972-8507-1-git-send-email-maninder1.s@samsung.com> <1588250972-8507-3-git-send-email-maninder1.s@samsung.com> In-Reply-To: <1588250972-8507-3-git-send-email-maninder1.s@samsung.com> From: Masahiro Yamada Date: Thu, 7 May 2020 19:35:29 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/4] scripts/checkstack.pl: add arm push handling for stack usage To: Maninder Singh Cc: "George G. Davis" , Linux Kernel Mailing List , a.sahrawat@samsung.com, Vaneet Narang , Arnd Bergmann , Andi Kleen 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 (+CC Andi Kleen, and more mentor) On Thu, Apr 30, 2020 at 9:50 PM Maninder Singh wrote: > > To count stack usage of push {*, fp, ip, lr, pc} instruction in ARM, > if FRAME POINTER is enabled. > e.g. c01f0d48: e92ddff0 push {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc} > > c01f0d50 : > c01f0d44: e1a0c00d mov ip, sp > c01f0d48: e92ddff0 push {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc} > c01f0d4c: e24cb004 sub fp, ip, #4 > c01f0d50: e24dd094 sub sp, sp, #448 ; 0x1C0 > > $ cat dump | scripts/checkstack.pl arm > 0xc01f0d50 Y []: 448 > > added subroutine frame work for this. > After change: > 0xc01f0d500 Y []: 492 > > Signed-off-by: Vaneet Narang > Signed-off-by: Maninder Singh I do not mean to block this patch, but some people still invest efforts to improve this script. So, please let me ask this question. Do you know CONFIG_FRAME_WARN? Commit 35bb5b1e0e84cfa1a8906f7e6a77f391ff315791 mentioned -Wframe-larger-than should obsolete make checkstack. Now, -Wframe-larger-than is supported by both minimal version of GCC and Clang. I know checkstack.pl dumps the stack size of functions, which is different from what -Wframe-larger-than does, but the goal is quite similar, I think. I just wondered if we need both. > --- > scripts/checkstack.pl | 27 ++++++++++++++++++++++++++- > 1 file changed, 26 insertions(+), 1 deletion(-) > > diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl > index 8e5ef98..b292ef4 100755 > --- a/scripts/checkstack.pl > +++ b/scripts/checkstack.pl > @@ -34,8 +34,10 @@ use strict; > # $& (whole re) matches the complete objdump line with the stack growth > # $1 (first bracket) matches the dynamic amount of the stack growth > # > +# $sub: subroutine for special handling to check stack usage. > +# > # use anything else and feel the pain ;) > -my (@stack, $re, $dre, $x, $xs, $funcre, $min_stack); > +my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack); > { > my $arch = shift; > if ($arch eq "") { > @@ -59,6 +61,7 @@ my (@stack, $re, $dre, $x, $xs, $funcre, $min_stack); > } elsif ($arch eq 'arm') { > #c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64 > $re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o; > + $sub = \&arm_push_handling; > } elsif ($arch =~ /^x86(_64)?$/ || $arch =~ /^i[3456]86$/) { > #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp > # or > @@ -112,6 +115,24 @@ my (@stack, $re, $dre, $x, $xs, $funcre, $min_stack); > } > > # > +# To count stack usage of push {*, fp, ip, lr, pc} instruction in ARM, > +# if FRAME POINTER is enabled. > +# e.g. c01f0d48: e92ddff0 push {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc} > +# > +sub arm_push_handling { > + my $regex = qr/.*push.*fp, ip, lr, pc}/o; > + my $size = 0; > + my $line_arg = shift; > + > + if ($line_arg =~ m/$regex/) { > + $size = $line_arg =~ tr/,//; > + $size = ($size + 1) * 4; > + } > + > + return $size; > +} > + > +# > # main() > # > my ($func, $file, $lastslash, $total_size, $addr, $intro); > @@ -163,6 +184,10 @@ while (my $line = ) { > $size = hex($size) if ($size =~ /^0x/); > $total_size = $total_size + $size > } > + elsif (defined $sub) { > + my $size = &$sub($line); > + $total_size = $total_size + $size; $total_size += $size; Or $total_size += &$sub($line); then, delete $size. > + } > } > if ($total_size > $min_stack) { > push @stack, "$intro$total_size\n"; > -- > 1.9.1 > -- Best Regards Masahiro Yamada