From: "Makhlis, Lev" Add up resource usage counters for live and dead threads to show aggregate per-process usage in /proc//stat. This mirrors the new getrusage() semantics. /proc//task//stat still has the per-thread usage. Signed-off-by: Lev Makhlis Signed-off-by: Andrew Morton --- 25-akpm/fs/proc/array.c | 11 +++++++++++ 1 files changed, 11 insertions(+) diff -puN fs/proc/array.c~show-aggregate-per-process-counters-in-proc-pid-stat fs/proc/array.c --- 25/fs/proc/array.c~show-aggregate-per-process-counters-in-proc-pid-stat Fri Sep 3 16:30:21 2004 +++ 25-akpm/fs/proc/array.c Fri Sep 3 16:30:21 2004 @@ -312,6 +312,7 @@ static int do_task_stat(struct task_stru unsigned long long start_time; unsigned long cmin_flt = 0, cmaj_flt = 0, cutime = 0, cstime = 0; unsigned long min_flt = 0, maj_flt = 0, utime = 0, stime = 0; + struct task_struct *t; char tcomm[sizeof(task->comm)]; state = *get_task_state(task); @@ -352,6 +353,16 @@ static int do_task_stat(struct task_stru stime = task->signal->stime; } } + if (whole) { + t = task; + do { + min_flt += t->min_flt; + maj_flt += t->maj_flt; + utime += t->utime; + stime += t->stime; + t = next_thread(t); + } while (t != task); + } ppid = task->pid ? task->real_parent->pid : 0; read_unlock(&tasklist_lock); _