This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] [PATCH] tapset to count number open file handlers and max file handlers for a process


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]