Re: [PATCH] distinct tgid/tid I/O statistics

From: Andrea Righi
Date: Mon May 19 2008 - 14:33:37 EST


Balbir Singh wrote:
+
+ if (!whole) {
+#ifdef CONFIG_TASK_XACCT

Can't we abstract this into a function for ease?

Maybe:

#ifdef CONFIG_TASK_XACCT
#define _task_xacct 1
#else
#define _task_xacct 0
#endif

and:

rchar = __task_xacct ? task->rchar : 0;
wchar = __task_xacct ? task->wchar : 0;
syscr = __task_xacct ? task->syscr : 0;
syscw = __task_xacct ? task->syscw : 0;

But it's very ugly anyway. It seems a similar problem has been raised
here:

http://lkml.org/lkml/2008/5/17/154

Apparently with no solution.


+ rchar = task->rchar;
+ wchar = task->wchar;
+ syscr = task->syscr;
+ syscw = task->syscw;
+#endif
+ memcpy(&ioac, &task->ioac, sizeof(ioac));
+ } else {
+ rchar = wchar = syscr = syscw = 0;
+ memset(&ioac, 0, sizeof(ioac));
+ rcu_read_lock();
+ if (lock_task_sighand(task, &flags)) {

If lock(), what happens otherwise?


mmmh... we must surely move the threads stats accounting code out of
the if statement. OK, I'll post a new patch soon.

Thanks,
-Andrea

+ struct signal_struct *sig = task->signal;
+ struct task_struct *t = task;
+
+ do {
+#ifdef CONFIG_TASK_XACCT
+ rchar += t->rchar;
+ wchar += t->wchar;
+ syscr += t->syscr;
+ syscw += t->syscw;
+#endif
+ ioac.read_bytes += t->ioac.read_bytes;
+ ioac.write_bytes += t->ioac.write_bytes;
+ ioac.cancelled_write_bytes +=
+ t->ioac.cancelled_write_bytes;
+ t = next_thread(t);
+ } while (t != task);
+
+#ifdef CONFIG_TASK_XACCT
+ rchar += sig->rchar;
+ wchar += sig->wchar;
+ syscr += sig->syscr;
+ syscw += sig->syscw;
+#endif
+ ioac.read_bytes += sig->ioac.read_bytes;
+ ioac.write_bytes += sig->ioac.write_bytes;
+ ioac.cancelled_write_bytes +=
+ sig->ioac.cancelled_write_bytes;
+
+ unlock_task_sighand(task, &flags);
+ }
+ rcu_read_unlock();
+ }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/