]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Cpu/inttimes.d
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Cpu / inttimes.d
1 #!/usr/sbin/dtrace -s
2 /*
3  * inttimes.d - print interrupt on-cpu time.
4  *              Written using DTrace (Solaris 10 3/05)
5  *
6  * $Id: inttimes.d 3 2007-08-01 10:50:08Z brendan $
7  *
8  * USAGE:       inttimes.d      # wait several seconds, then hit Ctrl-C
9  *
10  * FIELDS:
11  *              DEVICE          instance name of device driver
12  *              TIME (ns)       sum of time spent servicing interrupt (ns)
13  *
14  * BASED ON: /usr/demo/dtrace/intr.d
15  *
16  * SEE ALSO:
17  *          DTrace Guide "sdt Provider" chapter (docs.sun.com)
18  *          intrstat(1M)
19  *
20  * PORTIONS: Copyright (c) 2005 Brendan Gregg.
21  *
22  * CDDL HEADER START
23  *
24  *  The contents of this file are subject to the terms of the
25  *  Common Development and Distribution License, Version 1.0 only
26  *  (the "License").  You may not use this file except in compliance
27  *  with the License.
28  *
29  *  You can obtain a copy of the license at Docs/cddl1.txt
30  *  or http://www.opensolaris.org/os/licensing.
31  *  See the License for the specific language governing permissions
32  *  and limitations under the License.
33  *
34  * CDDL HEADER END
35  *
36  * 28-Jun-2005  Brendan Gregg   Created this.
37  * 20-Apr-2006     "      "     Last update.
38  */
39
40 #pragma D option quiet
41
42 dtrace:::BEGIN
43 {
44         printf("Tracing... Hit Ctrl-C to end.\n");
45 }
46
47 sdt:::interrupt-start
48 {
49         self->ts = vtimestamp;
50 }
51
52 sdt:::interrupt-complete
53 /self->ts && arg0 != 0/
54 {
55         this->devi = (struct dev_info *)arg0;
56         /* this checks the pointer is valid, */
57         self->name = this->devi != 0 ?
58             stringof(`devnamesp[this->devi->devi_major].dn_name) : "?";
59         this->inst = this->devi != 0 ? this->devi->devi_instance : 0;
60         @num[self->name, this->inst] = sum(vtimestamp - self->ts);
61         self->name = 0;
62 }
63
64 sdt:::interrupt-complete
65 {
66         self->ts = 0;
67 }
68
69 dtrace:::END
70 {
71         printf("%11s    %16s\n", "DEVICE", "TIME (ns)");
72         printa("%10s%-3d %@16d\n", @num);
73 }