BALLOON(4) xen BALLOON(4)
NAME
balloonXen hypervisor dynamic memory resize helper
SYNOPSIS
options XEN_BALLOON
DESCRIPTION
The Xen balloon driver can be enabled to allow the Xen hypervisor to dynamically resize the amount of RAM a NetBSD VM is allowed to use. This allows the hypervisor to manage RAM more efficiently, similar in spirit to how the NetBSD kernel would manage RAM wrt processes, with uvm(9).
 
The balloon driver negotiates domain VM memory allocation change requests from the Xen hypervisor, by reserving "pinned" memory for itself from the NetBSD uvm(9) subsystem.
 
There are two methods to notify the balloon driver of memory allocation change requests.
xenbus
In the xenbus method, the change notification originates outside the VM, presumable from the Hypervisor, and is communicated over the xenbus interface.
sysctl(3)
In the sysctl(3) method, the change notification originates from within the VM. Two sysctl(7) nodes are provided:
kern.xen.balloon.current
This node is read-only and returns the number of memory pages currently allocated to the VM.
kern.xen.balloon.target
This node can be written to, and sets a new target memory reservation, in pages. Note that targets set this way from within the VM do not reflect in the hypervisor. This is therefore a less preferred way to use the balloon
 
In either case, once a new allocation target is set, the balloon driver thread asynchronously attempts to reach this target in discrete steps. Every step, if it fails, is tried more than once. When the target is reached, the thread goes back to sleep, waiting for a new incoming target. If it is not reached, the target is updated to reflect the value after the last successful step.
EXAMPLES
# # Have a look at the current reservations. # sysctl -a|grep balloon kern.xen.balloon.current = 32512 kern.xen.balloon.target = 32512 # # # Change the current target to 30000 kernel pages. # sysctl -w kern.xen.balloon.target=30000 kern.xen.balloon.target: 32512 -> 30000 #
SEE ALSO
uvm(9)
Carl A. Waldspurger, Memory Resource Management in VMware ESX Server, Proceedings of the 5th Symposium on Operating Systems Design and Implementation, USENIX Association, December 9-11, 2002, http://www.usenix.org/events/osdi02/tech/full_papers/waldspurger/waldspurger.pdf.
AUTHORS
Cherry G. Mathew <cherry@zyx.in> Jean-Yves Migeon <jym@NetBSD.org>
CAVEATS
VMs can be inadvertently crashed/panic()ed by over expanding the balloon allocation, creating extreme OS memory pressure.
BUGS
xenmem_get_maxreservation() is currently hard-coded to return nkmempages. This driver is still regarded as EXPERIMENTAL.