[Users] Some details of vSwap implementation in Virtuozzo 7
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jul 17 19:10:16 MSK 2020
Hi All,
from time to time people complain on swap in Containers behavior,
most often the complain sounds like
"when a Container uses its vSwap there is a real swap-out on the host,
host physical swap 'used' value is increased => vSwap does not work".
Thus i'd try to explain some details on vSwap implementation in Virtuozzo 7,
hope that makes vSwap behavior more predictable/explainable.
The Container swapping process is similar to that on a standalone computer.
This means in particular that some pages may get into the swap even if there is
some free memory reported in the Container. This may validly happen in case
kernel memory management system detects some anonymous memory which is not
touched for a long time by Container processes and decides that it's more
efficient to put these anonymous pages into the swap and use more caches in a
Container instead.
The Container swap space resides in physical node swap file.
When the swap-out for a Container starts, appropriate number of pages are
allocated in physical swap on the host. Next
a) if there is no free memory on the host, the real swap-out of Container's
memory to physical swap happens
b) if there is free memory on the host, the Container's memory is saved in a
special swap cache in host's RAM and no real write to host's physical swap
occurs
Important note: the physical swap space is allocated in both cases anyway, this
guarantees all amount of host's swap cache for Containers memory can be written
into physical swap on host in case the host gets short of RAM.
Consequence 1: without any configured node swap file the Container's
`SWAPPAGES` parameter will be ignored.
Consequence 2: if node's swap size is less than sum of all Containers' swap
sizes on the node, Containers won't be able to use 100% of their swap
simultaneously - similar to RAM settings.
Hope that helps.
--
Best regards,
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
More information about the Users
mailing list