All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: William Lee Irwin III <wli@holomorphy.com>
Cc: Eric Dumazet <dada1@cosmosbay.com>, linux-kernel@vger.kernel.org
Subject: Re: per-thread rusage
Date: Mon, 9 Apr 2007 16:53:15 -0700	[thread overview]
Message-ID: <20070409165315.4704021f.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070404181050.GN2986@holomorphy.com>

On Wed, 4 Apr 2007 11:10:50 -0700
William Lee Irwin III <wli@holomorphy.com> wrote:

> On Wed, 4 Apr 2007 10:29:31 -0700 William Lee Irwin III <wli@holomorphy.com> wrote:
> >> It is not now possible for a thread to retrieve its own rusage in
> >> isolation. Its rusage is nowhere exposed without being intermixed with
> >> that of its sibling threads. This patch adds support for an
> >> RUSAGE_THREAD who argument that returns rusage for only the desired
> >> thread.
> 
> On Wed, Apr 04, 2007 at 07:48:29PM +0200, Eric Dumazet wrote:
> > Please check mm, because we now return ru_inblock and ru_oublock as well.
> > r->ru_inblock = task_io_get_inblock(p);
> > r->ru_oublock = task_io_get_oublock(p);
> 
> Respun vs. 2.6.21-rc5-mm4, still untested. Also...
> 
> Signed-off-by: William Irwin <bill.irwin@oracle.com>
> 
> 
> -- wli
> 
> 
> Index: mm-2.6.21-rc5-4/include/linux/resource.h
> ===================================================================
> --- mm-2.6.21-rc5-4.orig/include/linux/resource.h	2007-04-03 23:31:19.000000000 -0700
> +++ mm-2.6.21-rc5-4/include/linux/resource.h	2007-04-04 13:08:47.000000000 -0700
> @@ -18,7 +18,8 @@
>   */
>  #define	RUSAGE_SELF	0
>  #define	RUSAGE_CHILDREN	(-1)
> -#define RUSAGE_BOTH	(-2)		/* sys_wait4() uses this */
> +#define RUSAGE_THREAD	(-2)
> +#define RUSAGE_BOTH	(-3)		/* sys_wait4() uses this */
>  
>  struct	rusage {
>  	struct timeval ru_utime;	/* user time used */
> Index: mm-2.6.21-rc5-4/kernel/sys.c
> ===================================================================
> --- mm-2.6.21-rc5-4.orig/kernel/sys.c	2007-04-03 23:33:27.000000000 -0700
> +++ mm-2.6.21-rc5-4/kernel/sys.c	2007-04-04 13:11:17.000000000 -0700
> @@ -2074,6 +2074,16 @@
>  	}
>  
>  	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;
>  		case RUSAGE_BOTH:
>  		case RUSAGE_CHILDREN:
>  			utime = p->signal->cutime;
> @@ -2131,7 +2141,8 @@
>  
>  asmlinkage long sys_getrusage(int who, struct rusage __user *ru)
>  {
> -	if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
> +	if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN &&
> +						who != RUSAGE_THREAD)
>  		return -EINVAL;
>  	return getrusage(current, who, ru);
>  }

Seems sane.  Could we please get it tested and get a full description in
place?  Something which provides enough detail for the manpage maintainers.

Also, a quick comparison between Linux's RUSAGE_THREAD and $other-os's
implementations would reduce the possibility of silly, cast-in-stone
incompatabilities.




  reply	other threads:[~2007-04-09 23:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-04 17:29 per-thread rusage 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 [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2007-04-10 20:10 Oleg Nesterov

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=20070409165315.4704021f.akpm@linux-foundation.org \
    --to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.