Messages in this thread | | | Date | Mon, 19 May 2008 20:33:11 +0200 | From | Andrea Righi <> | Subject | Re: [PATCH] distinct tgid/tid I/O statistics |
| |
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(); >> + }
| |