[RFC] [PATCH] tapset to count number open file handlers and max file handlers for a process
Stone, Joshua I
joshua.i.stone@intel.com
Sat Sep 1 00:27:00 GMT 2007
Srinivasa Ds wrote:
[...]
> +// Return the number of open file handlers for the given task
> +function task_open_file_handler:long (task:long) %{
> + struct task_struct *t = (struct task_struct *)(long)THIS->task;
> + struct fdtable *fdt = kread(&(t->files->fdt));
This still need to be broken down -- one kread for t->files, and another
for files->fdt.
> + unsigned int count=0, fd;
> + rcu_read_lock();
> + for (fd = 0; fd < kread(&(fdt->max_fds)); fd++) {
No need to kread every time through the loop. You can read it once
right before entering the loop.
[...]
> +// Return the maximum number of file handlers for the given task
> +function task_max_file_handler:long (task:long) %{
> + struct task_struct *t = (struct task_struct *)(long)THIS->task;
> + struct files_struct *f = kread (&(t->files));
> + rcu_read_lock();
> + THIS->__retvalue = kread(&(f->fdt->max_fds));
Please split this into two kreads, f->fdt and fdt->max_fds.
Otherwise, it looks good.
Josh
More information about the Systemtap
mailing list