# cache_grow.stp # This script captures tallies stack back traces each time the slab cache # size is increased. The program is run with the following command: # # stap cache_grow.stp # # When the script completes it prints out top twenty executable that # caused slabs to grow. This is followed by stack backtraces showing path # in kernel to the cache_grow function. global stats, stacks probe kernel.function("cache_grow") { name = kernel_string($cachep->name) exec = execname() stats[exec, name] <<< 1 stacks[exec, name, backtrace()] <<< 1 } probe begin { printf("Type ctrl-c to stop script, and print out data (top 20 lists)\n") } probe end { printf("Number of cache_grow called by process and slab name\n") foreach ([exec, name] in stats- limit 20) { printf("%s, %s:\t%d\n", exec, name, @count(stats[exec, name])) } printf("\nBacktrace of processes when cache_grow called\n") foreach ([exec, cache, bt] in stacks- limit 20) { printf("Exec: %s Slab name: %s Count: %d\n", exec, cache, @count(stacks[exec, cache, bt])) print_stack(bt) printf("\n-------------------------------------------------------\n\n") } }