3 * seeksize.d - analyse disk head seek distance by process.
4 * Written using DTrace (Solaris 10 3/05).
6 * Disk I/O events caused by processes will in turn cause the disk heads
7 * to seek. This program analyses those seeks, so that we can determine
8 * if processes are causing the disks to seek in a "random" or "sequential"
11 * $Id: seeksize.d 3 2007-08-01 10:50:08Z brendan $
13 * USAGE: seeksize.d # wait several seconds, then hit Ctrl-C
17 * CMD command and argument list
18 * value distance in disk blocks (sectors)
19 * count number of I/O operations
21 * SEE ALSO: bitesize.d, iosnoop
23 * COPYRIGHT: Copyright (c) 2006 Brendan Gregg.
27 * The contents of this file are subject to the terms of the
28 * Common Development and Distribution License, Version 1.0 only
29 * (the "License"). You may not use this file except in compliance
32 * You can obtain a copy of the license at Docs/cddl1.txt
33 * or http://www.opensolaris.org/os/licensing.
34 * See the License for the specific language governing permissions
35 * and limitations under the License.
39 * 11-Sep-2004 Brendan Gregg Created this.
40 * 10-Oct-2004 " " Rewrote to use the io provider.
41 * 20-Apr-2006 " " Last update.
44 #pragma D option quiet
51 printf("Tracing... Hit Ctrl-C to end.\n");
60 /self->last[args[0]->b_edev] != 0/
62 /* calculate seek distance */
63 this->last = self->last[args[0]->b_edev];
64 this->dist = (int)(args[0]->b_blkno - this->last) > 0 ?
65 args[0]->b_blkno - this->last : this->last - args[0]->b_blkno;
68 @Size[pid, curpsinfo->pr_psargs] = quantize(this->dist);
73 /* save last position of disk head */
74 self->last[args[0]->b_edev] = args[0]->b_blkno +
75 args[0]->b_bcount / 512;
83 printf("\n%8s %s\n", "PID", "CMD");
84 printa("%8d %S\n%@d\n", @Size);