public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Jiri Pirko <jpirko@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Michael Kerrisk <mtk.manpages@googlemail.com>,
	linux-api@vger.kernel.org, Hugh Dickins <hugh@veritas.com>,
	jlim@sgi.com, kosaki.motohiro@jp.fujitsu.com
Subject: Re: [PATCH, RESEND] getrusage: fill ru_maxrss value
Date: Tue, 16 Dec 2008 16:20:54 +0100	[thread overview]
Message-ID: <20081216152054.GA17012@redhat.com> (raw)
In-Reply-To: <20081216155641.1411f8a7@psychotron.englab.brq.redhat.com>

On 12/16, Jiri Pirko wrote:
>
> This patch makes ->ru_maxrss value in struct rusage filled accordingly to
> rss hiwater mark. This struct is filled as a parameter to
> getrusage syscall. ->ru_maxrss value is set to pages which might be correct
> as "time" application converts it to KBs.
>
> To make this happen we extend struct signal_struct by two fields. The
> first one is ->maxrss which we use to store rss hiwater of the task. The
> second one is ->cmaxrss which we use to store highest rss hiwater of all
> task childs. These values are used in k_getrusage() to actually fill
> ->ru_maxrss. k_getrusage() uses current rss hiwater value directly
> if mm struct exists.
>
> We clear the ->maxrss as a part of flush_old_exec() to be consistent
> because bprm_mm_init() does not copy ->hiwater_rss.

Imho the patch is fine, but

> @@ -1598,6 +1601,15 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
>  out:
>  	cputime_to_timeval(utime, &r->ru_utime);
>  	cputime_to_timeval(stime, &r->ru_stime);
> +
> +	task_lock(p);
> +	if (p->mm) {
> +		unsigned long maxrss = get_mm_hiwater_rss(p->mm);
> +
> +		if (r->ru_maxrss < maxrss)
> +			r->ru_maxrss = maxrss;
> +	}
> +	task_unlock(p);

I think the code above should check "if (who != RUSAGE_CHILDREN) ?

Oleg.


  reply	other threads:[~2008-12-16 15:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-16 14:56 [PATCH, RESEND] getrusage: fill ru_maxrss value Jiri Pirko
2008-12-16 15:20 ` Oleg Nesterov [this message]
2008-12-16 15:54   ` Jiri Pirko

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=20081216152054.GA17012@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hugh@veritas.com \
    --cc=jlim@sgi.com \
    --cc=jpirko@redhat.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@googlemail.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