Hi,
I've been having some fun playing around with maps keyed on stack
traces (very cool to be able to do this) and have checked into
systemtap.samples a systemtap script (kmalloc-stacks.stp) and a perl
script (kmalloc-top) that in combination continuously track the
different execution paths to kmalloc(). It keeps counts of the
different execution paths in a systemtap hash, and periodically dumps
the hash contents (and clears the hash table) to the perl script,
which rehashes them in user space. At the end of the run (Ctrl-C), it
sorts the accumulated hash table and filters out any stacks that
contain any of the user-supplied regexps (-e option), which helps cut
down on noise e.g.
# ./kmalloc-top -e sys_select,alloc_skb
Here's an example of the output (gathered over a kernel compile):