<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Anchor Web Hosting Blog &#187; blktrace</title>
	<atom:link href="http://www.anchor.com.au/blog/tag/blktrace/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.anchor.com.au/blog</link>
	<description>A view into the Anchor Engineroom</description>
	<lastBuildDate>Wed, 08 Feb 2012 00:51:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Tracing I/O usage on Linux</title>
		<link>http://www.anchor.com.au/blog/2009/02/tracing-io-usage-on-linux/</link>
		<comments>http://www.anchor.com.au/blog/2009/02/tracing-io-usage-on-linux/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 01:09:39 +0000</pubDate>
		<dc:creator>oliver</dc:creator>
				<category><![CDATA[FTW]]></category>
		<category><![CDATA[blktrace]]></category>
		<category><![CDATA[btrace]]></category>
		<category><![CDATA[io]]></category>
		<category><![CDATA[iotop]]></category>
		<category><![CDATA[trace]]></category>

		<guid isPermaLink="false">http://www.anchor.com.au/blog/?p=439</guid>
		<description><![CDATA[I/O subsystems are a whole industry of their own, and many libraries could be (and probably have been) written on the subject already. The particular sub-topic I&#8217;m talking about today is when you are faced with a machine that you suspect to be suffering from heavy I/O load, and you want to find the culprit. [...]]]></description>
			<content:encoded><![CDATA[<p>I/O subsystems are a whole industry of their own, and many libraries could be (and probably have been) written on the subject already. The particular sub-topic I&#8217;m talking about today is when you are faced with a machine that you suspect to be suffering from heavy I/O load, and you want to find the culprit.</p>
<p>Sadly, this is an area that Windows has the upper hand. You can quite easily using the Performance Monitor determine which process is using the largest chunk of your disk I/O. On Linux things can be a little harder, however not all is lost.</p>
<p>If you are fortunate enough to be experiencing the problem on a machine running at least a 2.6.20 kernel and with Python 2.5 or later available, you can run <a href="http://guichaz.free.fr/iotop/">IOTop</a>. This prints out I/O usage data in a similar format to the standard &#8220;top&#8221; command, and it looks something like this:</p>
<div id="attachment_440" class="wp-caption aligncenter" style="width: 210px"><a href="http://www.anchor.com.au/blog/wp-content/uploads/2009/02/iotop_big.png"><img class="size-thumbnail wp-image-440" src="http://www.anchor.com.au/blog/wp-content/uploads/2009/02/iotop_big-150x150.png" alt="IOTop Output" width="200" height="200" /></a><p class="wp-caption-text">IOTop Output - picture sourced from http://guichaz.free.fr/iotop/iotop_big.png</p></div>
<p>Sadly at the time I needed to diagnose I/O, the machine I was using had neither a 2.6.20 kernel nor Python 2.5 so I was forced into seeking other methods to trace the I/O. Cue <a href="http://linux.die.net/man/8/blktrace">Blktrace</a>. This hooks into the kernel&#8217;s debug filesystem to gather I/O stats and presents a fairly raw trace of what&#8217;s going on. You can download the source from <a href="http://brick.kernel.dk/snaps/">here</a> or find RPM packages for recent RHEL at the <a href="http://packages.sw.be/blktrace/">RPMForge Repository.</a></p>
<p>While it is possible to use blktrace directly, there is also a helper script <em>btrace</em> which shortcuts a lot of the most commonly used options and output formatting. You will need to mount <em>debugfs</em> on /sys/kernel/debug then you are ready to roll!</p>
<pre>root@blarg:~# mount -t debugfs none /sys/kernel/debug
root@blarg:~# btrace /dev/sda
  8,0    0        1     0.000000000  2884  A   W 60060711 + 8 &lt;- (8,1) 60060648
  8,0    0        2     0.000000244  2884  Q   W 60060711 + 8 [kjournald]
  8,0    0        3     0.000005278  2884  G   W 60060711 + 8 [kjournald]
  8,0    0        4     0.000006933  2884  P   N [kjournald]
  8,0    0        5     0.000007515  2884  I   W 60060711 + 8 [kjournald]
  8,0    0        6     0.000010068  2884  A   W 60093063 + 8 &lt;- (8,1) 60093000
  8,0    0        7     0.000010263  2884  Q   W 60093063 + 8 [kjournald]
  8,0    0        8     0.000011588  2884  G   W 60093063 + 8 [kjournald]
  8,0    0        9     0.000012072  2884  I   W 60093063 + 8 [kjournald]</pre>
<p>OK so there&#8217;s not much I/O happening on my workstation, but on the machine I was diagnosing recently, the output of btrace spewed out hundreds of lines per second, many of them referring to a process running the <em>mutt</em> mail program. It turned out one of the users had approximately 90,000 emails in one folder that mutt was constantly rescanning since the machine didn&#8217;t have a recent enough version of mutt to support header caching.</p>
<p>The emails were archived away and the I/O problem was resolved. Whereas previously we could only guess at what was causing the I/O load, blktrace squarely points the finger at the problem process. On later machines IOTop would have been even more straightforward. Both are valuable additions to the sysadmin toolkit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anchor.com.au/blog/2009/02/tracing-io-usage-on-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

