Blob Blame History Raw
From: ccoffing@novell.com
Subject: Expose min/max limits of domain ballooning
Patch-mainline: obsolete
References: 152667, 184727

jb: Also added this to the sysfs representation.

--- head.orig/drivers/xen/balloon/balloon.c	2012-06-08 11:25:24.000000000 +0200
+++ head/drivers/xen/balloon/balloon.c	2012-06-08 11:27:49.000000000 +0200
@@ -216,7 +216,7 @@ static unsigned long current_target(void
 	return target;
 }
 
-static unsigned long minimum_target(void)
+unsigned long balloon_minimum_target(void)
 {
 #ifndef CONFIG_XEN
 #define max_pfn num_physpages
@@ -434,7 +434,7 @@ static void balloon_process(struct work_
 void balloon_set_new_target(unsigned long target)
 {
 	/* No need for lock. Not read-modify-write updates. */
-	bs.target_pages = max(target, minimum_target());
+	bs.target_pages = max(target, balloon_minimum_target());
 	schedule_work(&balloon_worker);
 }
 
@@ -509,10 +509,13 @@ static int balloon_read(char *page, char
 		page,
 		"Current allocation: %8lu kB\n"
 		"Requested target:   %8lu kB\n"
+		"Minimum target:     %8lu kB\n"
+		"Maximum target:     %8lu kB\n"
 		"Low-mem balloon:    %8lu kB\n"
 		"High-mem balloon:   %8lu kB\n"
 		"Driver pages:       %8lu kB\n",
 		PAGES2KB(bs.current_pages), PAGES2KB(bs.target_pages), 
+		PAGES2KB(balloon_minimum_target()), PAGES2KB(num_physpages),
 		PAGES2KB(bs.balloon_low), PAGES2KB(bs.balloon_high),
 		PAGES2KB(bs.driver_pages));
 
--- head.orig/drivers/xen/balloon/common.h	2009-06-09 15:01:37.000000000 +0200
+++ head/drivers/xen/balloon/common.h	2009-08-19 10:36:49.000000000 +0200
@@ -52,5 +52,6 @@ int balloon_sysfs_init(void);
 void balloon_sysfs_exit(void);
 
 void balloon_set_new_target(unsigned long target);
+unsigned long balloon_minimum_target(void);
 
 #endif /* __XEN_BALLOON_COMMON_H__ */
--- head.orig/drivers/xen/balloon/sysfs.c	2012-02-16 17:19:42.000000000 +0100
+++ head/drivers/xen/balloon/sysfs.c	2012-02-16 17:21:58.000000000 +0100
@@ -32,6 +32,7 @@
 #include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/init.h>
+#include <linux/mm.h>
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <xen/balloon.h>
@@ -53,6 +54,8 @@
 	static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
 
 BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(bs.current_pages));
+BALLOON_SHOW(min_kb, "%lu\n", PAGES2KB(balloon_minimum_target()));
+BALLOON_SHOW(max_kb, "%lu\n", PAGES2KB(num_physpages));
 BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(bs.balloon_low));
 BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(bs.balloon_high));
 BALLOON_SHOW(driver_kb, "%lu\n", PAGES2KB(bs.driver_pages));
@@ -123,6 +126,8 @@ static struct device_attribute *balloon_
 
 static struct attribute *balloon_info_attrs[] = {
 	&dev_attr_current_kb.attr,
+	&dev_attr_min_kb.attr,
+	&dev_attr_max_kb.attr,
 	&dev_attr_low_kb.attr,
 	&dev_attr_high_kb.attr,
 	&dev_attr_driver_kb.attr,