Subject: Re: CVS commit: [ktrace-lwp] src/sys
To: Jason Thorpe <thorpej@wasabisystems.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: source-changes
Date: 07/02/2003 18:12:23
On Wed, 2 Jul 2003, Jason Thorpe wrote:

>
> On Wednesday, July 2, 2003, at 02:48  PM, Bill Studenmund wrote:
>
> > only question I have is over the:
> > l->l_proc->p_stats->p_ru.ru_msgsnd++;
> > command at line 245 of dev/kttcp.c. Should we be doing per-lwp or
> > per-proc accounting?
>
> rusage is per-proc.

I understand it is now. The comment though was more of a thought-provoker
of, "Should it be." :-)

The main thing is I've been reading Solaris Internals again. ;-)

It has both per-LWP and per-proc accounting (as I understand it). While an
LWP is alive, its usage accumulates in it. When an LWP exits, its usage is
transfered to the proc. So at any given time, the overal rusage is the
proc's rusage + the sum of the rusage on all the lwps.

At process exit, all the LWPs get removed, so the process has all the info
for its lifetime resource usage.

From looking at the code so far, I can see one big advantage to the
proc/lwp split; we reduce potential lock contention for grabbing the lock
protectint the rusage info.

Oh, we also will need to add said lock at some point. :-)

Take care,

Bill