mpstat command

Hi,

I would like to clearly understand the output of the mpstat command. What is the mutex spins and also context switches? What if we saw that the number of mutex spins is high. Basically, what to look for in the output of the mpstat command? What is wrong and what is ok. what is the value under the smtx will reveal us. Please see below an example output

CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
  0  254   0  189   311  202  357   29   52 17402    0  1465    1  39   0  59
  1  184   0   66    55    9  379   43   67 22769    0  1360    1  51   0  48
  2  300   0  165    40    5  422   36   88 20983    0  1266    1  46   0  52
  3  384   0  374    80   38  407   42   78 20168    0  1775    2  41   0  57
CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
  0   60   0  239   321  203  195   76   40 41660    0  1068    1  99   0   0
  1   66   0  115    81    9  413   63   70 33658    0   776    1  84   0  15
  2    2   0   33    98    8  393   80   59 40319    0   671    1  91   0   9
  3  150   0  377   120   36  392   79   72 40218    0   854    2  85   0  13
CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
  0   70   0  187   312  203  393   26   62 13326    0  1560    1  33   0  66
  1  260   0  139    49   10  525   36  109 14185    0  1982    2  35   0  63
  2  303   0  277    46   13  462   33  103 16067    0  1672    1  42   1  56
  3  387   0  377   118   89  506   28  110 6790    0  1904    1  23   0  76

other then just to "understand" mpstat, is there any particular reason you need to clearly understand this command? Are you a developer? Has someone come to you regarding multitasking of the OS? I guess looking for a bit more background here.

mutex or mutually exclusive (smtx) = kernel contention (if a thread can't acquire a lock, it spins).
context switch (csw) = "A context switch is the computing process of storing and restoring the state (context) of a CPU so that execution can be resumed from the same point at a later time." - wikipedia.org

I found some interesting articles from Princeton u.
[http://www.princeton.edu/~unix/Solaris/troubleshoot/lockcontend.html]
[http://www.princeton.edu/~unix/Solaris/troubleshoot/cpuload.html]

You could honestly spend years understanding this stuff :smiley:

Hard to tell having only mpstat output and no clue about what your system is, what it is running and how does this issue appear.
Anyway, having the CPU spending most of its time in the kernel while your userland code is using only between 1 and 2 % of the CPUs is likely a symptom something is going very wrong.

pupp,

Thanks for your explanation. I actually stumbled upon this command while reading a solaris book . The book states that this command helps monitor cpu performance etc, but it didn't give any details about the command output. So, I was just trying to get the grasp around it.