the info in /proc is a time decayed average per process, so adding it
up is useless. It also fails to count any short lived processes that
come and go in the measurement interval. Actually thats the problem,
the ps/top data from /proc is not measured over an interval, thats why
you get a time decayed average of recent use. The data from vmstat and
its friends is based on a difference over a time interval, which is
why you have to ignore the first line of output, since thats the
difference from zero, which gets you the average since boot.

If you want more accurate measures of CPU time, use prstat -m rather
than top, since it uses microstate accounting and does differencing
over time properly. However, even the prstat data won't cleanly add up
to the same number as vmstat. There is other stuff going on like
invisible kernel threads, an inability to measure all processes at
exactly the same time, and the whole issue of how to account for
interrupt time (which depends on what Solaris release you are using).
Some of my attempts to add up process time as accurately as possible
have come up with more than 100% CPU usage, so the other option is to
give up on the issue and worry about something else.

If you want to play around with the data more accurately than prstat,
get the SE toolkit and look at the cpuchk.se script, it compares the
microstate and sampled CPU times for each process. There are also some
more useful data collectors like pw.se and pea.se (latest SE is on
sourceforge or sunfreeware.com)

Adrian


On Nov 30, 2007 12:02 PM, Cherian Abraham <[EMAIL PROTECTED]> wrote:
> CedBer,
>
> I have seen similar issues on Solaris versions 8 & 9, with no conclusive
> answer. If you take top and add up all the process CPU usage and use the
> very summary shown by top for usr and kernel usage, the total of all the
> processes does not add up to the usr %. I have heard that the latest version
> of top adds the kernel usage by each process on to the process cpu usage,
> however the values still do not add up.
> From looking at the source code of top, it looks like the summary shown uses
> an "exponential weighted average" calculation to derive the total usr &
> kernel cpu usages. That could be the reason for the mismatch.
> The problem still persists with trying to map the vmstat/sar/iostat usr &
> ker cpu usage with the sum obtained from top/prstat.
> fyi...i have seen this on N240 & N440 servers.
> Does any one have a clue why there the solaris accounting does not add up ?
>
> Thanks,
> Cherian
>
>
>
> On Nov 30, 2007 12:47 PM, Eric Saxe <[EMAIL PROTECTED]> wrote:
> >
> > CedBer wrote:
> > > If I divide by 8 rather than 4, I have B=1/2*C ! (where B is the sum of
> processes %CPU of top an C the usr+sys vmstat value)
> > >
> > Are you observing that same discrepancy between prstat and vmstat?
> > vmstat derives it's statistics from the cpu kstats...whereas prstat
> > looks at the lwp ps(1) information file in /proc. I'm not sure what top
> > uses...but I would imagine it looks at /proc as well.
> >
> > Thanks,
> > -Eric
> >
> >
> >
> > _______________________________________________
> > perf-discuss mailing list
> > perf-discuss@opensolaris.org
> >
>
>
> _______________________________________________
> perf-discuss mailing list
> perf-discuss@opensolaris.org
>
_______________________________________________
perf-discuss mailing list
perf-discuss@opensolaris.org

Reply via email to