summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.samples/kmalloc-stacks.stp
blob: 25a23f2d27d3c4972d370915eb0a9daf4ca19fa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
global kmalloc_stack

function reset_maxaction () %{ 
        if (CONTEXT && CONTEXT->actioncount) 
                CONTEXT->actioncount=0; 
%} 

function write_output()
{
	foreach (stack in kmalloc_stack) {
		log("<hashkey>");
		print_stack(stack);
		log("</hashkey>");
		print("<hashval>");
		print(sprint(kmalloc_stack[stack]));
		log("</hashval>");
		reset_maxaction();
	}
}

probe timer.jiffies(5000)
{
	write_output();
	delete kmalloc_stack;
}

probe kernel.function("__kmalloc")
{
	kmalloc_stack[backtrace()]++; 
}

probe end
{
	write_output();
}