mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: + getrusage-fill-ru_inblock-and-ru_oublock-fields-if-possible.patch added to -mm tree
@ 2007-03-16 17:10 Oleg Nesterov
  2007-03-16 17:23 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2007-03-16 17:10 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Andrew Morton, linux-kernel

Eric Dumazet wrote:
>
> @@ -2021,6 +2022,8 @@ static void k_getrusage(struct task_stru
>  			r->ru_nivcsw = p->signal->cnivcsw;
>  			r->ru_minflt = p->signal->cmin_flt;
>  			r->ru_majflt = p->signal->cmaj_flt;
> +			r->ru_inblock = task_io_get_inblock(p);
> +			r->ru_oublock = task_io_get_oublock(p);
>
>  			if (who == RUSAGE_CHILDREN)
>  				break;
> @@ -2032,6 +2035,8 @@ static void k_getrusage(struct task_stru
>  			r->ru_nivcsw += p->signal->nivcsw;
>  			r->ru_minflt += p->signal->min_flt;
>  			r->ru_majflt += p->signal->maj_flt;
> +			r->ru_inblock += task_io_get_inblock(p);
> +			r->ru_oublock += task_io_get_oublock(p);
>  			t = p;
>  			do {
>  				utime = cputime_add(utime, t->utime);
> @@ -2040,6 +2045,8 @@ static void k_getrusage(struct task_stru
>  				r->ru_nivcsw += t->nivcsw;
>  				r->ru_minflt += t->min_flt;
>  				r->ru_majflt += t->maj_flt;
> +				r->ru_inblock += task_io_get_inblock(t);
> +				r->ru_oublock += task_io_get_oublock(t);

I can't understand this. Consider k_getrusage(RUSAGE_BOTH). The end result
is that r->ru_inblock == 3 * task_io_get_inblock(p).

No?

Oleg.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + getrusage-fill-ru_inblock-and-ru_oublock-fields-if-possible.patch added to -mm tree
  2007-03-16 17:10 + getrusage-fill-ru_inblock-and-ru_oublock-fields-if-possible.patch added to -mm tree Oleg Nesterov
@ 2007-03-16 17:23 ` Eric Dumazet
  2007-03-16 17:34   ` Eric Dumazet
  2007-03-16 17:40   ` Oleg Nesterov
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2007-03-16 17:23 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, linux-kernel

On Friday 16 March 2007 18:10, Oleg Nesterov wrote:
> Eric Dumazet wrote:
> > @@ -2021,6 +2022,8 @@ static void k_getrusage(struct task_stru
> >  			r->ru_nivcsw = p->signal->cnivcsw;
> >  			r->ru_minflt = p->signal->cmin_flt;
> >  			r->ru_majflt = p->signal->cmaj_flt;
> > +			r->ru_inblock = task_io_get_inblock(p);
> > +			r->ru_oublock = task_io_get_oublock(p);
> >
> >  			if (who == RUSAGE_CHILDREN)
> >  				break;
> > @@ -2032,6 +2035,8 @@ static void k_getrusage(struct task_stru
> >  			r->ru_nivcsw += p->signal->nivcsw;
> >  			r->ru_minflt += p->signal->min_flt;
> >  			r->ru_majflt += p->signal->maj_flt;
> > +			r->ru_inblock += task_io_get_inblock(p);
> > +			r->ru_oublock += task_io_get_oublock(p);
> >  			t = p;
> >  			do {
> >  				utime = cputime_add(utime, t->utime);
> > @@ -2040,6 +2045,8 @@ static void k_getrusage(struct task_stru
> >  				r->ru_nivcsw += t->nivcsw;
> >  				r->ru_minflt += t->min_flt;
> >  				r->ru_majflt += t->maj_flt;
> > +				r->ru_inblock += task_io_get_inblock(t);
> > +				r->ru_oublock += task_io_get_oublock(t);
>
> I can't understand this. Consider k_getrusage(RUSAGE_BOTH). The end result
> is that r->ru_inblock == 3 * task_io_get_inblock(p).
>
> No?

Yes :)

Very good point, you found a bug in k_getrusage().

I just followed the existing logic, but it seems this logic is bad.

So not only ru_inblock/ru_oublock are multiplied by 3 : others fields as well 
are wrong.

Also the definition of RUSAGE_CHILDREN is not conformant to standard

http://www.opengroup.org/onlinepubs/009695399/functions/getrusage.html

	"If the value of the who argument is RUSAGE_CHILDREN, information shall be 
	"returned about resources used by the terminated and waited-for children of 
	"the current process

We currently do a sum of rusage stats of still alive children.. thats totally 
wrong...

Eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + getrusage-fill-ru_inblock-and-ru_oublock-fields-if-possible.patch added to -mm tree
  2007-03-16 17:23 ` Eric Dumazet
@ 2007-03-16 17:34   ` Eric Dumazet
  2007-03-16 17:40   ` Oleg Nesterov
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2007-03-16 17:34 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, linux-kernel

On Friday 16 March 2007 18:23, Eric Dumazet wrote:

>
> Very good point, you found a bug in k_getrusage().
>
> I just followed the existing logic, but it seems this logic is bad.
>
> So not only ru_inblock/ru_oublock are multiplied by 3 : others fields as
> well are wrong.
>
> Also the definition of RUSAGE_CHILDREN is not conformant to standard
>
> http://www.opengroup.org/onlinepubs/009695399/functions/getrusage.html
>
> 	"If the value of the who argument is RUSAGE_CHILDREN, information shall be
> 	"returned about resources used by the terminated and waited-for children
> of "the current process
>
> We currently do a sum of rusage stats of still alive children.. thats
> totally wrong...

Please ignore this mail, I was very wrong.

I shall rethink a proper patch.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + getrusage-fill-ru_inblock-and-ru_oublock-fields-if-possible.patch added to -mm tree
  2007-03-16 17:23 ` Eric Dumazet
  2007-03-16 17:34   ` Eric Dumazet
@ 2007-03-16 17:40   ` Oleg Nesterov
  1 sibling, 0 replies; 4+ messages in thread
From: Oleg Nesterov @ 2007-03-16 17:40 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Andrew Morton, linux-kernel

On 03/16, Eric Dumazet wrote:
>
> On Friday 16 March 2007 18:10, Oleg Nesterov wrote:
> > Eric Dumazet wrote:
> > > @@ -2021,6 +2022,8 @@ static void k_getrusage(struct task_stru
> > >  			r->ru_nivcsw = p->signal->cnivcsw;
> > >  			r->ru_minflt = p->signal->cmin_flt;
> > >  			r->ru_majflt = p->signal->cmaj_flt;
> > > +			r->ru_inblock = task_io_get_inblock(p);
> > > +			r->ru_oublock = task_io_get_oublock(p);
> > >
> > >  			if (who == RUSAGE_CHILDREN)
> > >  				break;
> > > @@ -2032,6 +2035,8 @@ static void k_getrusage(struct task_stru
> > >  			r->ru_nivcsw += p->signal->nivcsw;
> > >  			r->ru_minflt += p->signal->min_flt;
> > >  			r->ru_majflt += p->signal->maj_flt;
> > > +			r->ru_inblock += task_io_get_inblock(p);
> > > +			r->ru_oublock += task_io_get_oublock(p);
> > >  			t = p;
> > >  			do {
> > >  				utime = cputime_add(utime, t->utime);
> > > @@ -2040,6 +2045,8 @@ static void k_getrusage(struct task_stru
> > >  				r->ru_nivcsw += t->nivcsw;
> > >  				r->ru_minflt += t->min_flt;
> > >  				r->ru_majflt += t->maj_flt;
> > > +				r->ru_inblock += task_io_get_inblock(t);
> > > +				r->ru_oublock += task_io_get_oublock(t);
> >
> > I can't understand this. Consider k_getrusage(RUSAGE_BOTH). The end result
> > is that r->ru_inblock == 3 * task_io_get_inblock(p).
> >
> > No?
> 
> Yes :)
> 
> Very good point, you found a bug in k_getrusage().

No, no, please check the code.

> So not only ru_inblock/ru_oublock are multiplied by 3 : others fields as well 
> are wrong.
> 
> Also the definition of RUSAGE_CHILDREN is not conformant to standard
> 
> http://www.opengroup.org/onlinepubs/009695399/functions/getrusage.html
> 
> 	"If the value of the who argument is RUSAGE_CHILDREN, information shall be 
> 	"returned about resources used by the terminated and waited-for children of 
> 	"the current process

This exactly happens. We are reading ->signal->*, see wait_task_zombie().

> We currently do a sum of rusage stats of still alive children.. thats totally 
> wrong...

I hope not :)

Oleg.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-03-16 17:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-16 17:10 + getrusage-fill-ru_inblock-and-ru_oublock-fields-if-possible.patch added to -mm tree Oleg Nesterov
2007-03-16 17:23 ` Eric Dumazet
2007-03-16 17:34   ` Eric Dumazet
2007-03-16 17:40   ` Oleg Nesterov

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®