1235368Sgnn#!/usr/sbin/dtrace -s 2235368Sgnn/* 3235368Sgnn * inttimes.d - print interrupt on-cpu time. 4235368Sgnn * Written using DTrace (Solaris 10 3/05) 5235368Sgnn * 6235368Sgnn * $Id: inttimes.d 3 2007-08-01 10:50:08Z brendan $ 7235368Sgnn * 8235368Sgnn * USAGE: inttimes.d # wait several seconds, then hit Ctrl-C 9235368Sgnn * 10235368Sgnn * FIELDS: 11235368Sgnn * DEVICE instance name of device driver 12235368Sgnn * TIME (ns) sum of time spent servicing interrupt (ns) 13235368Sgnn * 14235368Sgnn * BASED ON: /usr/demo/dtrace/intr.d 15235368Sgnn * 16235368Sgnn * SEE ALSO: 17235368Sgnn * DTrace Guide "sdt Provider" chapter (docs.sun.com) 18235368Sgnn * intrstat(1M) 19235368Sgnn * 20235368Sgnn * PORTIONS: Copyright (c) 2005 Brendan Gregg. 21235368Sgnn * 22235368Sgnn * CDDL HEADER START 23235368Sgnn * 24235368Sgnn * The contents of this file are subject to the terms of the 25235368Sgnn * Common Development and Distribution License, Version 1.0 only 26235368Sgnn * (the "License"). You may not use this file except in compliance 27235368Sgnn * with the License. 28235368Sgnn * 29235368Sgnn * You can obtain a copy of the license at Docs/cddl1.txt 30235368Sgnn * or http://www.opensolaris.org/os/licensing. 31235368Sgnn * See the License for the specific language governing permissions 32235368Sgnn * and limitations under the License. 33235368Sgnn * 34235368Sgnn * CDDL HEADER END 35235368Sgnn * 36235368Sgnn * 28-Jun-2005 Brendan Gregg Created this. 37235368Sgnn * 20-Apr-2006 " " Last update. 38235368Sgnn */ 39235368Sgnn 40235368Sgnn#pragma D option quiet 41235368Sgnn 42235368Sgnndtrace:::BEGIN 43235368Sgnn{ 44235368Sgnn printf("Tracing... Hit Ctrl-C to end.\n"); 45235368Sgnn} 46235368Sgnn 47235368Sgnnsdt:::interrupt-start 48235368Sgnn{ 49235368Sgnn self->ts = vtimestamp; 50235368Sgnn} 51235368Sgnn 52235368Sgnnsdt:::interrupt-complete 53235368Sgnn/self->ts && arg0 != 0/ 54235368Sgnn{ 55235368Sgnn this->devi = (struct dev_info *)arg0; 56235368Sgnn /* this checks the pointer is valid, */ 57235368Sgnn self->name = this->devi != 0 ? 58235368Sgnn stringof(`devnamesp[this->devi->devi_major].dn_name) : "?"; 59235368Sgnn this->inst = this->devi != 0 ? this->devi->devi_instance : 0; 60235368Sgnn @num[self->name, this->inst] = sum(vtimestamp - self->ts); 61235368Sgnn self->name = 0; 62235368Sgnn} 63235368Sgnn 64235368Sgnnsdt:::interrupt-complete 65235368Sgnn{ 66235368Sgnn self->ts = 0; 67235368Sgnn} 68235368Sgnn 69235368Sgnndtrace:::END 70235368Sgnn{ 71235368Sgnn printf("%11s %16s\n", "DEVICE", "TIME (ns)"); 72235368Sgnn printa("%10s%-3d %@16d\n", @num); 73235368Sgnn} 74