[dtrace-discuss] track program time - need some guidelines

James Litchfield
2009-07-11T07:58:21Z

Solaris 10 uses microstate accounting all the time. This information
is always tracked in the kernel for each LWP. Each running userland
thread is tied to an LWP.

There are 10 states defined in /usr/include/sys/msacct.h.

Something such as this should help you get started. I used open as a
convenient
point to spit stuff out. Don''t forget -C in the invocation.

#include <sys/thread.h>
#include <sys/klwp.h>
#include <sys/msacct.h>

syscall::open:entry
/pid > 0/
{
        this->lwp = curthread->t_lwp;
        printf("Current USER time: %d for thread %u in pid %u\n",
            this->lwp->lwp_mstate.ms_acct[LMS_USER],
            curthread->t_tid, pid);
}




tester wrote:
> Hi,
>
> Need some dtrace pointers to track time spent by some programs. N processes
with N threads each running on a multiprocessor system. What probes to use to
decompose total run time to on-proc, sleep, io etc?
> Since it''s a muliprocessor system, I am guessing that the toal
units of time will be in the terms of " clock ticks" and so will be
the break up.
> So for example on a 2X2Ghz system a program running for 10 sec has,
> theoretically 10*2*2*1024*1024 clock ticks potentially available. How to
track how much of this the program is using (with a breakup of on-cpu and io
wait etc)
> Or am I completely off on this with a different approach?
>
> Also what will the additional impact of tracking such usage with Dtrace.
>
> Thanks
>