ia64/linux-2.6.18-xen.hg

annotate scripts/checkstack.pl @ 893:f994bfe9b93b

linux/blktap2: reduce TLB flush scope

c/s 885 added very coarse TLB flushing. Since these flushes always
follow single page updates, single page flushes (when available) are
sufficient.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:32:57 2009 +0100 (2009-06-04)
parents 831230e53067
children
rev   line source
ian@0 1 #!/usr/bin/perl
ian@0 2
ian@0 3 # Check the stack usage of functions
ian@0 4 #
ian@0 5 # Copyright Joern Engel <joern@wh.fh-wedel.de>
ian@0 6 # Inspired by Linus Torvalds
ian@0 7 # Original idea maybe from Keith Owens
ian@0 8 # s390 port and big speedup by Arnd Bergmann <arnd@bergmann-dalldorf.de>
ian@0 9 # Mips port by Juan Quintela <quintela@mandrakesoft.com>
ian@0 10 # IA64 port via Andreas Dilger
ian@0 11 # Arm port by Holger Schurig
ian@0 12 # sh64 port by Paul Mundt
ian@0 13 # Random bits by Matt Mackall <mpm@selenic.com>
ian@0 14 # M68k port by Geert Uytterhoeven and Andreas Schwab
ian@0 15 #
ian@0 16 # Usage:
ian@0 17 # objdump -d vmlinux | stackcheck.pl [arch]
ian@0 18 #
ian@0 19 # TODO : Port to all architectures (one regex per arch)
ian@0 20
ian@0 21 # check for arch
ian@0 22 #
ian@0 23 # $re is used for two matches:
ian@0 24 # $& (whole re) matches the complete objdump line with the stack growth
ian@0 25 # $1 (first bracket) matches the size of the stack growth
ian@0 26 #
ian@0 27 # use anything else and feel the pain ;)
ian@0 28 my (@stack, $re, $x, $xs);
ian@0 29 {
ian@0 30 my $arch = shift;
ian@0 31 if ($arch eq "") {
ian@0 32 $arch = `uname -m`;
ian@0 33 }
ian@0 34
ian@0 35 $x = "[0-9a-f]"; # hex character
ian@0 36 $xs = "[0-9a-f ]"; # hex character or space
ian@0 37 if ($arch eq 'arm') {
ian@0 38 #c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64
ian@0 39 $re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;
ian@0 40 } elsif ($arch =~ /^i[3456]86$/) {
ian@0 41 #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp
ian@0 42 $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o;
ian@0 43 } elsif ($arch eq 'x86_64') {
ian@0 44 # 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp
ian@0 45 $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%rsp$/o;
ian@0 46 } elsif ($arch eq 'ia64') {
ian@0 47 #e0000000044011fc: 01 0f fc 8c adds r12=-384,r12
ian@0 48 $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
ian@0 49 } elsif ($arch eq 'm68k') {
ian@0 50 # 2b6c: 4e56 fb70 linkw %fp,#-1168
ian@0 51 # 1df770: defc ffe4 addaw #-28,%sp
ian@0 52 $re = qr/.*(?:linkw %fp,|addaw )#-([0-9]{1,4})(?:,%sp)?$/o;
ian@0 53 } elsif ($arch eq 'mips64') {
ian@0 54 #8800402c: 67bdfff0 daddiu sp,sp,-16
ian@0 55 $re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
ian@0 56 } elsif ($arch eq 'mips') {
ian@0 57 #88003254: 27bdffe0 addiu sp,sp,-32
ian@0 58 $re = qr/.*addiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
ian@0 59 } elsif ($arch eq 'ppc') {
ian@0 60 #c00029f4: 94 21 ff 30 stwu r1,-208(r1)
ian@0 61 $re = qr/.*stwu.*r1,-($x{1,8})\(r1\)/o;
ian@0 62 } elsif ($arch eq 'ppc64') {
ian@0 63 #XXX
ian@0 64 $re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o;
ian@0 65 } elsif ($arch =~ /^s390x?$/) {
ian@0 66 # 11160: a7 fb ff 60 aghi %r15,-160
ian@0 67 $re = qr/.*ag?hi.*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})/o;
ian@0 68 } elsif ($arch =~ /^sh64$/) {
ian@0 69 #XXX: we only check for the immediate case presently,
ian@0 70 # though we will want to check for the movi/sub
ian@0 71 # pair for larger users. -- PFM.
ian@0 72 #a00048e0: d4fc40f0 addi.l r15,-240,r15
ian@0 73 $re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o;
ian@0 74 } else {
ian@0 75 print("wrong or unknown architecture\n");
ian@0 76 exit
ian@0 77 }
ian@0 78 }
ian@0 79
ian@0 80 sub bysize($) {
ian@0 81 my ($asize, $bsize);
ian@0 82 ($asize = $a) =~ s/.*: *(.*)$/$1/;
ian@0 83 ($bsize = $b) =~ s/.*: *(.*)$/$1/;
ian@0 84 $bsize <=> $asize
ian@0 85 }
ian@0 86
ian@0 87 #
ian@0 88 # main()
ian@0 89 #
ian@0 90 my $funcre = qr/^$x* <(.*)>:$/;
ian@0 91 my $func;
ian@0 92 my $file, $lastslash;
ian@0 93
ian@0 94 while (my $line = <STDIN>) {
ian@0 95 if ($line =~ m/$funcre/) {
ian@0 96 $func = $1;
ian@0 97 }
ian@0 98 elsif ($line =~ m/(.*):\s*file format/) {
ian@0 99 $file = $1;
ian@0 100 $file =~ s/\.ko//;
ian@0 101 $lastslash = rindex($file, "/");
ian@0 102 if ($lastslash != -1) {
ian@0 103 $file = substr($file, $lastslash + 1);
ian@0 104 }
ian@0 105 }
ian@0 106 elsif ($line =~ m/$re/) {
ian@0 107 my $size = $1;
ian@0 108 $size = hex($size) if ($size =~ /^0x/);
ian@0 109
ian@0 110 if ($size > 0xf0000000) {
ian@0 111 $size = - $size;
ian@0 112 $size += 0x80000000;
ian@0 113 $size += 0x80000000;
ian@0 114 }
ian@0 115 next if ($size > 0x10000000);
ian@0 116
ian@0 117 next if $line !~ m/^($xs*)/;
ian@0 118 my $addr = $1;
ian@0 119 $addr =~ s/ /0/g;
ian@0 120 $addr = "0x$addr";
ian@0 121
ian@0 122 my $intro = "$addr $func [$file]:";
ian@0 123 my $padlen = 56 - length($intro);
ian@0 124 while ($padlen > 0) {
ian@0 125 $intro .= ' ';
ian@0 126 $padlen -= 8;
ian@0 127 }
ian@0 128 next if ($size < 100);
ian@0 129 push @stack, "$intro$size\n";
ian@0 130 }
ian@0 131 }
ian@0 132
ian@0 133 print sort bysize @stack;