VMware balloon: add module parameter limiting ballon size
Subsystems (2)
PATCH 1/2 VMware balloon: add module parameter limiting ballon size
From: Wei Huang <[email protected]>
To avoid over-ballooning a VM and causing OOM situation introduce module parameter allowing to specify amount of memory (percentage-wise) that is reserved for the kernel, and which is not balloonable.
--- Documentation/kernel-parameters.txt | 4 ++++ drivers/misc/vmware_balloon.c | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-)
Documentation/kernel-parameters.txt +4 -0
@@ -2813,6 +2813,10 @@ and is between 256 and 4096 characters. It is defined in the file vmpoff= [KNL,S390] Perform z/VM CP command after power off. Format: <command> + vmware_balloon.os_percentage = + [HW] Percentage of memory reserved for OS needs and + therefore is not balloonable. Default is 20%. + vt.cur_default= [VT] Default cursor shape. Format: 0xCCBBAA, where AA, BB, and CC are the same as the parameters of the <Esc>[?A;B;Cc escape sequence;
drivers/misc/vmware_balloon.c +14 -4
@@ -45,13 +45,13 @@MODULE_AUTHOR ("VMware, Inc." );MODULE_DESCRIPTION ("VMware Memory Control (Balloon) Driver" ); -MODULE_VERSION ("1.2.1.1-k" ); +MODULE_VERSION ("1.2.1.2-k" );MODULE_ALIAS ("dmi:*:svnVMware*:*" );MODULE_ALIAS ("vmware_vmmemctl" );MODULE_LICENSE ("GPL" );/* -* Various constants controlling rate of inflaint/deflating balloon, +* Various constants controlling rate of inflating/deflating balloon, * measured in pages. */
@@ -218,6 +218,14 @@ static struct vmballoon balloon;static struct workqueue_struct *vmballoon_wq;/* +* We reserve, by default, 20% of the total RAM for OS needs, limiting +* balloon size to 80% of the total RAM. +*/ +static unsigned int vmballoon_os_percentage =20 ; +module_param_named (os_percentage, vmballoon_os_percentage, uint,0644 ); +MODULE_PARM_DESC (os_percentage,"Amount of memory reserved for OS and therefore is not balloonable (default=20%)" ); + +/* * Send "start" command to the host, communicating supported version * of the protocol. */
@@ -651,7 +659,7 @@ static void vmballoon_work(struct work_struct *work) {struct delayed_work *dwork =to_delayed_work (work); struct vmballoon *b = container_of(dwork, struct vmballoon, dwork); -unsigned int target; +unsigned int max_target, target;STATS_INC (b->stats.timer);
@@ -663,7 +671,9 @@ static void vmballoon_work(struct work_struct *work)if (vmballoon_send_get_target (b, &target)) {/* update target, adjust size */ - b->target = target; + max_target = b->sysinfo.totalram * + (100 - vmballoon_os_percentage) /100 ; + b->target =min (target, max_target);if (b->size < target)vmballoon_inflate (b);
Signature · 1 line
1.7.0
PATCH 2/2 VMware balloon: add page sharing interface
From: Wei Huang <[email protected]>
VMware indentifies a class of applications which manage their own memory space and may have performance issues with existing balloon driver. An example is Java virtual machines. JVM maps a large range of virtual address space as heap and manages the heap itself. With balloon driver the OS may end up having less memory to use to back up the whole heap, which can cause undesirable disk swap and performance degradation.
This patch introduces an interface that allows programs communicate amount of memory they manage themselves (stored in vmballoon_pshare_context->max_size for individual application and vmballoon->max_pshare_size for total size). The driver then reduces it's internal balloon target (see vmballoon_adjust_target() function) and reports the difference to the registered applications so that they could close the gap. The user level applications then are expected to fill this gap by, for example, notifying hypervisor that certain pages could be shared.
--- Documentation/kernel-parameters.txt | 6 + drivers/misc/vmware_balloon.c | 293 +++++++++++++++++++++++++++++++++-- 2 files changed, 287 insertions(+), 12 deletions(-)
Documentation/kernel-parameters.txt +6 -0
@@ -2813,6 +2813,12 @@ and is between 256 and 4096 characters. It is defined in the file vmpoff= [KNL,S390] Perform z/VM CP command after power off. Format: <command> + vmware_balloon.enable_pshare = + [HW] Enable page share interface to the balloon module + allowing userspace clients to signal the amount of + pages available for sharing and amount of pages being + shared so that balloon target can be adjusted + accordingly. Default is enabled. vmware_balloon.os_percentage = [HW] Percentage of memory reserved for OS needs and therefore is not balloonable. Default is 20%.
drivers/misc/vmware_balloon.c +281 -12
382 lines not on this page · raw message
Signature · 1 line
1.7.0