64
edits
Changes
vswap in vz7 details added
'''New [[Download/kernel/rhel6|RHEL6-based OpenVZ]] kernel ''' has a new memory management model, which supersedes [[UBC|User beancounters]]. It is called '''VSwap'''.
* '''physpages'''
: This parameter limits sets the amount of fast physical memory (RAM) available to processes inside a container, in memory pages. Currently (as of 042stab042 kernel) the user memory, the kernel memory and the page cache are accounted into <code>physpages</code>.
: The <code>barrier</code> is ignored and should be set to 0, and the <code>limit</code> sets the limit.
* '''ram''': Currently (as of >= 042stab042) the user memoryis an easy shortcut for physpages.limit, the kernel memory and the page cache are accounted into <code>physpages</code>.is measured in bytes
* '''swappages'''
: This parameter limits sets the amount of swap space which can be used for "slower memory" (vswap) available to processes inside a container, in memory pages.
: The <code>barrier</code> is ignored and should be set to 0, and the <code>limit</code> sets the limit.
* '''swap'''
: is an easy shortcut for swappages.limit, and is measured in bytes
The sum of <code>physpages.limit</code> and <code>swappages.limit</code> limits the maximum amount
of allocated memory which can be used by a container. When physpages limit
is reached, memory pages belonging to the container are pushed out to
so called virtual swap (''vswap''). The difference between normal swap
swapping. Actual swap out occurs only if there is a global memory shortage
on the system.
{{Note|swap used by a container can exceed <code>swappages.limit</code>, but is always within sum of <code>physpages.limit</code> and <code>swappages.limit</code>.}}
=== Implicit UBC parameters ===
Since vzctl 4.6, if some optional beancounters are not set, vzctl sets them implicitly,
based on '''ram''' and '''swap''' settings.
The following formulae are used:
<math>lockedpages_{bar} = oomguarpages_{bar} = ram</math>
<math>lockedpages_{lim} = oomguarpages_{lim} = \infty</math>
<math>vmguarpages_{bar} = vmguarpages_{lim} = ram + swap</math>
==== VM overcommit and privvmpages ====
vzctl 4.6 adds a new parameter, <code>--vm_overcommit</code>.
Its only purpose is to be used in privvmpages calculation,
in case VSwap is used and there is no explicit setting
for privvmpages.
If <math>vm\_overcommit</math> is set:
: <math>privvmpages_{bar} = privvmpages_{lim} = (ram + swap) \times vm\_overcommit</math>
If it is not set:
: <math>privvmpages_{bar} = privvmpages_{lim} = \infty</math>
== Setting ==
{{Note|for VSwap, you need vswap-enabled kernel, ie [[Download/kernel/rhel6|RHEL6-based OpenVZ]] kernel.}}
Since vzctl 3.0.30, you can use <code>--ram</code> and <code>--swap</code> parameters, like this:
vzctl set 777 --ram 512M --swap 1G --save
If you have an existing container with usual UBC parameters set, and you want to convert this one into VSwap enabled config, here's what you need to do.
# Decide on how much RAM and swap you want this CT to have. FIXME how Generally, sum of your new RAM+swap should be more or less equal to convert from UBCsum of old PRIVVMPAGES and KMEMSIZE.
# Manually remove all UBC parameters from config. '''This is optional''', you can still have UBC limits applied if you want.
== See also ==
* [http://openvz.livejournal.com/39644.html On vSwap and 042stab04x kernel improvements]* [http://openvz.livejournal.com/39765.html Recent improvements in VSwapvzctl]
[[Category: UBC]]