1#!/usr/sbin/dtrace -s
2/*
3 * intoncpu.d - print interrupt on-cpu usage.
4 *              Written using DTrace (Solaris 10 3/05)
5 *
6 * 20-Apr-2006, ver 0.91
7 *
8 * USAGE:       intoncpu.d      # wait several seconds, then hit Ctrl-C
9 *
10 * FIELDS:
11 *		value	Time interrupt thread was on-cpu, ns
12 *		count	Number of occurrences of at least this time
13 *
14 * BASED ON: /usr/demo/dtrace/intr.d
15 *
16 * SEE ALSO: DTrace Guide "sdt Provider" chapter (docs.sun.com)
17 *           intrstat(1M)
18 *
19 * PORTIONS: Copyright (c) 2005, 2006 Brendan Gregg.
20 *
21 * CDDL HEADER START
22 *
23 *  The contents of this file are subject to the terms of the
24 *  Common Development and Distribution License, Version 1.0 only
25 *  (the "License").  You may not use this file except in compliance
26 *  with the License.
27 *
28 *  You can obtain a copy of the license at Docs/cddl1.txt
29 *  or http://www.opensolaris.org/os/licensing.
30 *  See the License for the specific language governing permissions
31 *  and limitations under the License.
32 *
33 * CDDL HEADER END
34 *
35 * 09-May-2005  Brendan Gregg   Created this.
36 */
37
38#pragma D option quiet
39
40dtrace:::BEGIN
41{
42	printf("Tracing... Hit Ctrl-C to end.\n");
43}
44
45sdt:::interrupt-start
46{
47	self->ts = vtimestamp;
48}
49
50sdt:::interrupt-complete
51/self->ts && arg0 != 0/
52{
53	this->devi = (struct dev_info *)arg0;
54	/* this checks the pointer is valid, */
55	self->name = this->devi != 0 ?
56	    stringof(`devnamesp[this->devi->devi_major].dn_name) : "?";
57	this->inst = this->devi != 0 ? this->devi->devi_instance : 0;
58	@Time[self->name, this->inst] = quantize(vtimestamp - self->ts);
59	self->name = 0;
60}
61
62dtrace:::END
63{
64	printa("%s%d\n%@d", @Time);
65}
66