linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vaneet Narang <v.narang@samsung.com>
To: Masahiro Yamada <masahiroy@kernel.org>,
	Maninder Singh <maninder1.s@samsung.com>
Cc: "George G. Davis" <george_davis@mentor.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	AMIT SAHRAWAT <a.sahrawat@samsung.com>,
	Arnd Bergmann <arnd@arndb.de>, Andi Kleen <ak@linux.intel.com>
Subject: RE:(2) [PATCH 3/4] scripts/checkstack.pl: add arm push handling for stack usage
Date: Thu, 07 May 2020 19:02:20 +0530	[thread overview]
Message-ID: <20200507133220epcms5p87e370759fbc8aecca3093c503dd99b4c@epcms5p8> (raw)
In-Reply-To: <CAK7LNAQxOtjsrS6b8pF93=0yqnTJT6b7V2hDOWsYGH-njNcZdw@mail.gmail.com>

Hi Masahiro, 

>> 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 <Y>:
>> 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
  
 
> Do you know CONFIG_FRAME_WARN?
 Yes we know this and we use it to get compilation error if some function is using more stack.
This config will report issue at compilation.
 
>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.
 
We feel purpose of this patch is different from CONFIG_FRAME_WARN.
This patch is specific to ARM and fixes bug in stack usage calculation.

We were comparing stack usage of ARM with ARM64 and found big gap.
We realised ARM is not calculating stack usage properly.
It only considers stack used by local variables but it doesn't consider 
stack used to store register context at the start of functions. 
This is not the case with ARM64. It seems ARM64 considers both.

We found even stack variables are of same size on both target but 
arm64 stack usage is high.

Considering below assembly, Actual stack usage is 492 but current script reports 448.
push instruction uses 44 bytes of stack to take backup of registers as per ARM calling
convention.

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

Thanks & Regards,
Vaneet Narang
 
  

  parent reply	other threads:[~2020-05-07 14:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200430124952epcas5p28cd53b0aa452f43eed48ed9d58b4005b@epcas5p2.samsung.com>
2020-04-30 12:49 ` [PATCH 1/4] scripts/checkstack.pl: don't display $dre as different entity Maninder Singh
     [not found]   ` <CGME20200430124955epcas5p4b5c1dd7393a7b798d80206d071264df3@epcas5p4.samsung.com>
2020-04-30 12:49     ` [PATCH 2/4] scripts/checkstack.pl: Add argument to print stacks greather than value Maninder Singh
2020-05-07  8:13       ` Masahiro Yamada
     [not found]   ` <CGME20200430124958epcas5p15ecc8e744ed0f78837a6d58274a5baf0@epcas5p1.samsung.com>
2020-04-30 12:49     ` [PATCH 3/4] scripts/checkstack.pl: add arm push handling for stack usage Maninder Singh
2020-05-07 10:35       ` Masahiro Yamada
     [not found]       ` <CGME20200430124958epcas5p15ecc8e744ed0f78837a6d58274a5baf0@epcms5p8>
2020-05-07 13:32         ` Vaneet Narang [this message]
     [not found]   ` <CGME20200430125001epcas5p2a6f02e9888481cef96f32ba14450bc63@epcas5p2.samsung.com>
2020-04-30 12:49     ` [PATCH 4/4] scripts/checkstack.pl: fix arm sp regex Maninder Singh
2020-05-07 10:38       ` Masahiro Yamada
     [not found]       ` <CGME20200430125001epcas5p2a6f02e9888481cef96f32ba14450bc63@epcms5p5>
2020-05-07 10:51         ` Maninder Singh
2020-05-07 11:58           ` [PATCH " Masahiro Yamada
2020-05-07  8:12   ` [PATCH 1/4] scripts/checkstack.pl: don't display $dre as different entity Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200507133220epcms5p87e370759fbc8aecca3093c503dd99b4c@epcms5p8 \
    --to=v.narang@samsung.com \
    --cc=a.sahrawat@samsung.com \
    --cc=ak@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=george_davis@mentor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maninder1.s@samsung.com \
    --cc=masahiroy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).