0

I'm now try to understand qemu-kvm memory overhead. from the host OS,we can found -m 8192 which mean I have allocated 8GB memory to guest.

qemu     2813877  0.5  0.2 30472752 1103620 ?    Sl   Jan05 1178:13 /usr/libexec/qemu-kvm -name instance-000003db -S -machine pc-i440fx-rhel7.1.0,accel=kvm,usb=off -cpu Haswell,+abm,+pdpe1gb,+rdrand,+f16c,+osxsave,+dca,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme,-rtm,-hle -m 8192 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid 886db7b2-79b6-4a8a-8b34-4e7001377da9 -smbios type=1,manufacturer=Fedora Project,product=OpenStack Nova,version=12.0.5-2.el7.centos.ustack,serial=168f720b-7801-453d-8d2e-99aed5ade6cd,uuid=886db7b2-79b6-4a8a-8b34-4e7001377da9,family=Virtual Machine -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-instance-000003db/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=rbd:openstack-00/886db7b2-79b6-4a8a-8b34-4e7001377da9_disk.config:id=admin:key=AQD7kyJQQGoOBhAAqrPAqSopSwPrrfMMomzVdw==:auth_supported=cephx\;none:mon_host=55.3.52.1\:6789\;55.3.52.11\:6789\;55.3.52.21\:6789,if=none,id=drive-ide0-1-1,readonly=on,format=raw,cache=writeback -device ide-cd,bus=ide.1,unit=1,drive=drive-ide0-1-1,id=ide0-1-1 -drive file=rbd:openstack-00/volume-beeea3a3-44c8-4c36-835c-08bfdc9f61db:id=admin:key=AQD7kyJQQGoOBhAAqrPAqSopSwPrrfMMomzVdw==:auth_supported=cephx\;none:mon_host=55.3.52.1\:6789\;55.3.52.11\:6789\;55.3.52.21\:6789,if=none,id=drive-virtio-disk0,format=raw,serial=beeea3a3-44c8-4c36-835c-08bfdc9f61db,cache=writeback -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive file=rbd:openstack-00/volume-3be22eb0-6847-4366-a1ac-fcc8ddd87761:id=admin:key=AQD7kyJQQGoOBhAAqrPAqSopSwPrrfMMomzVdw==:auth_supported=cephx\;none:mon_host=55.3.52.1\:6789\;55.3.52.11\:6789\;55.3.52.21\:6789,if=none,id=drive-virtio-disk1,format=raw,serial=3be22eb0-6847-4366-a1ac-fcc8ddd87761,cache=writeback -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk1,id=virtio-disk1 -drive file=rbd:openstack-00/volume-4630e604-d404-4492-b861-44785274595f:id=admin:key=AQD7kyJQQGoOBhAAqrPAqSopSwPrrfMMomzVdw==:auth_supported=cephx\;none:mon_host=55.3.52.1\:6789\;55.3.52.11\:6789\;55.3.52.21\:6789,if=none,id=drive-virtio-disk2,format=raw,serial=4630e604-d404-4492-b861-44785274595f,cache=writeback -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk2,id=virtio-disk2 -netdev tap,fd=31,id=hostnet0,vhost=on,vhostfd=32 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=fa:16:3e:43:9b:d4,bus=pci.0,addr=0x3 -chardev file,id=charserial0,path=/var/lib/nova/instances/886db7b2-79b6-4a8a-8b34-4e7001377da9/console.log -device isa-serial,chardev=charserial0,id=serial0 -chardev pty,id=charserial1 -device isa-serial,chardev=charserial1,id=serial1 -device usb-tablet,id=input0 -vnc 0.0.0.0:2 -k en-us -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7 -msg timestamp=on

Also, I found this part of memory under /proc/pid/smaps; from this we can know it was equal to 8192MB.

7f6714000000-7f6914000000 rw-p 00000000 00:00 0
Size:            8388608 kB ===>8192MB
Rss:              953304 kB
Pss:              953304 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:      8508 kB
Private_Dirty:    944796 kB
Referenced:       927352 kB
Anonymous:        953304 kB
AnonHugePages:    839680 kB
Swap:             455556 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB

But,when I using 'free' to check memory size under guest OS,there are only 7872MB left on guestOS..

[root@host-10-3-0-221 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          7872        950       6921          0        220        303
-/+ buffers/cache:        426       7446
Swap:         8191          0       8191

I would like to know why the total in guest less than 8192MB.

  • This is not a duplicate of https://unix.stackexchange.com/questions/14102/real-memory-usage - that question (and its answers) don't deal with Qemu/KVM at all! – Blairo Feb 08 '18 at 07:31
  • I can't add an answer here now so just putting a quick comment...

    The overheads you're seeing here are to do with BIOS and kernel of your VM. Inspect a physical system and you'll see the same thing - this is for the low-level system code and virtual device interfacing needed to run the VM, which has its own isolated virtual system.

    Another interesting and related question is how much host/hypervisor overhead there is per unit of guest memory - this is somewhat dependent on the kind and number of virtual devices the guest has, but there are also some constant overheads.

    – Blairo Feb 08 '18 at 07:38

1 Answers1

0

I see this both in KVM and in VMWare and the reason is due to memory overhead used by the Hypervisor to handle the virtual machines,for example to let memory overcommit and dynamic allocation and shared memory work.

I have not found any kvm specific paper for it but vmware forum has a good thread on the issue: https://communities.vmware.com/message/1994605

jnvilo
  • 1