Re: [RFC][PATCH 09/10] taskstats: Fix exit CPU time accounting

From: Michael Holzheu
Date: Thu Sep 30 2010 - 09:47:50 EST


Hello Roland,

On Wed, 2010-09-29 at 12:19 -0700, Roland McGrath wrote:
> > > I would consider it to be a BUG() that the time is not accounted.
> > > Independent of the fact that a parent wants to see the SIGCHLD and
> > > the exit status of its child the process time of the child should be
> > > accounted, no?
> >
> > I do not know. It doesn't look like a BUG(), I mean it looks as if
> > the code was intentionally written this way.
>
> POSIX specifies this behavior: "If the child is never waited for (for
> example, if the parent has SA_NOCLDWAIT set or sets SIGCHLD to SIG_IGN),
> the resource information for the child process is discarded and not
> included in the resource information provided by getrusage()."

Thanks! That information was missing! Although still for me it not seems
to be a good decision to do it that way. Because of that it currently is
not possible to evaluate all consumed CPU time by looking at the current
processes. Time can simply disappear.

What about adding a new set of CPU time fields (e.g. cr-times) for the
cumulative "autoreap" children times to the signal struct and export
them via taskstats?

Then the following set of CPU times will give a complete picture (I also
added steal time (st) that is currently not accounted in Linux per
task):

* task->(u/s/st-time):
Time that has been consumed by task itself

* task->signal->(c-u/s/st-time):
Time that has been consumed by dead children of process where parent
has done a sys_wait()

* task->signal->(u/s/st-time):
Time that has been consumed by dead threads of thread group of process
- NEW: Has to be exported via taskstats

* task->signal->(cr-u/s/st-time):
Time that has been consumed by dead children that reaped
themselves, because parent ignored SIGCHLD or has set SA_NOCLDWAIT
- NEW: Fields have to be added to signal struct
- NEW: Has to be exported via taskstats

Michael

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/