summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.examples/io
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.examples/io')
-rw-r--r--testsuite/systemtap.examples/io/ioblktime.meta13
-rwxr-xr-xtestsuite/systemtap.examples/io/ioblktime.stp29
-rwxr-xr-xtestsuite/systemtap.examples/io/traceio.stp33
3 files changed, 65 insertions, 10 deletions
diff --git a/testsuite/systemtap.examples/io/ioblktime.meta b/testsuite/systemtap.examples/io/ioblktime.meta
new file mode 100644
index 00000000..18a8b168
--- /dev/null
+++ b/testsuite/systemtap.examples/io/ioblktime.meta
@@ -0,0 +1,13 @@
+title: Average Time Block IO Requests Spend in Queue
+name: ioblktime.stp
+version: 1.0
+author: William Cohen
+keywords: io
+subsystem: kernel
+status: production
+exit: user-controlled
+output: sorted-list
+scope: system-wide
+description: The ioblktime.stp script tracks the amount of time that each block IO requests spend waiting for completion. The script computes the average time waiting time for block IO per device and prints list every 10 seconds. In some cases there can be too many oustanding block IO operations and the script may exceed the default number of MAXMAPENTRIES allowed. In this case the allowed number can be increased with "-DMAXMAPENTRIES=10000" option on the stap command line.
+test_check: stap -p4 ioblktime.stp
+test_installcheck: stap ioblktime.stp -c "sleep 1"
diff --git a/testsuite/systemtap.examples/io/ioblktime.stp b/testsuite/systemtap.examples/io/ioblktime.stp
new file mode 100755
index 00000000..d6267b3e
--- /dev/null
+++ b/testsuite/systemtap.examples/io/ioblktime.stp
@@ -0,0 +1,29 @@
+#! /usr/bin/env stap
+
+global req_time, 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
+ }
+}
+
+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
+}
diff --git a/testsuite/systemtap.examples/io/traceio.stp b/testsuite/systemtap.examples/io/traceio.stp
index 9e2deec6..875000cb 100755
--- a/testsuite/systemtap.examples/io/traceio.stp
+++ b/testsuite/systemtap.examples/io/traceio.stp
@@ -1,6 +1,9 @@
#! /usr/bin/env stap
# traceio.stp
# Copyright (C) 2007 Red Hat, Inc., Eugene Teo <eteo@redhat.com>
+# Copyright (C) 2009 Kai Meyer <kai@unixlords.com>
+# Fixed a bug that allows this to run longer
+# And added the humanreadable function
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -10,22 +13,32 @@
global reads, writes, total_io
probe vfs.read.return {
- reads[execname()] += $return
+ reads[pid(),execname()] += $return
+ total_io[pid(),execname()] += $return
}
probe vfs.write.return {
- writes[execname()] += $return
+ writes[pid(),execname()] += $return
+ total_io[pid(),execname()] += $return
+}
+
+function humanreadable(bytes) {
+ if (bytes > 1024*1024*1024) {
+ return sprintf("%d GiB", bytes/1024/1024/1024)
+ } else if (bytes > 1024*1024) {
+ return sprintf("%d MiB", bytes/1024/1024)
+ } else if (bytes > 1024) {
+ return sprintf("%d KiB", bytes/1024)
+ } else {
+ return sprintf("%d B", bytes)
+ }
}
probe timer.s(1) {
- foreach (p in reads)
- total_io[p] += reads[p]
- foreach (p in writes)
- total_io[p] += writes[p]
- foreach(p in total_io- limit 10)
- printf("%15s r: %8d KiB w: %8d KiB\n",
- p, reads[p]/1024,
- writes[p]/1024)
+ foreach([p,e] in total_io- limit 10)
+ printf("%8d %15s r: %12s w: %12s\n",
+ p, e, humanreadable(reads[p,e]),
+ humanreadable(writes[p,e]))
printf("\n")
# Note we don't zero out reads, writes and total_io,
# so the values are cumulative since the script started.