Latest revision |
Your text |
Line 76: |
Line 76: |
| # Add PHYSPAGES and SWAPPAGES parameters to config. Easiest way is to use <code>vzctl set $CTID --ram N --swap M --save</code> | | # Add PHYSPAGES and SWAPPAGES parameters to config. Easiest way is to use <code>vzctl set $CTID --ram N --swap M --save</code> |
| | | |
− | Now your config is vswap enabled, and when you (re)start it (or use <code>--reset_ub</code>), vswap mechanism will be used by the kernel for this CT. | + | Now your config is vswap enabled, and when you (re)start it, vswap mechanism will be used by the kernel for this CT. |
− | | |
− | Here is an example of the above steps:
| |
− | | |
− | CTID=123
| |
− | RAM=1G
| |
− | SWAP=2G
| |
− | CFG=/etc/vz/conf/${CTID}.conf
| |
− | cp $CFG $CFG.pre-vswap
| |
− | grep -Ev '^(KMEMSIZE|LOCKEDPAGES|PRIVVMPAGES|SHMPAGES|NUMPROC|PHYSPAGES|VMGUARPAGES|OOMGUARPAGES|NUMTCPSOCK|NUMFLOCK|NUMPTY|NUMSIGINFO|TCPSNDBUF|TCPRCVBUF|OTHERSOCKBUF|DGRAMRCVBUF|NUMOTHERSOCK|DCACHESIZE|NUMFILE|AVNUMPROC|NUMIPTENT|ORIGIN_SAMPLE|SWAPPAGES)=' > $CFG < $CFG.pre-vswap
| |
− | vzctl set $CTID --ram $RAM --swap $SWAP --save
| |
− | vzctl set $CTID --reset_ub
| |
| | | |
| == How to distinguish between vswap and non-vswap configs? == | | == How to distinguish between vswap and non-vswap configs? == |
Line 96: |
Line 85: |
| | | |
| In addition, vzctl checks if kernel support vswap, and refuses to start a vswap-enabled container on a non vswap capable kernel. The check is presence of <code>/proc/vz/vswap</code> file. | | In addition, vzctl checks if kernel support vswap, and refuses to start a vswap-enabled container on a non vswap capable kernel. The check is presence of <code>/proc/vz/vswap</code> file. |
− |
| |
− | == Details about vSwap implementation in Virtuozzo 7 ==
| |
− |
| |
− | The Container swapping process is similar to that on a standalone computer.<br>
| |
− | This means in particular that some pages may get into the swap even if there is some free memory reported in the Container.<br>
| |
− | 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.<br>
| |
− | When the swap-out for a Container starts, appropriate number of pages are allocated in physical swap on the host. Next
| |
− | # if there is no free memory on the host, the real swap-out of Container's memory to physical swap happens
| |
− | # 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
| |
− |
| |
− | {{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.
| |
| | | |
| == See also == | | == See also == |