[libvirt-users] locking domain memory

Michal Privoznik mprivozn at redhat.com
Mon Nov 21 16:05:49 UTC 2016


On 18.11.2016 23:17, Dennis Jacobfeuerborn wrote:
> Hi,
> is there a way to lock a guests memory so it doesn't get swapped out? I
> now there is memoryBacking->locked but that says it requires
> memtune->hard_limit and the description of that basically "don't ever do
> this" rendering the locked element kind of pointless.
> How can I prevent the guests memory from being swapped out without
> shooting myself in the foot?

There is no simple answer for this question. You have to know your
machines in order to know what to expect. Firstly, it doesn't makes much
sense to lock just guest memory, you need the hypervisor's memory too.
However, if hypervisor is capable of ballooning the guest's memory on
the fly (or there's is a memory leak in hypervisor), you want to put
some limit on how much can be actually locked. But once you put the
limit, kernel starts shooting if it is reached. Then, after you've done
some observation and saw that your qemu takes never more than X bytes,
take into account operations that are short lived - qemu allocates some
memory on hotplug, maybe on some excessive monitor communication too.
Who knows.
Anyway, you've taken the limit X, and added some say 10% on the top of
it - just to be sure, right? And then you upgrade. New binary does of
course have some parts rewritten and thus allocates different amounts of
memory. You see where I am going with this?

Long story short: The problem of determining memory amount needed for a
process to run can be reduced to halting problem. QED.

Michal




More information about the libvirt-users mailing list