]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
x86/iommu: account for necessary allocations when calculating Dom0's
authorKeir Fraser <keir@xen.org>
Wed, 15 Dec 2010 10:31:59 +0000 (10:31 +0000)
committerKeir Fraser <keir@xen.org>
Wed, 15 Dec 2010 10:31:59 +0000 (10:31 +0000)
initial allocation size

As of c/s 21812:e382656e4dcc, IOMMU related allocations for Dom0
happen only after it got all of its memory allocated, and hence the
reserve (mainly for setting up its swiotlb) may get exhausted without
accounting for the necessary allocations up front.

While not precise, the estimate has been found to be within a couple
of pages for the systems it got tested on.

For the calculation to be reasonably correct, this depends on the
patch titled "x86/iommu: don't map RAM holes above 4G" sent out
yesterday.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
xen-unstable changeset:   22506:618ba64260fa
xen-unstable date:        Tue Dec 14 09:54:10 2010 +0000

xen/arch/x86/domain_build.c

index f9d1513f78e0780892087a3a1aa36ecc96b0fe8d..ec2c7a9970aa4160b03c30525b3ac3b4973cbdca 100644 (file)
@@ -188,6 +188,15 @@ static unsigned long __init compute_dom0_nr_pages(
     if ( is_pv_32on64_domain(d) )
         avail -= opt_dom0_max_vcpus - 1;
 
+    /* Reserve memory for iommu_dom0_init() (rough estimate). */
+    if ( iommu_enabled )
+    {
+        unsigned int s;
+
+        for ( s = 9; s < BITS_PER_LONG; s += 9 )
+            avail -= max_page >> s;
+    }
+
     /*
      * If domain 0 allocation isn't specified, reserve 1/16th of available
      * memory for things like DMA buffers. This reservation is clamped to