]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xen/setup: Work properly with 'dom0_mem=X' or with not dom0_mem.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 5 Apr 2012 21:17:54 +0000 (17:17 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 21 May 2012 21:47:35 +0000 (17:47 -0400)
We ignored the X value and ended up populating up to
max(MAX_DOMAIN_PAGES, last E820_RAM entry).

This fixes it by figuring out how many RAM nr_pages the
hypervisor wanted to provide to us and cap the populate
hypercalls up to that.

The end result is (on a 32GB box):

-Memory: 31779964k/34603008k available (5831k kernel code, 1351620k absent, 1471424k reserved, 2886k data, 692k init)
-(XEN) memory.c:133:d0 Could not allocate order=0 extent: id=0 memflags=0 (15 of 512)
+Memory: 31788256k/34032852k available (5831k kernel code, 1351620k absent, 892976k reserved, 2886k data, 692k init)

with dom0_mem=1G
-Memory: 550608k/12890412k available (5831k kernel code, 1351620k absent, 10988184k reserved, 2886k data, 692k init)
+Memory: 717272k/1049028k available (5831k kernel code, 516k absent, 331240k reserved, 2886k data, 692k init)

[v1: Details added]
[v2: Redid on 32GB box]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
arch/x86/xen/setup.c

index 9703e3dd3339c033aa6df87cd7f891715be988a5..09b8cd110b4071990ac2110402fa9848bc74f561 100644 (file)
@@ -282,11 +282,29 @@ static unsigned long __init xen_get_max_pages(void)
         * the current maximum rather than the static maximum. In this
         * case the e820 map provided to us will cover the static
         * maximum region.
+        *
+        * The dom0_mem=min:X,max:Y tweaks options differently depending
+        * on the version, but in general this is what we get:
+        *                | XENMEM_maximum_reser  | nr_pages
+        * --------------++-----------------------+-------------------
+        *  no dom0_mem   | INT_MAX               | max_phys_pfn
+        *  =3G           | INT_MAX               | 786432
+        *  =max:3G       | 786432                | 786432
+        *  =min:1G,max:3G| INT_MAX               | max_phys_fn
+        *  =1G,max:3G    | INT_MAX               | 262144
+        *  =min:1G,max:3G,2G | INT_MAX           | max_phys_fn
+        *
+        * The =3G is often used and it lead to us initially setting
+        * 786432 and allowing dom0 to balloon up to the max_physical_pfn.
+        * This is at odd with the classic XenOClassic so lets emulate
+        * the classic behavior.
         */
        if (xen_initial_domain()) {
                ret = HYPERVISOR_memory_op(XENMEM_maximum_reservation, &domid);
                if (ret > 0)
                        max_pages = ret;
+               if (ret == -1UL)
+                       max_pages = xen_start_info->nr_pages;
        }
 
        return min(max_pages, MAX_DOMAIN_PAGES);