Debian Codegraph @

testsuite/systemtap.examples/memory/mmwriteback.stp

raw
1 #! /usr/bin/env stap
2
3 global traced_pid, command
4 global pgout, bgwriteout, kupdate
5
6 function log_event:long ()
7 {
8 return (!traced_pid || traced_pid == pid())
9 }
10
11 probe kernel.trace("balance_dirty_pages") # v3.2+
12 {
13 if (!log_event()) next
14 bgwriteout[pid()] <<< (@defined($dirtied) ? $dirtied
15 : (@defined($written) ? $written : $count))
16 command[pid()] = execname()
17 }
18
19 probe kernel.trace("writeback_pages_written") # v2.6.36+
20 {
21 if (!log_event()) next
22 kupdate[pid()] <<< (@defined($pages_written) ? $pages_written : $count)
23 command[pid()] = execname()
24 }
25
26 probe kernel.trace("mm_vmscan_writepage") # v2.6.36+
27 {
28 if (!log_event()) next
29 pgout[pid()] <<< 1
30 command[pid()] = execname()
31 }
32
33 probe begin {
34 printf("Starting data collection\n")
35 if (target())
36 printf("mode Specific Pid, traced pid: %d\n\n", target())
37 else
38 printf("mode - All Pids\n\n")
39 }
40
41 probe end, error {
42 printf("Terminating data collection\n")
43 printf(" Pdflush Pdflush Kupdate Kupdate Pgout\n")
44 printf("Command Pid count sum count sum count\n")
45 printf("------- --- ------- ------- ------- ------- -----\n")
46 foreach (pid+ in command)
47 printf("%-16s %10d %10d %10d %10d %10d %11d\n",
48 command[pid], pid,
49 @count(bgwriteout[pid]),
50 (@count(bgwriteout[pid]) ? @sum(bgwriteout[pid]) : 0),
51 @count(kupdate[pid]),
52 (@count(kupdate[pid]) ? @sum(kupdate[pid]) : 0),
53 @count(pgout[pid]))
54 }