I checked a 512M guest which has with some overhead ~550M
The majority is the unique guest memory and qemu allocations.
And a slight bit out of shared mappings.

  PID User     Command                         Swap      USS      PSS      RSS 
65719 libvirt-qemu /usr/bin/qemu-system-x86_64     4.0K   549.5M   550.6M   
554.3M 

ps_mem here reports 1.1G which is wrong
 Private  +   Shared  =  RAM used       Program
549.3 MiB + 551.6 MiB =   1.1 GiB       qemu-system-x86_64

If you look in /proc/<pid>smaps you'll find that qemu has
the usual libs and a few unpopulated 64M mappings.
The real majority of memory consumption is in the mapping
of the guest memory.

7fb9b3e00000-7fb9d3e00000 rw-p 00000000 00:00 0 
Size:             524288 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Rss:              524176 kB
Pss:              524176 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:    524176 kB
Referenced:       519084 kB
Anonymous:        524176 kB
LazyFree:              0 kB
AnonHugePages:         0 kB
ShmemPmdMapped:        0 kB
FilePmdMapped:        0 kB
Shared_Hugetlb:        0 kB
Private_Hugetlb:       0 kB
Swap:                  0 kB
SwapPss:               0 kB
Locked:                0 kB
THPeligible:            1
VmFlags: rd wr mr mw me dc ac dd sd hg mg

There just isn't much more than that:
root@g-newqemu:~# cat /proc/65719/smaps | grep -e '^Rss' | awk 'BEGIN {sum=0} 
{sum=sum+$2} END {print sum}'
567464
root@g-newqemu:~# cat /proc/65719/smaps | grep -e '^Pss' | awk 'BEGIN {sum=0} 
{sum=sum+$2} END {print sum}'
563837

ps_mem just has a bug in this case,
one can have a shared mapping without shared bytes.
But ps_mem does parse shared and pss to then recalculate it as:
   Shared = Pss - Private
That is just wrong, shared is zero.
The calculation above makes it assume twice as much memory as is really 
consumed.

As ps_mem isn't in Ubuntu that is at best a bug report at
https://github.com/pixelb/ps_mem/issues

** Changed in: qemu (Ubuntu)
       Status: Incomplete => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1892648

Title:
  VM eating twice the memory allocated

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1892648/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to