]> sourceware.org Git - systemtap.git/commitdiff
revised as per wcohen, added new section iotime
authorddomingo <ddomingo@redhat.com>
Thu, 4 Dec 2008 00:44:40 +0000 (10:44 +1000)
committerddomingo <ddomingo@redhat.com>
Thu, 4 Dec 2008 00:44:40 +0000 (10:44 +1000)
doc/SystemTap_Beginners_Guide/en-US/extras/inodewatch-simple.stp
doc/SystemTap_Beginners_Guide/en-US/extras/iotime-simple.stp [new file with mode: 0644]

index d1cbf6f69d06a1951b30d6dcc7b14b78204811dd..80d1ca8ea864de004cdcad8e5dacea91a3291c9c 100644 (file)
@@ -1,5 +1,4 @@
-probe kernel.function ("vfs_write"),\r
-      kernel.function ("vfs_read")\r
+probe vfs.write, vfs.read\r
 {\r
   dev_nr = $file->f_dentry->d_inode->i_sb->s_dev\r
   inode_nr = $file->f_dentry->d_inode->i_ino\r
diff --git a/doc/SystemTap_Beginners_Guide/en-US/extras/iotime-simple.stp b/doc/SystemTap_Beginners_Guide/en-US/extras/iotime-simple.stp
new file mode 100644 (file)
index 0000000..a14f773
--- /dev/null
@@ -0,0 +1,82 @@
+global start
+global entry_io
+global fd_io
+global time_io
+
+function timestamp:long() {
+  return gettimeofday_us() - start
+}
+
+function proc:string() {
+  return sprintf("%d (%s)", pid(), execname())
+}
+
+probe begin {
+ start = gettimeofday_us()
+}
+
+global filenames
+global filehandles
+global fileread
+global filewrite
+
+probe syscall.open {
+  filenames[pid()] = user_string($filename)
+} 
+
+probe syscall.open.return {
+  if ($return != -1) {
+    filehandles[pid(), $return] = filenames[pid()]
+    fileread[pid(), $return] = 0
+    filewrite[pid(), $return] = 0
+  } else {
+    printf("%d %s access %s fail\n", timestamp(), proc(), filenames[pid()])
+  }
+  delete filenames[pid()]
+}
+
+probe syscall.read {
+  if ($count > 0) {
+    fileread[pid(), $fd] += $count
+  }
+  t = gettimeofday_us(); p = pid()
+  entry_io[p] = t
+  fd_io[p] = $fd
+}
+
+probe syscall.read.return {
+  t = gettimeofday_us(); p = pid()
+  fd = fd_io[p]
+  time_io[p,fd] <<< t - entry_io[p]
+}
+
+probe syscall.write {
+  if ($count > 0) {
+    filewrite[pid(), $fd] += $count
+  }
+  t = gettimeofday_us(); p = pid()
+  entry_io[p] = t
+  fd_io[p] = $fd
+}
+
+probe syscall.write.return {
+  t = gettimeofday_us(); p = pid()
+  fd = fd_io[p]
+  time_io[p,fd] <<< t - entry_io[p]
+}
+
+probe syscall.close {
+  if (filehandles[pid(), $fd] != "") {
+    printf("%d %s access %s read: %d write: %d\n",  timestamp(), proc(),
+       filehandles[pid(), $fd], fileread[pid(), $fd], filewrite[pid(), $fd])
+    if (@count(time_io[pid(), $fd]))
+      printf("%d %s iotime %s time: %d\n",  timestamp(), proc(),
+       filehandles[pid(), $fd], @sum(time_io[pid(), $fd]))
+   }
+  delete fileread[pid(), $fd]
+  delete filewrite[pid(), $fd]
+  delete filehandles[pid(), $fd]
+  delete fd_io[pid()]
+  delete entry_io[pid()]
+  delete time_io[pid(),$fd]
+}
\ No newline at end of file
This page took 0.030628 seconds and 5 git commands to generate.