首页 > Linux操作系统 > Linux操作系统 > mpstat输出列的含义
$ mpstat 1
CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl
0 4 0 28 679 154 573 3 12 8 0 767 1 2 0 96
1 4 0 22 504 145 485 2 9 4 0 661 1 2 0 97
2 4 0 30 579 81 425 3 12 6 0 519 1 2 0 97
3 5 0 25 505 250 517 3 12 5 0 758 1 3 0 96
CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl
0 0 0 9 567 182 372 0 2 0 0 338 0 1 0 99
1 0 0 21 454 174 468 1 1 2 0 468 1 1 0 98
2 0 0 12 480 15 304 1 4 1 0 249 2 1 0 97
3 27 0 15 157 68 147 1 2 0 0 422 0 1 0 99
jmoekamp@hivemind:~$
# dtrace -n 'vminfo:::as_fault{@execs[execname]=count()}'
dtrace: description 'vminfo:::as_fault
' matched 1 probe
^C
dtrace 104
jmoekamp@hivemind:~## dtrace -n 'vminfo:::maj_fault{@execs[execname] = count() }'
dtrace: description 'vminfo:::maj_fault' matched 1 probe
^C
# dtrace -n 'sysinfo:::xcalls{@execs[execname] = count();}'
dtrace: description 'sysinfo:::xcalls' matched 1 probe
^C
firefox-bin 6
thunderbird-bin 6
VBoxHeadless 9
dtrace 24
pageout 1660
sched 1834
jmoekamp@hivemind:~#
jmoekamp@hivemind:~# intrstat
device | cpu0 %tim cpu1 %tim cpu2 %tim cpu3 %tim
-------------+------------------------------------------------------------
[...]
e1000g#0 | 0 0,0 0 0,0 0 0,0 0 0,0
e1000g#1 | 0 0,0 0 0,0 0 0,0 0 0,0
ehci#0 | 0 0,0 0 0,0 0 0,0 0 0,0
ehci#1 | 0 0,0 0 0,0 0 0,0 0 0,0
hci1394#0 | 0 0,0 0 0,0 123 0,0 0 0,0
[...]
pci-ide#0 | 0 0,0 0 0,0 247 0,3 0 0,0
rge#0 | 0 0,0 0 0,0 0 0,0 11 0,0
# dtrace -n 'sysinfo:::pswitch{@execs[execname] = count(); }'
dtrace: description 'sysinfo:::pswitch' matched 3 probes
^C
fmd 1
[...]
VBoxHeadless 2054
sched 9657
jmoekamp@hivemind:~#
# dtrace -n 'sysinfo::preempt:inv_swtch{@execs[execname] = count();}'
dtrace: description 'sysinfo::preempt:inv_swtch
' matched 1 probe
^C
VBoxHeadless 1
VBoxSVC 1
gam_server 1
thunderbird-bin 2
firefox-bin 3
gnome-netstatus- 3
Obviously a large number of involuntary context switches should be avoided.
# dtrace -n ' sched:::off-cpu{self->cpu = cpu;}
sched:::on-cpu /self->cpu != cpu/
{
printf("%s migrated from cpu %d to cpu %d\n",execname,self->cpu,cpu);
self->cpu = 0;
}'
dtrace: description ' sched:::off-cpu
' matched 6 probes
^C
CPU ID FUNCTION:NAME
2 10067 resume:on-cpu firefox-bin migrated from cpu 0 to cpu 2
2 10067 resume:on-cpu thunderbird-bin migrated from cpu 0 to cpu 2
2 10067 resume:on-cpu nskernd migrated from cpu 0 to cpu 2
2 10067 resume:on-cpu nskernd migrated from cpu 0 to cpu 2
2 10067 resume:on-cpu VBoxHeadless migrated from cpu 0 to cpu 2
2 10067 resume:on-cpu sched migrated from cpu 0 to cpu 2
2 10067 resume:on-cpu gnome-netstatus- migrated from cpu 0 to cpu 2
2 10067 resume:on-cpu gnome-netstatus- migrated from cpu 0 to cpu 2
The number of spins is an interesting number because of the nature of spin locks. Imagine this lock like a lock at a lavatory door, where the "Busy/Vacant" part is out of order. You have two ways to get to the lavatory. Shaking every few seconds at the door to check if it's still closed or you can leave it, doing something else and wait for a few minutes and then check again. The spin lock is the equivalent to this very annoying person rattling at the door. Being annoying is no problem in the computer, but rechecking it again and again uses your clock cycles you could use better. However it has a big advantage: You get the lavatory immediately when it's free and you don't have to do a context switch from doing a telephone call and going to the lavatory. Of course the reality is a little bit more complex than the lavatory door, but it should get you the picture. It's the same with spin locks: There is a tight loop that tries to acquire the lock again and again, until it get's the lock and stays on a CPU until the time quantum for the thread is used up or a thread with a higher priority leads to the preemption of the thread. So counting the "spinning on mutexes" event is a good indication, how often your computer rattles at the lavatory door and burns CPU cycles while doing so. Furthermore it's a good indication if there are any highly contended locks in the codepath you are using, as it get's more probable that a lock has to spin, when many threads want to use the same codepath synchronized by this lock. However this is just a vastly simplified description, the handling of locks in Solaris is an own article,too or another evening with the book already mentioned.# dtrace -n 'lockstat:::adaptive-spin, lockstat:::adaptive-block
> {
> @execs[execname,probename] = count();
> }'
dtrace: description 'lockstat:::adaptive-spin, lockstat:::adaptive-block
' matched 2 probes
^C
gnome-netstatus- adaptive-spin 2
sched adaptive-block 5
zpool-datapool adaptive-block 5
VBoxHeadless adaptive-spin 21
zpool-datapool adaptive-spin 78
sched adaptive-spin 262
#
# dtrace -n 'lockstat:::rw-block
{
@execs[execname] = count();
}'
dtrace: description 'lockstat:::rw-block
' matched 1 probe
^C
VBoxHeadless 8
#
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/228190/viewspace-662358/ ,如需转载,请注明出处,否则将追究法律责任。