亲测。
vm:
#top -p 14971
top - 21:42:17 up 9 days, 11:02, 5 users, load average: 0.08, 0.03, 0.02
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.9 us, 0.4 sy, 0.0 ni, 97.7 id, 0.9 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 4046344 total, 268972 free, 466868 used, 3310504 buff/cache
KiB Swap: 4194300 total, 4193488 free, 812 used. 3216164 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
14971 root 20 0 4220 648 580 R 8.3 0.0 0:01.74 a.out
cpu 占用率基本在 7%左右波动
host:
#top -p 104384
top - 21:44:37 up 36 days, 12:04, 1 user, load average: 3.64, 3.80, 3.80
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
%Cpu(s): 9.4 us, 1.7 sy, 0.0 ni, 88.8 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 65729244 total, 64605832 used, 1123412 free, 189524 buffers
KiB Swap: 66875388 total, 4046752 used, 62828636 free. 24522884 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
104384 libvirt+ 20 0 9332380 3.898g 5068 S 30.3 6.2 1530:39 qemu-system-x86
CPU 占用率基本稳定在 30 左右,观察 1 分钟
将 vm 里 a.out kill 掉。
host:
top - 21:47:45 up 36 days, 12:07, 1 user, load average: 3.99, 3.77, 3.77
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
%Cpu(s): 7.9 us, 1.7 sy, 0.0 ni, 89.9 id, 0.4 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 65729244 total, 64600260 used, 1128984 free, 189736 buffers
KiB Swap: 66875388 total, 4046704 used, 62828684 free. 24526240 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
104384 libvirt+ 20 0 9332380 3.898g 5068 S 11.0 6.2 1531:24 qemu-system-x86
CPU 占用率降为 10%左右。
附:
host cpu 为 Intel(R) Xeon(R) CPU E5-2650 v3 @ 2.30GHz,40 Core
vm 里分了 4 Core。