I want to calculate how much CPU I am spending servicing interrupts. I took the /usr/demo/dtrace/intr.d script and modified it slightly. I reasoned that the per cent CPU consumed would be the difference in vtimestamp between interrupt start and interrupt complete, summed over the 10 sec interval and divided by the nano sec in the interval. So %CPU= (sum from above/10/10**9)*100*100 = sum/10**6 to get hundredth''s of a per cent CPU. 10000=1 CPU. ( the sampling interval was 10 sec) The numbers I am getting seem high. My implementation follows. Consider the following script, #!/usr/sbin/dtrace -qs /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * This D script is used as an example in the Solaris Dynamic Tracing Guide * in Chapter 22, "sdt Provider". * * The full text of Chapter 22 may be found here: * * http://docs.sun.com/db/doc/817-6223?a=view * * On machines that have DTrace installed, this script is available as * intr.d in /usr/demo/dtrace, a directory that contains all D scripts * used in the Solaris Dynamic Tracing Guide. A table of the scripts and their * corresponding chapters may be found here: * * file:///usr/demo/dtrace/index.html */ interrupt-start { self->ts = vtimestamp; } interrupt-complete /self->ts && arg0 / { this->devi = (struct dev_info *)arg0; @[cpu,stringof(`devnamesp[this->devi->devi_major].dn_name), this->devi->devi_instance] = sum(vtimestamp - self->ts); @c[cpu,stringof(`devnamesp[this->devi->devi_major].dn_name), this->devi->devi_instance] = count(); self->ts=0; } tick-10s { normalize(@, 1000000); printf("\nTime = %Y \n",walltimestamp); printa("CPU= %d, device= %s, instance= %d CPU_hundreds_per_cent = %@d \n", @); printa("CPU= %d, device= %s, instance= %d number_of_interrupts = %@d \n", @c); clear(@); clear(@c); } tick-100s { exit(0); } Comments or suggestions are appreciated. rick -- Rickey C. Weisner Software Development and Performance Specialist Sun Microsystems, INC cell phone: 615-308-1147 email: rick.weisner at sun.com
Hey Rick, How are you doing? Your script looks good to me. In fact, I tested it out myself and it worked out good. Does intrstat agree with you? You can both with a slight modification of your script: - Change your tick-10s -> END - Run with ''dtrace ... -c ''intrstat 10 1'' -- Just me, Wire ... On 9/28/06, rickey c weisner <rick.weisner at sun.com> wrote:> I want to calculate how much CPU I am spending servicing interrupts. > I took the /usr/demo/dtrace/intr.d script and modified it slightly. > I reasoned that the per cent CPU consumed would be the > difference in vtimestamp between interrupt start and interrupt complete, > summed over the 10 sec interval and divided by the nano sec in the interval. > So %CPU= (sum from above/10/10**9)*100*100 = sum/10**6 to get hundredth''s of > a per cent CPU. 10000=1 CPU. ( the sampling interval was 10 sec) > The numbers I am getting seem high. > My implementation follows. > Consider the following script, > #!/usr/sbin/dtrace -qs > /* > * Copyright 2005 Sun Microsystems, Inc. All rights reserved. > * Use is subject to license terms. > * > * This D script is used as an example in the Solaris Dynamic Tracing Guide > * in Chapter 22, "sdt Provider". > * > * The full text of Chapter 22 may be found here: > * > * http://docs.sun.com/db/doc/817-6223?a=view > * > * On machines that have DTrace installed, this script is available as > * intr.d in /usr/demo/dtrace, a directory that contains all D scripts > * used in the Solaris Dynamic Tracing Guide. A table of the scripts and their > * corresponding chapters may be found here: > * > * file:///usr/demo/dtrace/index.html > */ > > interrupt-start > { > self->ts = vtimestamp; > } > > interrupt-complete > /self->ts && arg0 / > { > this->devi = (struct dev_info *)arg0; > @[cpu,stringof(`devnamesp[this->devi->devi_major].dn_name), > this->devi->devi_instance] = sum(vtimestamp - self->ts); > @c[cpu,stringof(`devnamesp[this->devi->devi_major].dn_name), > this->devi->devi_instance] = count(); > self->ts=0; > } > tick-10s > { > normalize(@, 1000000); > printf("\nTime = %Y \n",walltimestamp); > printa("CPU= %d, device= %s, instance= %d CPU_hundreds_per_cent = %@d \n", @); > printa("CPU= %d, device= %s, instance= %d number_of_interrupts = %@d \n", @c); > clear(@); > clear(@c); > } > tick-100s > { > exit(0); > } > > Comments or suggestions are appreciated. > rick > -- > > Rickey C. Weisner > Software Development and Performance Specialist > Sun Microsystems, INC > cell phone: 615-308-1147 > email: rick.weisner at sun.com > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
rickey c weisner wrote:> I want to calculate how much CPU I am spending servicing interrupts. > I took the /usr/demo/dtrace/intr.d script and modified it slightly. > I reasoned that the per cent CPU consumed would be the > difference in vtimestamp between interrupt start and interrupt complete, > summed over the 10 sec interval and divided by the nano sec in the interval. > So %CPU= (sum from above/10/10**9)*100*100 = sum/10**6 to get hundredth''s of > a per cent CPU. 10000=1 CPU. ( the sampling interval was 10 sec) > The numbers I am getting seem high.Take a look at the kstats for the cpus; they''re more likely to get you uninflated numbers. DTrace is a wonderful tool, but I use it''s timing info from short events w/ a large grain of salt. 83% kstat cpu::intrstat module: cpu instance: 0 name: intrstat class: misc crtime 33.895227496 level-1-count 79223039 level-1-time 425002295121 level-10-count 111287579 level-10-time 445476322445 level-11-count 43838509 level-11-time 5616701210 level-12-count 2 level-12-time 12819 level-13-count 0 level-13-time 0 level-14-count 111287579 level-14-time 147382628805 level-15-count 22823591 level-15-time 30642427092 level-2-count 109268089 level-2-time 20202863349 level-3-count 3 level-3-time 23508 level-4-count 3074934 level-4-time 10441259535 level-5-count 730069 level-5-time 22474668458 level-6-count 55352878 level-6-time 531883479180 level-7-count 0 level-7-time 0 level-8-count 0 level-8-time 0 level-9-count 9392068 level-9-time 371481324152 snaptime 1092714.35739276 These stats are maintained using the highest possible resolution timers. - Bart -- Bart Smaalders Solaris Kernel Performance barts at cyber.eng.sun.com http://blogs.sun.com/barts