[OpenAFS-devel] stack usage in the linux kernel

chas williams chas@locutus.cmf.nrl.navy.mil
Mon, 19 May 2003 11:39:36 -0400


at one point there was some concern regarding afs' usage (perhaps abuse)
of the stack in the linux kernel.  i have heard some rumbling about
going to an even smaller stack, so i thought i might check up on afs
a bit.  the top ten users of stack space appear to be:

Function		Stack Usage (bytes)
----------------------- -------------------
osi_AssertFailK 	1168
VLDB_Same       	648
afs_StoreAllSegments    392
afs_FlushVCBs   	340
afs_NewDynrootVolume    260
afs_CheckServers        260
_RXAFSCB_GetCE  	116
vcache2inode    	100
vcache2fakeinode        100
osi_UFSTruncate 	100

i use the following trivial script on one of the loadable afs modules.

#!/usr/bin/perl
# stack_usage.pl
# usage: objdump --disassemble object.o | stack_usage.pl

while(<>) {
        chop;
        /:$/ && do { ($func) = /.*<(\w+)>:/; };
        /sub\s+.*,%esp$/ && do {
                ($usage) = /sub\s+\$([0-9x]+),%esp/;
                $usage = hex($usage);
                if ($usage) {
                        printf "%s\t%d\n", $func,  $usage;
                }
        };
}

i imagine its 'ok' for osi_AssertFailK to use that much stack.  it rarely
gets called and you never return from it (however, it could easily be
made acceptable -- char buf[1008]).  VLDB_Same() should probably get a
bit smaller.  the big culprit here is:

    union {
      struct vldbentry tve;
      struct nvldbentry ntve;
      struct uvldbentry utve;
    } v;

any how, if i cleaned this up does anyone think it would be worthwhile?