forked from dengliu/systemtap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mmanonpage.stp
72 lines (61 loc) · 1.81 KB
/
mmanonpage.stp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/stap
global traced_pid, command
global allocation, free
global anon_fault, anon_usrfree, anon_pgin, anon_cow, anon_unmap
function log_event:long ()
{
return (!traced_pid || traced_pid == pid())
}
probe kernel.trace("mm_page_alloc")!, kernel.trace("mm_page_allocation") {
if (!log_event()) next
allocation[pid()] <<< 1
command[pid()] = execname()
}
probe kernel.trace("mm_page_free")!, kernel.trace("mm_page_free_direct") {
if (!log_event()) next
free[pid()] <<< 1
}
probe kernel.trace("mm_anon_fault") {
if (!log_event()) next
anon_fault[pid()] <<< 1
}
probe kernel.trace("mm_anon_pgin") {
if (!log_event()) next
anon_pgin[pid()] <<< 1
}
probe kernel.trace("mm_anon_cow") {
if (!log_event()) next
anon_cow[pid()] <<< 1
}
probe kernel.trace("mm_anon_unmap") {
if (!log_event()) next
anon_unmap[pid()] <<< 1
}
probe kernel.trace("mm_anon_userfree") {
if (!log_event()) next
anon_usrfree[pid()] <<< 1
}
probe begin {
printf("Starting data collection\n")
traced_pid = target()
if (traced_pid)
printf("mode Specific Pid, traced pid: %d\n\n", traced_pid)
else
printf("mode - All Pids\n\n")
}
probe end {
printf("Terminating data collection\n")
printf("%-16s %6s %8s %7s %7s %7s %7s %7s %7s\n",
"Command", "Pid", "Alloc", "Free", "A_fault",
"A_ufree", "A_pgin", "A_cow", "A_unmap")
printf("%-16s %6s %8s %7s %7s %7s %7s %7s %7s\n",
"-------", "---", "-----", "----", "-------",
"-------", "------", "-----", "-------")
foreach (pid in allocation-)
printf("%-16s %6d %8d %7d %7d %7d %7d %7d %7d\n",
command[pid], pid,
@count(allocation[pid]), @count(free[pid]),
@count(anon_fault[pid]), @count(anon_usrfree[pid]),
@count(anon_pgin[pid]), @count(anon_cow[pid]),
@count(anon_unmap[pid]))
}