1#!/usr/sbin/dtrace -s 2/* 3 * intoncpu.d - print interrupt on-cpu usage. 4 * Written using DTrace (Solaris 10 3/05) 5 * 6 * $Id: intoncpu.d 3 2007-08-01 10:50:08Z brendan $ 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 * 20-Apr-2006 " " Last update. 37 */ 38 39#pragma D option quiet 40 41dtrace:::BEGIN 42{ 43 printf("Tracing... Hit Ctrl-C to end.\n"); 44} 45 46sdt:::interrupt-start 47{ 48 self->ts = vtimestamp; 49} 50 51sdt:::interrupt-complete 52/self->ts && arg0 != 0/ 53{ 54 this->devi = (struct dev_info *)arg0; 55 /* this checks the pointer is valid, */ 56 self->name = this->devi != 0 ? 57 stringof(`devnamesp[this->devi->devi_major].dn_name) : "?"; 58 this->inst = this->devi != 0 ? this->devi->devi_instance : 0; 59 @Time[self->name, this->inst] = quantize(vtimestamp - self->ts); 60 self->name = 0; 61} 62 63dtrace:::END 64{ 65 printa("%s%d\n%@d", @Time); 66} 67