Difference between revisions of "VSwap"
(added a section name) |
(→Implicit UBC parameters: enlarge a bit) |
||
Line 35: | Line 35: | ||
Since vzctl 4.6, if some optional beancounters are not set, vzctl sets them implicitly, | 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: | The following formulae are used: | ||
Line 45: | Line 45: | ||
<math>vmguarpages_{bar} = vmguarpages_{lim} = ram + swap</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> | : <math>privvmpages_{bar} = privvmpages_{lim} = (ram + swap) \times vm\_overcommit</math> | ||
− | + | If it is not set: | |
: <math>privvmpages_{bar} = privvmpages_{lim} = \infty</math> | : <math>privvmpages_{bar} = privvmpages_{lim} = \infty</math> |
Revision as of 23:24, 1 October 2013
New RHEL6-based OpenVZ kernel has a new memory management model, which supersedes User beancounters. It is called VSwap.
Contents
Primary parameters
With VSwap, there are two required parameters: ram
and swap
(a.k.a. physpages
and swappages
). All the other beancounters become optional.
- physpages
- This parameter 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
physpages
.
- The
barrier
is ignored and should be set to 0, and thelimit
sets the limit.
- ram
- is an easy shortcut for physpages.limit, and is measured in bytes
- swappages
- This parameter sets the amount of "slower memory" (vswap) available to processes inside a container, in memory pages.
- The
barrier
is ignored and should be set to 0, and thelimit
sets the limit.
- swap
- is an easy shortcut for swappages.limit, and is measured in bytes
The sum of physpages.limit
and swappages.limit
limits the maximum amount
of 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
and vswap is that with vswap no actual disk I/O usually occurs. Instead,
a container is artificially slowed down, to emulate the effect of the real
swapping. Actual swap out occurs only if there is a global memory shortage
on the system.
Note: swap used by a container can exceed swappages.limit , but is always within sum of physpages.limit and swappages.limit .
|
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:
VM overcommit and privvmpages
vzctl 4.6 adds a new parameter, --vm_overcommit
.
Its only purpose is to be used in privvmpages calculation,
in case VSwap is used and there is no explicit setting
for privvmpages.
If is set:
If it is not set:
Setting
Note: for VSwap, you need vswap-enabled kernel, ie RHEL6-based OpenVZ kernel. |
Since vzctl 3.0.30, you can use --ram
and --swap
parameters, like this:
vzctl set 777 --ram 512M --swap 1G --save
Convert non-VSwap CT to VSwap
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. Generally, sum of your new RAM+swap should be more or less equal to sum 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.
- Add PHYSPAGES and SWAPPAGES parameters to config. Easiest way is to use
vzctl set $CTID --ram N --swap M --save
Now your config is vswap enabled, and when you (re)start it, vswap mechanism will be used by the kernel for this CT.
How to distinguish between vswap and non-vswap configs?
Both vzctl
and the kernel treats a configuration file as vswap one if PHYSPAGES limit is not set to unlimited
(a.k.a. LONG_MAX). You can also use the following command:
# vzlist -o vswap $CTID
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 /proc/vz/vswap
file.