3 * anonpgpid.d - anonymous memory paging info by process on CPU.
4 * Written using DTrace (Solaris 10 3/05).
6 * This scripts may help identify which processes are affected by a system
7 * with low memory, which is paging to the physical swap device. A report
8 * of the process on the CPU when paging occured is printed.
10 * $Id: anonpgpid.d 8 2007-08-06 05:55:26Z brendan $
12 * USAGE: anonpgpid.d # hit Ctrl-C to end
17 * D Direction, Read or Write
18 * BYTES Total bytes during sample
22 * This program is currently an approximation - often the process when writing
23 * pages to swap will be "pageout" the pageout scanner, or "rcapd" the
24 * resource capping daemon.
26 * THANKS: James Dickens
28 * COPYRIGHT: Copyright (c) 2006 Brendan Gregg.
32 * The contents of this file are subject to the terms of the
33 * Common Development and Distribution License, Version 1.0 only
34 * (the "License"). You may not use this file except in compliance
37 * You can obtain a copy of the license at Docs/cddl1.txt
38 * or http://www.opensolaris.org/os/licensing.
39 * See the License for the specific language governing permissions
40 * and limitations under the License.
46 * Track processes accurately. This is a little difficult - anonpgout
47 * occurs asynchronously to the process, and events related to this don't
48 * point back to the process.
50 * Author: Brendan Gregg [Sydney, Australia]
52 * 25-Jul-2005 Brendan Gregg Created this.
53 * 18-Feb-2006 " " Last update.
56 #include <sys/vnode.h>
58 #pragma D option quiet
62 printf("Tracing... Hit Ctrl-C to end.\n");
65 fbt::pageio_setup:entry
66 /((args[2]->v_flag & (VISSWAP | VSWAPLIKE)) != 0)/
68 @total[pid, execname, args[3] & B_READ ? "R" : "W"] = sum(arg1);
73 printf("%6s %-16s %1s %s\n", "PID", "CMD", "D", "BYTES");
74 printa("%6d %-16s %1s %@d\n", @total);