blob: 0ba1ee483929ab79fe0ce40be19f9ac61a18f644 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/bin/bash
pname=""
verbose=""
function usage {
echo "Usage: funccount [process]"
}
if [ $# -eq 1 ]; then
pname=$1
fi
echo "Creating and building SystemTap module..."
stap "$verbose" -e '
global timebyfunc, pages, page_sz
global start, pname_str, totcalls
probe begin {
pname_str = "'$pname'"
printf("Collecting data for %s - type Ctrl-C to print output and exit...\n", pname_str);
}
probe kernel.function("mpage_readpages")
{
if ($nr_pages && execname() == pname_str) {
start[$nr_pages] = gettimeofday_ns()
pages=$nr_pages
}
}
probe kernel.function("mpage_readpages").return
{
if (pages == 0)
next
delta = gettimeofday_ns() - start[pages]
timebyfunc[pages] <<< delta
page_sz[pages] = pages
delete start[pages]
pages=0
}
function print_header() {
printf("%-19s %10s %12s\n",
"Call", "Count", "Total ns")
}
probe end {
print_header()
foreach (page in page_sz-) {
printf("mpage_readpages(%d) %10d %12d\n", page_sz[page],
@count(timebyfunc[page]), @sum(timebyfunc[page]))
totcalls += @count(timebyfunc[page])
}
printf("Total Calls: %d\n", totcalls);
delete page_sz
delete timebyfunc
}'
|