mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: kosaki.motohiro@jp.fujitsu.com, Jiri Pirko <jpirko@redhat.com>,
	linux-kernel@vger.kernel.org, Hugh Dickins <hugh@veritas.com>
Subject: Re: [PATCH, RESEND3] getrusage: fill ru_maxrss value
Date: Tue, 30 Dec 2008 20:10:56 +0900 (JST)	[thread overview]
Message-ID: <20081230200150.1289.KOSAKI.MOTOHIRO@jp.fujitsu.com> (raw)
In-Reply-To: <20081225144300.GA14659@redhat.com>

Hi

sorry for late responce.

but I thought I should investigate BSD behavior at first.
and I've installed FreeBSD on my PC and tested it.

I'll post this test case and my proposal patch soon.


> On 12/25, KOSAKI Motohiro wrote:
> >
> > > On Wed, 24 Dec 2008 16:37:55 +0900 (JST)
> > > KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> > > 
> > > > > @@ -870,6 +870,7 @@ static int de_thread(struct task_struct *tsk)
> > > > >  	sig->notify_count = 0;
> > > > >  
> > > > >  no_thread_group:
> > > > > +	sig->maxrss = 0;
> > > > >  	exit_itimers(sig);
> > > > >  	flush_itimer_signals();
> > > > >  	if (leader)
> > > > 
> > > > I don't know getrusage correct behavior so detail.
> > > > Why don't update parent process's sig->cmaxrss ?
> > > Because exec affects only this task and we want to forgot maxrss value.
> > > That does not implicate that we want to forgot highest maxrss value of
> > > our childs because exec does not affect them. I think this is right
> > > behavior.
> > 
> > Hmm, "we want" is a bit ambiguously word.
> > We have three reviewing viewpoint.
> > 
> > 1) this code is consistent to other linux kernel code.
> > 
> > this patch fill its requrement perfectly.
> > 
> > 2) the behavior is enough surpriseless?
> > 
> > Honestly, I think this patch is a bit supriseful.
> > example,
> > 
> >   1. process-A fork process-B
> >   2. process-A wait by wait4()
> >   3. process-B consume 1GB memory
> >   4. process-B exec another program
> >   5. process-B consume 100KB memory
> >   6. process-B exit
> >   7. process-A get maxrss=100KB
> > 
> > oh, 1GB consumption is disappeared.
> 
> Yes, and I also think this is not right.
> 
> But this has nothing to do with parent->signal->cmaxrss, the question
> is why we lost the info.

BSD inherit maxrss at exec(), but Jiri's patch doesn't.


> And please note we have the same problem with xacct_add_tsk(), that
> is why I think this patch is right _for now_, but see below.

xacct is linux specific feature.
it doesn't need other os compatibility.



> > However, if we choice process don't forget maxrss at exec,
> > another supriseful happend.
> > example,
> > 
> >   1. process-A consume 1GB memroy
> >   2. process-A fork process-B
> >   3. process-A wait by wait4()
> >   4. right after, process-B exec another program
> >   5. process-B consume 100KB memory
> >   6. process-B exit
> >   7. process-A get maxrss=1GB
> > 
> > oh, this design cause large process can't get child maxrss.
> 
> Even simpler. If we never reset marxrss, we start inherit this
> value from /sbin/init which is obviously wrong.
> 
> That is why I suggested to change bprm_mm_init's path to keep
> mm->hiwater_xxx but only if !PF_FORKNOEXEC (and in that case
> we must kill "sig->maxrss = 0" from de_thread()).
> 
> What do you think?

your idea is nice. but it is incompatibility to bsd.
I beilieve incompatibility of compatibility feature is worthless.

BSD return 1GB at above case. then I like this behavior.




> > if who==RUSAGE_BOTH,
> 
> Ah. I forgot to mention what the code does to discuss...
> 
> > correct behavior: max(hiwater_rss, mm_rss) + signal->cmaxrss)
> 
> I disagree. This doesn't look correct to me. ->maxrss is a maximum,
> we shouldn't report the sum.

you are absolutely right.
I was crap thinking. thanks clarification.


> > this code:        max(signal->maxrss + signal->cmaxrss, max(hiwater_rss, mm_rss))
> 
> Afaics, no. this code reports
> 
> 	max(signal->cmaxrss, max(signal->maxrss, get_mm_hiwater_rss())
> 
> and this looks right to me.
> 
> But I agree, this is debateable.
> 
> Oleg.
> 




      reply	other threads:[~2008-12-30 11:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-18 12:59 Jiri Pirko
2008-12-24  7:37 ` KOSAKI Motohiro
2008-12-24 11:17   ` Jiri Pirko
2008-12-24 17:42     ` Oleg Nesterov
2008-12-25  0:11       ` Jiri Pirko
2008-12-25  4:46     ` KOSAKI Motohiro
2008-12-25 12:44       ` Jiri Pirko
2008-12-25 14:43       ` Oleg Nesterov
2008-12-30 11:10         ` KOSAKI Motohiro [this message]

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=20081230200150.1289.KOSAKI.MOTOHIRO@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=hugh@veritas.com \
    --cc=jpirko@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.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®