[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] balloon: don't crash in HVM-with-PoD guests


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-linux-2.6.18-xen <patchbot@xxxxxxx>
  • Date: Mon, 20 Jan 2014 09:55:02 +0000
  • Delivery-date: Mon, 20 Jan 2014 09:55:10 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1390211059 -3600
# Node ID 6ea18f7269166802f9c03c4bf48e362e89dfdad5
# Parent  9aa376723f25b5f022bc01bb36ae2197ee75d334
balloon: don't crash in HVM-with-PoD guests

989:a7781c0a3b9a ("xen/balloon: fix balloon driver accounting for
HVM-with-PoD case") was almost entirely broken - the BUG_ON() there
triggers as soon as there's any meaningful amount of excess memory.

Re-implement the logic assuming that XENMEM_get_pod_target will at some
point be allowed for a domain to query on itself. Basing the
calculation on just num_physpages results in significantly too much
memory getting balloned out when there's memory beyond the 4G boundary.

Using what recent upstream's get_num_physpages() returns is not an
alternative because that value is too small (even if not as small as
totalram_pages), resulting in not enough pages getting ballooned out.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---


diff -r 9aa376723f25 -r 6ea18f726916 drivers/xen/balloon/balloon.c
--- a/drivers/xen/balloon/balloon.c     Mon Jan 20 10:03:56 2014 +0100
+++ b/drivers/xen/balloon/balloon.c     Mon Jan 20 10:44:19 2014 +0100
@@ -537,17 +537,11 @@ static int __init balloon_init(void)
         * extent of 1. When start_extent > nr_extents (>= in newer Xen), we
         * simply get start_extent returned.
         */
-       totalram_bias = HYPERVISOR_memory_op(rc != -ENOSYS && rc != 1
-               ? XENMEM_maximum_reservation : XENMEM_current_reservation,
-               &pod_target.domid);
-       if ((long)totalram_bias != -ENOSYS) {
-               BUG_ON(totalram_bias < totalram_pages);
-               bs.current_pages = totalram_bias;
-               totalram_bias -= totalram_pages;
-       } else {
-               totalram_bias = 0;
-               bs.current_pages = totalram_pages;
-       }
+       bs.current_pages = pod_target.tot_pages + pod_target.pod_entries
+                          - pod_target.pod_cache_pages;
+       if (rc || bs.current_pages > num_physpages)
+               bs.current_pages = num_physpages;
+       totalram_bias = bs.current_pages - totalram_pages;
 #endif
        bs.target_pages  = bs.current_pages;
        bs.balloon_low   = 0;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.