mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: wli@holomorphy.com
Cc: Eric Dumazet <dada1@cosmosbay.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: per-thread rusage
Date: Wed, 11 Apr 2007 00:10:36 +0400	[thread overview]
Message-ID: <20070410201036.GA205@tv-sign.ru> (raw)

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.


             reply	other threads:[~2007-04-10 20:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-10 20:10 Oleg Nesterov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-04-04 17:29 William Lee Irwin III
2007-04-04 17:48 ` Eric Dumazet
2007-04-04 18:10   ` William Lee Irwin III
2007-04-09 23:53     ` Andrew Morton
2007-04-10  0:42       ` William Lee Irwin III
2007-04-10  0:53         ` Andrew Morton
2007-04-10  1:12           ` William Lee Irwin III
2007-04-10  1:18             ` Andrew Morton
2007-05-01 17:29         ` Bill Irwin
2007-05-01 18:39           ` Ulrich Drepper
2007-05-01 20:24             ` Bill Irwin
2007-05-01 22:10               ` Ulrich Drepper
2007-05-01 22:27                 ` Theodore Tso
2007-05-01 22:34                   ` Bill Irwin
2007-05-01 23:04                     ` Alan Cox
2007-05-01 23:17                       ` Bill Irwin
2007-05-02  5:05                       ` Balbir Singh
2007-05-02  0:17                   ` Ulrich Drepper
2007-05-02  4:31                     ` Theodore Tso
2007-05-02  4:57                       ` Ulrich Drepper
2007-05-01 22:29                 ` Bill Irwin
2007-04-04 22:36 ` Valdis.Kletnieks
2007-04-05  4:09   ` William Lee Irwin III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070410201036.GA205@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=dada1@cosmosbay.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wli@holomorphy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®