diff options
author | ddomingo <ddomingo@redhat.com> | 2008-12-04 10:44:40 +1000 |
---|---|---|
committer | ddomingo <ddomingo@redhat.com> | 2008-12-04 10:44:40 +1000 |
commit | c1f7a8464fa9054e6ee06e05451f555b5504dd71 (patch) | |
tree | e6a4e6c709b0174b4b5077cac01ce75329ee0511 /doc/SystemTap_Beginners_Guide | |
parent | ba7f87bf8ef0723ca462a8f7eaf0d36093822bdc (diff) | |
download | systemtap-steved-c1f7a8464fa9054e6ee06e05451f555b5504dd71.tar.gz systemtap-steved-c1f7a8464fa9054e6ee06e05451f555b5504dd71.tar.xz systemtap-steved-c1f7a8464fa9054e6ee06e05451f555b5504dd71.zip |
revised as per wcohen, added new section iotime
Diffstat (limited to 'doc/SystemTap_Beginners_Guide')
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/extras/inodewatch-simple.stp | 3 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/extras/iotime-simple.stp | 82 |
2 files changed, 83 insertions, 2 deletions
diff --git a/doc/SystemTap_Beginners_Guide/en-US/extras/inodewatch-simple.stp b/doc/SystemTap_Beginners_Guide/en-US/extras/inodewatch-simple.stp index d1cbf6f6..80d1ca8e 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/extras/inodewatch-simple.stp +++ b/doc/SystemTap_Beginners_Guide/en-US/extras/inodewatch-simple.stp @@ -1,5 +1,4 @@ -probe kernel.function ("vfs_write"),
- kernel.function ("vfs_read")
+probe vfs.write, vfs.read
{
dev_nr = $file->f_dentry->d_inode->i_sb->s_dev
inode_nr = $file->f_dentry->d_inode->i_ino
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 index 00000000..a14f7731 --- /dev/null +++ b/doc/SystemTap_Beginners_Guide/en-US/extras/iotime-simple.stp @@ -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 |