stack checking (was: Re: RFC: turn kmalloc+memset(,0,) into kcalloc)

Jörn Engel
2005-04-08T13:01:36Z

On Fri, 8 April 2005 13:38:22 +0100, Paulo Marques wrote:
> Adrian Bunk wrote:
>
> >E.g. read my "Stack usage tasks" email. The benefits would only be
> >present for people using GNU gcc 3.4 or SuSE gcc 3.3 on i386, but this
> >is a reasonable subset of the kernel users - and it brings them a
> >2% kernel size improvement.
>
> I've read that thread, but it seems that it is at a dead end right now,
> since we don't have a good tool to find out which functions are abusing
> the stack with unit-at-a-time.
>
> Is there some way to even limit the search, like using a stack usage log
> from a compilation without unit-at-a-time, and going over the hotspots
> to check for problems?
>
> If we can get a list, even if it contains a lot of false positives, I
> would more than happy to help out...

The situation is bad, but not that bad.

As a starter, you can compile the kernel with gcc 3.4 and run "make
checkstack" on it. No call graph information in there, but getting
all functions on the list below 2k would help.

Next step would be a small hack to my private tool to read stack
consumption from gcc 3.4 and call graph from gcc 3.1. Obviously you
get tons of "these five functions in the call graph are actually a
single one in the real binary". Quick and dirty.

Then someone (doesn't have to be me) should spend some time to port
the callgraph extraction code from 3.1 to 3.4 or 4.0. Before the
unit-at-a-time thing came up, I wanted to port things to sparse. But
sparse would suffer from the same problem of not inlining functions
identically to the real compiler, so current gcc appears to be a
better target.

Step 1 is possible right now, step 2 might take a while (i'm on
vacation) and step 3 may not happen this year anymore, unless someone
else wants to start hacking on it.

Jörn

--
Courage is not the absence of fear, but rather the judgement that
something else is more important than fear.
-- Ambrose Redmoon