[TriLUG] kvm memory usage seems high

Kevin Hunter Kesling via TriLUG trilug at trilug.org
Fri Oct 21 21:41:29 EDT 2016


Hello TriLUG,

I recently started playing around with KVM, and have found myself with a 
few longer-running VMs.  Like many, I suspect, I was hoping to take 
advantage of KSM, and at first, things seemed to be in order.  However, 
I'm now noting that some instances seem to use a lot more memory than 
I've told them to use (qemu ... -m ...), and I'm hoping TriLUG can offer 
some insights.

First, my two-sentence understanding of Qemu/KVM is that guests are just 
normal Linux processes.  When the virtual machine starts up, Qemu 
allocates X amount of RAM, and the host -- with the usual overcommit 
heuristics -- says "Ok!" to the process.

Mosts guests I provision need no more than 256 MB.  I'm somewhat 
surprised, then, when I see that they have way more than that in RSS (as 
measured via htop on the host).  I'd expect some overhead for Qemu, but 
almost twice that?  For example, here's what 'ps' reports for one such 
process (of a few)

     $ ps waux | kevins_manual_awk_grep_whatev

     USER  ...     VSZ    RSS ... COMMAND
     kevin ... 3316012 472268 ... qemu-system-x86_64 ... -m 256

So, for a 256 MB allocation, the process is using 483 MB (461 MiB) on 
the host?  (The guest registers 236 MiB via free.)  That seems ... off. 
Does Qemu really incur *that* much overhead?

If it matters (and as I write this I realize I have not tried turning it 
off), ksmtuned is indeed installed:

     $ cat pages_shared pages_sharing
     103674
     380764

and on both hosts showing this behavior, the kernel is 4.4.

My google-fu to explain this behavior has not been so great, so I am 
hoping TriLUG might have some insight or experience to help explain this 
extra memory use.

Thanks!

Kevin


More information about the TriLUG mailing list