1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title xmlns:d="http://docbook.org/ns/docbook">5.2.7. Periodically Print I/O Block Time</title><link rel="stylesheet" type="text/css" href="Common_Content/css/default.css" /><link rel="stylesheet" media="print" href="Common_Content/css/print.css" type="text/css" /><meta xmlns:d="http://docbook.org/ns/docbook" name="generator" content="not publican" /><meta xmlns:d="http://docbook.org/ns/docbook" name="package" content="" /><link rel="home" href="index.html" title="SystemTap Beginners Guide" /><link rel="up" href="mainsect-disk.html" title="5.2. Disk" /><link rel="prev" href="inodewatch2sect.html" title="5.2.6. Monitoring Changes to File Attributes" /><link rel="next" href="mainsect-profiling.html" title="5.3. Profiling" /></head><body><p id="title"></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="inodewatch2sect.html"><strong>Prev</strong></a></li><li class="home">SystemTap Beginners Guide</li><li class="next"><a accesskey="n" href="mainsect-profiling.html"><strong>Next</strong></a></li></ul><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="ioblktimesect"> </a>5.2.7. Periodically Print I/O Block Time</h3></div></div></div><a id="id5032" class="indexterm"></a><a id="id5035" class="indexterm"></a><a id="id5038" class="indexterm"></a><a id="id5041" class="indexterm"></a><a id="id5044" class="indexterm"></a><div class="para"> This section describes how to track the amount of time each block I/O requests spends waiting for completion. This is useful in determining whether there are too many outstanding block I/O operations at any given time. </div><div class="para"><div xmlns:d="http://docbook.org/ns/docbook" class="title">ioblktime.stp</div> <pre class="programlisting">#! /usr/bin/env stap global req_time%[25000], etimes probe ioblock.request { req_time[$bio] = gettimeofday_us() } probe ioblock.end { t = gettimeofday_us() s = req_time[$bio] delete req_time[$bio] if (s) { etimes[devname, bio_rw_str(rw)] <<< t - s } } /* for time being delete things that get merged with others */ probe kernel.{trace("block_bio_frontmerge"), trace("block_bio_backmerge")} { delete req_time[$bio] } probe timer.s(10), end { ansi_clear_screen() printf("%10s %3s %10s %10s %10s\n", "device", "rw", "total (us)", "count", "avg (us)") foreach ([dev,rw] in etimes - limit 20) { printf("%10s %3s %10d %10d %10d\n", dev, rw, @sum(etimes[dev,rw]), @count(etimes[dev,rw]), @avg(etimes[dev,rw])) } delete etimes } </pre> </div><div class="para"> <a class="xref" href="ioblktimesect.html#ioblktime">ioblktime.stp</a> computes the average waiting time for block I/O per device, and prints a list every 10 seconds. As always, you can revise this refresh rate by editing the specified value in <code class="command">probe timer.s(10), end {</code>. </div><div class="para"> In some cases, there can be too many outstanding block I/O operations, at which point the script can exceed the default number of <code class="command">MAXMAPENTRIES</code>. <code class="command">MAXMAPENTRIES</code> is the maximum number of rows in an array if the array size is not specified explicitly when declared. If the script exceeds the default <code class="command">MAXMAPENTRIES</code> value of 2048, run the script again with the <code class="command">stap</code> option <code class="command">-DMAXMAPENTRIES=10000</code>. </div><div class="example"><a id="ioblktimeoutput"> </a><p class="title"><strong>Example 5.12. <a class="xref" href="ioblktimesect.html#ioblktime">ioblktime.stp</a> Sample Output</strong></p><div class="example-contents"><pre class="screen"> device rw total (us) count avg (us) sda W 9659 6 1609 dm-0 W 20278 6 3379 dm-0 R 20524 5 4104 sda R 19277 5 3855</pre></div></div><div class="para"> <a class="xref" href="ioblktimesect.html#ioblktimeoutput">Example 5.12, “ioblktime.stp Sample Output”</a> displays the device name, operations performed (<code class="command">rw</code>), total wait time of all operations (<code class="command">total(us)</code>), number of operations (<code class="command">count</code>), and average wait time for all those operations (<code class="command">avg (us)</code>). The times tallied by the script are in microseconds. </div></div><ul class="docnav"><li class="previous"><a accesskey="p" href="inodewatch2sect.html"><strong>Prev</strong>5.2.6. Monitoring Changes to File Attributes</a></li><li class="up"><a accesskey="u" href="#"><strong>Up</strong></a></li><li class="home"><a accesskey="h" href="index.html"><strong>Home</strong></a></li><li class="next"><a accesskey="n" href="mainsect-profiling.html"><strong>Next</strong>5.3. Profiling</a></li></ul></body></html>
|