diff options
author | dsmith <dsmith> | 2007-09-13 20:06:39 +0000 |
---|---|---|
committer | dsmith <dsmith> | 2007-09-13 20:06:39 +0000 |
commit | 70cafb08301af7028904201075ef2c7335254b8d (patch) | |
tree | 6c8e50eada84e047e18f1de364eb2f43e4abeeb4 /tapset/task.stp | |
parent | 007f0f1c0c671613ac8ea2e20480c8c04ee580d5 (diff) | |
download | systemtap-steved-70cafb08301af7028904201075ef2c7335254b8d.tar.gz systemtap-steved-70cafb08301af7028904201075ef2c7335254b8d.tar.xz systemtap-steved-70cafb08301af7028904201075ef2c7335254b8d.zip |
2007-09-13 David Smith <dsmith@redhat.com>
* task.stp (task_open_file_handles): Fixed for kernels less than
version 2.6.15.
(task_max_file_handles): Ditto.
Diffstat (limited to 'tapset/task.stp')
-rw-r--r-- | tapset/task.stp | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/tapset/task.stp b/tapset/task.stp index 947351c6..a15888f8 100644 --- a/tapset/task.stp +++ b/tapset/task.stp @@ -132,30 +132,60 @@ function task_cpu:long (task:long) // Return the number of open file handlers for the given task -function task_open_file_handles:long (task:long) %{ /* pure */ +function task_open_file_handles:long (task:long) +%( kernel_v >= "2.6.15" %? +%{ /* pure */ + struct task_struct *t = (struct task_struct *)(long)THIS->task; + struct files_struct *fs = kread(&(t->files)); + struct fdtable *f = kread(&(fs->fdt)); + unsigned int count=0, fd, max; + rcu_read_lock(); + max = kread(&(f->max_fds)); + for (fd = 0; fd < max; fd++) { + if ( kread(&(f->fd[fd])) != NULL) + count ++; + } + rcu_read_unlock(); + THIS->__retvalue = count; + CATCH_DEREF_FAULT(); +%} +%: +%{ /* pure */ struct task_struct *t = (struct task_struct *)(long)THIS->task; struct files_struct *f = kread(&(t->files)); - struct fdtable *fdt = kread(&(f->fdt)); unsigned int count=0, fd, max; rcu_read_lock(); - max = kread(&(fdt->max_fds)); + max = kread(&(f->max_fds)); for (fd = 0; fd < max; fd++) { - if ( kread(&(fdt->fd[fd])) != NULL) + if ( kread(&(f->fd[fd])) != NULL) count ++; } rcu_read_unlock(); THIS->__retvalue = count; CATCH_DEREF_FAULT(); %} +%) // Return the maximum number of file handlers for the given task -function task_max_file_handles:long (task:long) %{ /* pure */ +function task_max_file_handles:long (task:long) +%( kernel_v >= "2.6.15" %? +%{ /* pure */ + struct task_struct *t = (struct task_struct *)(long)THIS->task; + struct files_struct *fs = kread (&(t->files)); + struct fdtable *f = kread(&(fs->fdt)); + rcu_read_lock(); + THIS->__retvalue = kread(&(f->max_fds)); + rcu_read_unlock(); + CATCH_DEREF_FAULT(); +%} +%: +%{ /* pure */ struct task_struct *t = (struct task_struct *)(long)THIS->task; - struct files_struct *f = kread (&(t->files)); - struct fdtable *fdt = kread(&(f->fdt)); + struct files_struct *f = kread(&(t->files)); rcu_read_lock(); - THIS->__retvalue = kread(&(fdt->max_fds)); + THIS->__retvalue = kread(&(f->max_fds)); rcu_read_unlock(); CATCH_DEREF_FAULT(); %} +%) |