| 1 |
#! /usr/bin/env stap |
| 2 |
|
| 3 |
global execnames, page_faults, node_faults, nodes |
| 4 |
|
| 5 |
probe vm.pagefault { |
| 6 |
execnames[pid()] = execname() |
| 7 |
page_faults[pid(), write_access ? 1 : 0] <<< 1 |
| 8 |
try { |
| 9 |
n=addr_to_node(address) |
| 10 |
node_faults[pid(), n] <<< 1 |
| 11 |
nodes[n] <<< 1 |
| 12 |
} catch { } |
| 13 |
} |
| 14 |
|
| 15 |
function print_pf () { |
| 16 |
printf ("\n") |
| 17 |
printf ("%-16s %-6s %10s %10s %-20s\n", |
| 18 |
"Execname", "PID", "RD Faults", "WR Faults", "Node:Faults") |
| 19 |
print ("======================= ========== ========== =============\n") |
| 20 |
foreach (pid in execnames) { |
| 21 |
printf ("%-16s %6d %10d %10d ", execnames[pid], pid, |
| 22 |
@count(page_faults[pid,0]), @count(page_faults[pid,1])) |
| 23 |
foreach ([node+] in nodes) { |
| 24 |
if ([pid, node] in node_faults) |
| 25 |
printf ("%d:%d ", node, @count(node_faults[pid, node])) |
| 26 |
} |
| 27 |
printf ("\n") |
| 28 |
} |
| 29 |
printf("\n") |
| 30 |
} |
| 31 |
|
| 32 |
probe begin { |
| 33 |
printf("Starting pagefault counters \n") |
| 34 |
} |
| 35 |
|
| 36 |
probe end { |
| 37 |
printf("Printing counters: \n") |
| 38 |
print_pf () |
| 39 |
printf("Done\n") |
| 40 |
} |