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