| 1 |
<?xml version='1.0'?> |
| 2 |
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ |
| 3 |
]> |
| 4 |
|
| 5 |
<section id="ioblktimesect"> |
| 6 |
<title>Periodically Print I/O Block Time</title> |
| 7 |
<indexterm> |
| 8 |
<primary>script examples</primary> |
| 9 |
<secondary>monitoring I/O block time</secondary> |
| 10 |
</indexterm> |
| 11 |
|
| 12 |
<indexterm> |
| 13 |
<primary>examples of SystemTap scripts</primary> |
| 14 |
<secondary>monitoring I/O block time</secondary> |
| 15 |
</indexterm> |
| 16 |
|
| 17 |
<indexterm> |
| 18 |
<primary>monitoring I/O block time</primary> |
| 19 |
<secondary>examples of SystemTap scripts</secondary> |
| 20 |
</indexterm> |
| 21 |
|
| 22 |
<indexterm> |
| 23 |
<primary>I/O block time, monitoring</primary> |
| 24 |
<secondary>examples of SystemTap scripts</secondary> |
| 25 |
</indexterm> |
| 26 |
|
| 27 |
<indexterm> |
| 28 |
<primary>printing I/O block time (periodically)</primary> |
| 29 |
<secondary>examples of SystemTap scripts</secondary> |
| 30 |
</indexterm> |
| 31 |
|
| 32 |
<para> |
| 33 |
This section describes how to track the amount of time each block I/O requests spends |
| 34 |
waiting for completion. This is useful in determining whether there are too many |
| 35 |
outstanding block I/O operations at any given time. |
| 36 |
</para> |
| 37 |
|
| 38 |
<formalpara id="ioblktime"> |
| 39 |
<title>ioblktime.stp</title> |
| 40 |
<para> |
| 41 |
<programlisting><xi:include parse="text" href="../testsuite/systemtap.examples/io/ioblktime.stp" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> |
| 42 |
</para> |
| 43 |
</formalpara> |
| 44 |
|
| 45 |
<!-- <remark>what does $count do, specifically?</remark> --> |
| 46 |
|
| 47 |
<para> |
| 48 |
<xref linkend="ioblktime"/> computes the average waiting time for block I/O per device, |
| 49 |
and prints a list every 10 seconds. As always, you can revise this refresh rate by |
| 50 |
editing the specified value in <command>probe timer.s(10), end {</command>. |
| 51 |
</para> |
| 52 |
<para> |
| 53 |
In some cases, there can be too many outstanding block |
| 54 |
I/O operations, at which point the script can exceed the default number of |
| 55 |
<command>MAXMAPENTRIES</command>. <command>MAXMAPENTRIES</command> is the maximum number of |
| 56 |
rows in an array if the array size is not specified explicitly when declared. If the script |
| 57 |
exceeds the default <command>MAXMAPENTRIES</command> value of 2048, run the script again with |
| 58 |
the <command>stap</command> option <command>-DMAXMAPENTRIES=10000</command>. |
| 59 |
</para> |
| 60 |
|
| 61 |
|
| 62 |
<example id="ioblktimeoutput"> |
| 63 |
<title><xref linkend="ioblktime"/> Sample Output</title> |
| 64 |
<screen> device rw total (us) count avg (us) |
| 65 |
sda W 9659 6 1609 |
| 66 |
dm-0 W 20278 6 3379 |
| 67 |
dm-0 R 20524 5 4104 |
| 68 |
sda R 19277 5 3855</screen> |
| 69 |
</example> |
| 70 |
|
| 71 |
<para> |
| 72 |
<xref linkend="ioblktimeoutput"/> displays the device name, operations performed |
| 73 |
(<command>rw</command>), total wait time of all operations (<command>total(us)</command>), |
| 74 |
number of operations (<command>count</command>), and average |
| 75 |
wait time for all those operations (<command>avg (us)</command>). The times tallied by the |
| 76 |
script are in microseconds. |
| 77 |
</para> |
| 78 |
|
| 79 |
<!-- |
| 80 |
global reads, writes, total_io |
| 81 |
|
| 82 |
probe kernel.function("vfs_read") { |
| 83 |
reads[execname()] += $count |
| 84 |
} |
| 85 |
|
| 86 |
probe kernel.function("vfs_write") { |
| 87 |
writes[execname()] += $count |
| 88 |
} |
| 89 |
|
| 90 |
# print top 10 IO processes every 5 seconds |
| 91 |
probe timer.s(5) { |
| 92 |
foreach (name in writes) |
| 93 |
total_io[name] += writes[name] |
| 94 |
foreach (name in reads) |
| 95 |
total_io[name] += reads[name] |
| 96 |
printf ("%16s\t%10s\t%10s\n", "Process", "KB Read", "KB Written") |
| 97 |
foreach (name in total_io- limit 10) |
| 98 |
printf("%16s\t%10d\t%10d\n", name, |
| 99 |
reads[name]/1024, writes[name]/1024) |
| 100 |
delete reads |
| 101 |
delete writes |
| 102 |
delete total_io |
| 103 |
print("\n") |
| 104 |
} |
| 105 |
--> |
| 106 |
|
| 107 |
</section> |