OpenVZ Forum


Home » General » Support » How to enable swap for CT when swap on OpenVZ 7 host machine is disabled?
Re: How to enable swap for CT when swap on OpenVZ 7 host machine is disabled? [message #53649 is a reply to message #53461] Mon, 08 June 2020 09:41 Go to previous message
khorenko is currently offline  khorenko
Messages: 533
Registered: January 2006
Location: Moscow, Russia
Senior Member
Yes, i know the thread is old.
i'm writing here because this page is mentioned in the OpenVZ bug
https://bugs.openvz.org/browse/OVZ-7072

Quote from the bug:
Quote:

Guys, you've described vSwap behavior in vz7 correctly:
* if some page goes into virtual swap inside a Container, a new page is allocated in physical swap on the Hardware Node. Always.
* if there is free RAM on the host, the page is NOT written to physical swap on the host, but saved in free host RAM (tswap area)
* tswap - is a cache, so on a memory pressure (on host) it must free its pages, so it MUST have some space to write the data - that's why swap entry is allocated in advance - it guarantees all tswap entries can be freed any time later
* important note: once again - physical swap entries on host are allocated if a CT uses vswap, but real data is NOT written to the physical disk in case there is free RAM on host

On vz6 we had similar behavior initially but later had to rework so vswap does not allocate physical swap entries.
This was done because online migration required it: technically in vz6 online migration marks all memory pages as "in swap", thus is required lot of physical swap - not only for CT vswap usage, but for all memory usage as well. And sometimes online migration fails to to luck of physical swap.

In vz7 CRIU online migration work in another way, so no need for such hack anymore and thus we do not plan to change this behavior.

Disks are big now, so increasing swap space on the host should not be a big problem (once again - there is no real swapin/swapout if there is free RAM on host).
Or just don't set up vSwap for Containers: if host has free RAM, the performance is the same (if CT has RAM=4Gb vs CT has RAM 2Gb + vSwap 2Gb),
and in case host does not have free RAM (so vSwap does not work at all, host physical swap is used), host memory management knows better what memory to put into physical swap.


If your problem is solved - please, report it!
It's even more important than reporting the problem itself...
 
Read Message
Read Message
Previous Topic: OpenVZ 7 Precreated OS Template
Next Topic: vzpkg clean error
Goto Forum:
  


Current Time: Sun Sep 15 21:27:35 GMT 2024

Total time taken to generate the page: 0.03655 seconds