Commit 8ad2914d9cc55be651ef3bd676981a72c9001a47

Authored by Randy Dunlap
Committed by Linus Torvalds
1 parent 5ec3e4b7ae

[PATCH] checkstack: print module names

Finding "init_module" high stack usage problems is challenging when there
are over 1600 "init_module" functions in the kernel tree, so make
checkstack.pl print out the filename where the stack usage occurs.  This is
useful for code built as loadable modules.

For built-in code, it just prints the kernel image file name, like
"vmlinux".  Examples:

(before patch:)
0x0000000d callback:					1928
0xffffffff81678c09 huft_build:				1560
0x0018 init_module:					1512

(after patch:)
0x0000000d callback [divacapi]:				1928
0xffffffff81678c09 huft_build [vmlinux]:		1560
0x0018 init_module [hdaps]:				1512

Also change one if-series to use elsif to cut down on unneeded tests.

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Acked-by: Joern Engel <joern@wh.fh-wedel.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 12 additions and 2 deletions Side-by-side Diff

scripts/checkstack.pl
... ... @@ -89,11 +89,21 @@
89 89 #
90 90 my $funcre = qr/^$x* <(.*)>:$/;
91 91 my $func;
  92 +my $file, $lastslash;
  93 +
92 94 while (my $line = <STDIN>) {
93 95 if ($line =~ m/$funcre/) {
94 96 $func = $1;
95 97 }
96   - if ($line =~ m/$re/) {
  98 + elsif ($line =~ m/(.*):\s*file format/) {
  99 + $file = $1;
  100 + $file =~ s/\.ko//;
  101 + $lastslash = rindex($file, "/");
  102 + if ($lastslash != -1) {
  103 + $file = substr($file, $lastslash + 1);
  104 + }
  105 + }
  106 + elsif ($line =~ m/$re/) {
97 107 my $size = $1;
98 108 $size = hex($size) if ($size =~ /^0x/);
99 109  
... ... @@ -109,7 +119,7 @@
109 119 $addr =~ s/ /0/g;
110 120 $addr = "0x$addr";
111 121  
112   - my $intro = "$addr $func:";
  122 + my $intro = "$addr $func [$file]:";
113 123 my $padlen = 56 - length($intro);
114 124 while ($padlen > 0) {
115 125 $intro .= ' ';