[libvirt-users] Dealing with swappiness on host systems

Dennis Jacobfeuerborn dennisml at conversis.de
Mon Oct 10 12:39:04 UTC 2016


Hi,
I'm looking for a way to prevent qemu processes on a libvirt host to use
swap unless there is no physical memory free but apparently this is not
as easy as I'd hoped it would be. This is on a CentOS 7 system.

At first I tried setting /proc/sys/vm/swappiness to 1 (apparently
setting it to 0 now means even the OOM killer takes precedence over
swapping:
https://www.percona.com/blog/2014/04/28/oom-relation-vm-swappiness0-new-kernel/
). After doing this I could still see the used swap increase for a guest
even though there were 28G of memory used only as page-cache on the host.

Taking another look at it I notices that swappiness can now apparently
be controlled on a per-process basis as well by means of using the files
under /sys/fs/cgroup/memory/machine.slice however I found no good
documentation describing which of the values takes precedence and
whether these values can be modified on the fly the same way the files
under /proc can.

Has anyone pointers to documentation that explains how all of this
works? More specifically:

Which of these paths take precedence for a running process:
/proc/sys/vm/swappiness
/sys/fs/cgroup/memory/machine.slice/memory.swappiness
/sys/fs/cgroup/memory/machine.slice/<guest-id>/memory.swappiness

Can any/all of these values be modified on the fly and if not is there
another way to tell qemu to prefer physical memory to swap and only use
swap when no physical memory is available?

Regards,
  Dennis




More information about the libvirt-users mailing list