scripts/checkstack.pl: match all stack sizes for some archs
authorTiezhu Yang <yangtiezhu@loongson.cn>
Tue, 19 Dec 2023 12:49:59 +0000 (20:49 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 29 Dec 2023 20:22:27 +0000 (12:22 -0800)
For some unknown reason the regular expression for checkstack only matches
three digit numbers starting with the number "3", or any higher number.
Which means that it skips any stack sizes smaller than 304 bytes.  This
makes the checkstack script a bit less useful than it could be.

Change the script to match any number.  To be filtered out stack sizes can
be configured with the min_stack variable, which omits any stack frame
sizes smaller than 100 bytes by default.

This is similar with commit aab1f809d754 ("scripts/checkstack.pl: match
all stack sizes for s390").

Link: https://lkml.kernel.org/r/20231219125008.23007-4-yangtiezhu@loongson.cn
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
scripts/checkstack.pl

index e1af9f4fcef3273358cbc40cfd3d44325580e73e..a564c46d61297fd679cfa310d1916509b2479cc8 100755 (executable)
@@ -74,16 +74,16 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack);
                $re = qr/.*(?:linkw %fp,|addaw )#-([0-9]{1,4})(?:,%sp)?$/o;
        } elsif ($arch eq 'mips64') {
                #8800402c:       67bdfff0        daddiu  sp,sp,-16
-               $re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+               $re = qr/.*daddiu.*sp,sp,-([0-9]{1,8})/o;
        } elsif ($arch eq 'mips') {
                #88003254:       27bdffe0        addiu   sp,sp,-32
-               $re = qr/.*addiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+               $re = qr/.*addiu.*sp,sp,-([0-9]{1,8})/o;
        } elsif ($arch eq 'nios2') {
                #25a8:  defffb04        addi    sp,sp,-20
-               $re = qr/.*addi.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+               $re = qr/.*addi.*sp,sp,-([0-9]{1,8})/o;
        } elsif ($arch eq 'openrisc') {
                # c000043c:       9c 21 fe f0     l.addi r1,r1,-272
-               $re = qr/.*l\.addi.*r1,r1,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+               $re = qr/.*l\.addi.*r1,r1,-([0-9]{1,8})/o;
        } elsif ($arch eq 'parisc' || $arch eq 'parisc64') {
                $re = qr/.*ldo ($x{1,8})\(sp\),sp/o;
        } elsif ($arch eq 'powerpc' || $arch =~ /^ppc(64)?(le)?$/ ) {
@@ -97,10 +97,10 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack);
                $re = qr/.*(?:lay|ag?hi).*\%r15,-([0-9]+)(?:\(\%r15\))?$/o;
        } elsif ($arch eq 'sparc' || $arch eq 'sparc64') {
                # f0019d10:       9d e3 bf 90     save  %sp, -112, %sp
-               $re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o;
+               $re = qr/.*save.*%sp, -([0-9]{1,8}), %sp/o;
        } elsif ($arch =~ /^riscv(64)?$/) {
                #ffffffff8036e868:      c2010113                addi    sp,sp,-992
-               $re = qr/.*addi.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+               $re = qr/.*addi.*sp,sp,-([0-9]{1,8})/o;
        } elsif ($arch =~ /^loongarch(32|64)?$/) {
                #9000000000224708:      02ff4063                addi.d  $sp, $sp, -48(0xfd0)
                $re = qr/.*addi\..*sp, .*sp, -([0-9]{1,8}).*/o;