Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1803673ybz; Thu, 30 Apr 2020 05:54:29 -0700 (PDT) X-Google-Smtp-Source: APiQypJMq9QtAzvAiUykBJjzycQUG2VkJ587nsYt9UeSm8I8oCYcG6MDUbSzzCjiNzNais1Lt07/ X-Received: by 2002:a05:6402:c84:: with SMTP id cm4mr2368043edb.316.1588251269193; Thu, 30 Apr 2020 05:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588251269; cv=none; d=google.com; s=arc-20160816; b=i3hwhrKBMf7mmmaJ27Xkb1OHUEaXGVWHqgrXBmLH/6KIZlbDM9412EXb/400x4GxU8 XSkkmNYnfg+XynvzL2qw3YCjXjvvwhfY+hKMvrlqCckbdVJsYubAVyaS6G9ElKhxZzND Lu0/ciZcNQrxod86mrLHTkqs3GV5CBeemKmNWGJI+YgnZwTpuDsP0em5hQxd6p0I+t4q 1MhWKefh42vP8Ksj4COBCY8D1oRkqx7uKPKTMyPmKKA2RvVjV0N5KBAJHzflCiaa4fwM VcP9h0hKHLvqKa84eso1zeAyJGAb/oWunzZqsSiQ0doz5Ya+z+SyfZtF+KFWcFSrsLaW 2Mmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=wpu+3ukIInx2nRn1W8K27/+a9+Bp2v8EeAJ/0ijQ978=; b=Spetjgp4QYUSPHByOISfqJaVI040wLuNvqiS4TT+xtXSAwrBsJbOKJ8N86c5hgyWLZ uN1D3BrkI4gw3VM+vHhCtSkFk2rYISDDoPgwIlDa1OpWShi7t4s79apXptdePjPGrDqq EtEIjjKmJArNWasrmYJ4x8QWkKgHY8s9vT9ldvS4iGUqGhkPKEbx2bE3hb3qUb2kVxSU +OpEE8Eq+wULOt/BUFgeya5hRIh4UPL/zp4fkvZEzBzn1X6ff2UueTEWFIiOCfOEPfPv vJGrMal4u1EI405hPyMrwJZa7il60Js42TypcK0OZSkPrJElqNgGN04oYopZSbLmOrWh 4f8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=MYut6mhY; 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=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v20si5809786edb.416.2020.04.30.05.54.05; Thu, 30 Apr 2020 05:54:29 -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=@samsung.com header.s=mail20170921 header.b=MYut6mhY; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726885AbgD3MuV (ORCPT + 99 others); Thu, 30 Apr 2020 08:50:21 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:59769 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726127AbgD3MuU (ORCPT ); Thu, 30 Apr 2020 08:50:20 -0400 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200430125017epoutp030f1fad99c111bd4afff4a7c349860c7e~KmeKV6_Wr1211512115epoutp03h for ; Thu, 30 Apr 2020 12:50:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200430125017epoutp030f1fad99c111bd4afff4a7c349860c7e~KmeKV6_Wr1211512115epoutp03h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1588251017; bh=wpu+3ukIInx2nRn1W8K27/+a9+Bp2v8EeAJ/0ijQ978=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MYut6mhYSTFrLuh6+4nCt+Jx+sr+yyTxjm5IE4zW4D2fGoMFk940bvQd1T8rqwjCj 9Vrv5z9ATxyX3eqEp+yCc7kudQqQ4PftsbbDCWZFXdpo40oNloJMnSpY0I4lCe5eyB JxngOimwzMOWY+Pe8ZK1RJVUQ1V9P2yU3aqdYXLw= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20200430125016epcas5p1f778c34f1f64b95bf4984359c0f45ddb~KmeJqK6Jk0487204872epcas5p1V; Thu, 30 Apr 2020 12:50:16 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 7D.33.10083.889CAAE5; Thu, 30 Apr 2020 21:50:16 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20200430124958epcas5p15ecc8e744ed0f78837a6d58274a5baf0~Kmd5d3SgE2132721327epcas5p1g; Thu, 30 Apr 2020 12:49:58 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200430124958epsmtrp1d3b7a5294466a85355c7cf3e53f2b991~Kmd5dORWd3007130071epsmtrp1X; Thu, 30 Apr 2020 12:49:58 +0000 (GMT) X-AuditID: b6c32a4a-88dff70000002763-1d-5eaac988817e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id F6.11.25866.679CAAE5; Thu, 30 Apr 2020 21:49:58 +0900 (KST) Received: from localhost.localdomain (unknown [107.109.224.135]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200430124957epsmtip283b16160a48e5d25742092b3826c9d69~Kmd4NOsIq1701017010epsmtip2X; Thu, 30 Apr 2020 12:49:57 +0000 (GMT) From: Maninder Singh To: yamada.masahiro@socionext.com, george_davis@mentor.com Cc: linux-kernel@vger.kernel.org, a.sahrawat@samsung.com, Maninder Singh , Vaneet Narang Subject: [PATCH 3/4] scripts/checkstack.pl: add arm push handling for stack usage Date: Thu, 30 Apr 2020 18:19:31 +0530 Message-Id: <1588250972-8507-3-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1588250972-8507-1-git-send-email-maninder1.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VRbUhTYRTu3b27u64WL1PpqCQyEnPYtCiYEeWPsCFJRj8ModnSm5pujl21 tB8tHcsWbgqZMcoPUKE7TFtisjmhDSmlJhJBYhnR8qNJNcfwh4G5XaV/z3k+znnfc2hCukIm 01W6Osag09TIKDE55svMONI6zalzIg6pcs7NKANbG0LlB9cTSunrMZNK7/RTpPQshlEepXJH mpHKOsoh1duuDVIVdqYWkSXiU+VMTVUDY8g+fVVc+cgbpPR/Em992co0oi5sQXE04OMw2r9K WpCYlmI3Am7Nj6KCFK8jMI4V80IYwexCSGRBdCzx2FrA8y4Evs5PIr6IIBjqWRNG0xRWAOea IKM4AZ+EpbFWKmoitoeCY+IVERXi8SUwTXljARKng2U5HAtIcD587loR8e9LhXn//Zg/Dp+D 5d7ZWCPAkyIwd9op3nQWOhymHRwPP9+M7oSTYdVmFvGBFgTrk0OILx4iGJgLCXnXGQi2GAXR zxE4E4Zd2Tx9EDpnnguimMD7oW0zIOB5CYx37+J0MM2P7LRJgXAoRPJYBa99HiG/FzuCv30c 1Y5S7f9H9CLEoSRGz2orGPaE/piOualgNVq2XlehKKvVOlHs/vKCcTToP+9FmEayfRLayaml Qk0D26j1IqAJWYLk25VtSlKuaWxiDLWlhvoahvWiFJqUHZDI0TO1FFdo6phqhtEzhl1V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6wJ 0094miuxFGckGmoxFxUnAgATWqD6ngIAAA== X-CMS-MailID: 20200430124958epcas5p15ecc8e744ed0f78837a6d58274a5baf0 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20200430124958epcas5p15ecc8e744ed0f78837a6d58274a5baf0 References: <1588250972-8507-1-git-send-email-maninder1.s@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; + } } if ($total_size > $min_stack) { push @stack, "$intro$total_size\n"; -- 1.9.1