View Issue Details

IDProjectCategoryView StatusLast Update
0006316CentOS-6kernelpublic2013-11-22 20:36
Reporterjleung 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformMicrosoft Hyper-VOSWindows 8 6.2.9200OS Version
Product Version6.4 
Target VersionFixed in Version6.5 
Summary0006316: hv_balloon.c is missing pressure reports code and linear function code
DescriptionThe hv_balloon.c code sitting in the EL6.4's kernel source is missing the following patches made upstream since Kernel version 3.8:

-Drivers: hv: balloon: Make adjustments to the pressure report (0731572b6c529f8e8a320dc4df6d67d9a595ecf3)
-Drivers: hv: balloon: Prevent the host from ballooning the guest too low (1c7db96f6feac95d90200ddd0f9b5d94614ea759)

git hashes of those commits are included in this bug report if anybody wants to temporarily resolve this issue.

With close observation, Hyper-V does not do anything to the CentOS 6.4 guest's assigned memory value. Therefore without those 2 patches mentioned above, the hv_balloon module is considered to be broken.

This bug only surfaces when Dynamic Memory is ENABLED at the hypervisor, so anybody who uses EL6.4 but leaves Dynamic Memory disabled should not be affected.
Steps To Reproduce1. enable Dynamic Memory under Hypervisor
2. Boot CentOS 6.4
3. Notice that assigned memory value does not change
Additional InformationI have re-compiled the kernel module with those 2 patches named above and can confirm that the module is working as intended.
TagsNo tags attached.

Activities

jleung

jleung

2013-03-13 07:33

reporter  

0001-HyperV-Balloon-Fix.patch (2,023 bytes)
--- linux-2.6.32-358.0.1.el6/drivers/hv/hv_balloon.c	2013-02-20 07:27:55.000000000 -0800
+++ /root/linux-2.6.32-358.0.1.el6/drivers/hv/hv_balloon.c	2013-03-12 23:43:48.984062102 -0700
@@ -515,6 +515,34 @@ static void process_info(struct hv_dynme
 	}
 }
 
+unsigned long compute_balloon_floor(void)
+{
+	unsigned long min_pages;
+#define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
+	/* Simple continuous piecewiese linear function:
+	 *  max MiB -> min MiB  gradient
+	 *       0         0
+	 *      16        16
+	 *      32        24
+	 *     128        72    (1/2)
+	 *     512       168    (1/4)
+	 *    2048       360    (1/8)
+	 *    8192       552    (1/32)
+	 *   32768      1320
+	 *  131072      4392
+	 */
+	if (totalram_pages < MB2PAGES(128))
+		min_pages = MB2PAGES(8) + (totalram_pages >> 1);
+	else if (totalram_pages < MB2PAGES(512))
+		min_pages = MB2PAGES(40) + (totalram_pages >> 2);
+	else if (totalram_pages < MB2PAGES(2048))
+		min_pages = MB2PAGES(104) + (totalram_pages >> 3);
+	else
+		min_pages = MB2PAGES(296) + (totalram_pages >> 5);
+#undef MB2PAGES
+	return min_pages;
+}
+
 /*
  * Post our status as it relates memory pressure to the
  * host. Host expects the guests to post this status
@@ -528,15 +556,21 @@ static void process_info(struct hv_dynme
 static void post_status(struct hv_dynmem_device *dm)
 {
 	struct dm_status status;
+	struct sysinfo val;
 
-
+	si_meminfo(&val);
 	memset(&status, 0, sizeof(struct dm_status));
 	status.hdr.type = DM_STATUS_REPORT;
 	status.hdr.size = sizeof(struct dm_status);
 	status.hdr.trans_id = atomic_inc_return(&trans_id);
 
-
-	status.num_committed = vm_memory_committed();
+	/*
+	 * The host expects the guest to report free memory.
+	 * Further, the host expects the pressure information to
+	 * include the ballooned out pages.
+	 */
+	status.num_avail = val.freeram;
+	status.num_committed = vm_memory_committed() + dm->num_pages_ballooned + compute_balloon_floor();
 
 	vmbus_sendpacket(dm->dev->channel, &status,
 				sizeof(struct dm_status),
jleung

jleung

2013-03-13 07:34

reporter   ~0016686

I've uploaded the consolidated patch that covers the relevant code to get hv_balloon to work properly
toracat

toracat

2013-03-13 15:24

manager   ~0016688

CentOS kernel is a straight rebuild of the upstream (RHEL) kernel. So, any fix must be done upstream for the distro kernel.

CentOSPlus kernel, on the other hand, is a custom kernel. It may be possible to apply the patches there.
jleung

jleung

2013-03-13 15:30

reporter   ~0016690

Seems like somebody will have to open up a bug with upstream with this one. Since I don't have a RHEL subscription, I doubt I can even open one up there.
toracat

toracat

2013-03-13 15:31

manager   ~0016691

You don't need a subscription. Just set up a login and you should be able to report bugs.
jleung

jleung

2013-03-13 16:55

reporter   ~0016693

Filed a bug at upstream:
https://bugzilla.redhat.com/show_bug.cgi?id=921199
toracat

toracat

2013-03-13 17:05

manager   ~0016694

Thanks. Unfortunately it was automatically (?) made private. Would you mind adding my registered email toracat <at> elrepo.org to the CC list?
toracat

toracat

2013-03-13 17:15

manager   ~0016695

I can see the bug report now. Thank you.
toracat

toracat

2013-03-15 07:37

manager   ~0016721

The centosplus kernel with the patch applied is now available for testing:

http://people.centos.org/toracat/kernel/6/plus/bug6316/

Please note the packages are not singed and are offered for testing purposes only.
toracat

toracat

2013-04-23 20:38

manager   ~0017270

kernel 2.6.32-358.6.1.el6 is out upstream. The second hunk of the patch is now in this kernel, so that part has been removed from the plus kernel.
toracat

toracat

2013-11-22 18:54

manager   ~0018386

The patch is in EL6.5GA ( BZ 927417 / 921199 ).

Issue History

Date Modified Username Field Change
2013-03-13 07:28 jleung New Issue
2013-03-13 07:33 jleung File Added: 0001-HyperV-Balloon-Fix.patch
2013-03-13 07:34 jleung Note Added: 0016686
2013-03-13 15:24 toracat Note Added: 0016688
2013-03-13 15:24 toracat Status new => assigned
2013-03-13 15:30 jleung Note Added: 0016690
2013-03-13 15:31 toracat Note Added: 0016691
2013-03-13 16:55 jleung Note Added: 0016693
2013-03-13 17:05 toracat Note Added: 0016694
2013-03-13 17:15 toracat Note Added: 0016695
2013-03-15 07:37 toracat Note Added: 0016721
2013-04-23 20:38 toracat Note Added: 0017270
2013-11-22 18:54 toracat Note Added: 0018386
2013-11-22 20:33 toracat Resolution open => fixed
2013-11-22 20:33 toracat Product Version 6.4 => 6.5
2013-11-22 20:36 toracat Status assigned => resolved
2013-11-22 20:36 toracat Product Version 6.5 => 6.4
2013-11-22 20:36 toracat Fixed in Version => 6.5