lkml.org 
[lkml]   [2007]   [Apr]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: per-thread rusage
William Lee Irwin III <wli@holomorphy.com> wrote:
>
> switch (who) {
> + case RUSAGE_THREAD:
> + utime = p->utime;
> + stime = p->stime;
> + r->ru_nvcsw = p->nvcsw;
> + r->ru_nivcsw = p->nivcsw;
> + r->ru_minflt = p->min_flt;
> + r->ru_majflt = p->maj_flt;
> + r->ru_inblock = task_io_get_inblock(p);
> + r->ru_oublock = task_io_get_oublock(p);
> + break;

Minor nit. Perhaps it makes sense to introduce

static void rusage_self(struct rusage *r, struct task_struct *p);

for that. Could be re-used by "do {} while ()" below. Of course, we need
s/=/+=/.

Or, if we think the kernel code is too much clean,

--- kernel/sys.c~ 2007-04-05 12:20:35.000000000 +0400
+++ kernel/sys.c 2007-04-11 00:08:53.000000000 +0400
@@ -2097,6 +2097,7 @@ static void k_getrusage(struct task_stru
r->ru_majflt += p->signal->maj_flt;
r->ru_inblock += p->signal->inblock;
r->ru_oublock += p->signal->oublock;
+ case RUSAGE_THREAD:
t = p;
do {
utime = cputime_add(utime, t->utime);
@@ -2107,7 +2108,9 @@ static void k_getrusage(struct task_stru
r->ru_majflt += t->maj_flt;
r->ru_inblock += task_io_get_inblock(t);
r->ru_oublock += task_io_get_oublock(t);
- t = next_thread(t);
+
+ if (who != RUSAGE_THREAD)
+ t = next_thread(t);
} while (t != p);
break;


Oleg.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-04-10 22:13    [W:0.014 / U:0.872 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site