lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1277853344-19617-1-git-send-email-dtor@vmware.com>
Date:	Tue, 29 Jun 2010 16:15:43 -0700
From:	Dmitry Torokhov <dtor@...are.com>
To:	linux-kernel@...r.kernel.org
Cc:	pv-drivers@...are.com
Subject: [RFC/PATCH 1/2] VMware balloon: add module parameter limiting ballon size

From: Wei Huang <whuang@...are.com>

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.

Signed-off-by: Wei Huang <whuang@...are.com>
Signed-off-by: Dmitry Torokhov <dtor@...are.com>
---
 Documentation/kernel-parameters.txt |    4 ++++
 drivers/misc/vmware_balloon.c       |   18 ++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 82d6aeb..3aabe6e 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -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;
diff --git a/drivers/misc/vmware_balloon.c b/drivers/misc/vmware_balloon.c
index 2a1e804..061cc3e 100644
--- a/drivers/misc/vmware_balloon.c
+++ b/drivers/misc/vmware_balloon.c
@@ -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);
-- 
1.7.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ