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

[Xen-devel] [Patch] by default don't give all memory to dom0



On a system where swiotlb is used, by default xen fails to allocate
memory for dom0's swiotlb contiguous memory request.

By default, xen needs to reserve some portion of memory to satisfy
SWIOTLB and other contguous memory region requests. Following
the current swiotlb enabling mechanism, Appended patch reserves 128MB 
of memory on systems with more than 2GB of RAM.

Ideally shouldn't we enable SWIOTLB in dom0 and this DMA memory reservation
in hypervisor by default? Otherwise we will have a problem(even on systems 
with less than 2GB of RAM) in servicing a driver DMA request to a 
kmalloc'd buffer which spans more than a page or the various 
xen_create_contiguous_region() requests.

Signed-off-by: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>

diff -r 84ee014ebd41 xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c       Wed Aug 17 20:34:38 2005
+++ b/xen/arch/x86/domain_build.c       Thu Aug 18 11:52:57 2005
@@ -34,6 +34,18 @@
         opt_dom0_mem = (unsigned int)(bytes >> 10);
 }
 custom_param("dom0_mem", parse_dom0_mem);
+
+static unsigned int reserve_dmapages = 0;
+static void parse_reserve_dmamem(char *s)
+{
+    unsigned long long bytes = parse_size_and_unit(s);
+    /* If no unit is specified we default to kB units, not bytes. */
+    if ( isdigit(s[strlen(s)-1]) )
+        reserve_dmapages = (unsigned int)bytes >> (PAGE_SHIFT - 10);
+    else
+        reserve_dmapages = (unsigned int)(bytes >> PAGE_SHIFT);
+}
+custom_param("dma_mem", parse_reserve_dmamem);
 
 static unsigned int opt_dom0_shadow = 0;
 boolean_param("dom0_shadow", opt_dom0_shadow);
@@ -137,10 +149,13 @@
 
     printk("*** LOADING DOMAIN 0 ***\n");
 
-    /* By default DOM0 is allocated all available memory. */
     d->max_pages = ~0U;
+    /* By default DOM0 is allocated (all available memory - reserved dma 
+       low memory) */
+    if (!reserve_dmapages && max_page > 0x7ffff)
+       reserve_dmapages = 32 * 1024; /* 128MB */
     if ( (nr_pages = opt_dom0_mem >> (PAGE_SHIFT - 10)) == 0 )
-        nr_pages = avail_domheap_pages() +
+        nr_pages = avail_domheap_pages() - reserve_dmapages +
             ((initrd_len + PAGE_SIZE - 1) >> PAGE_SHIFT) +
             ((image_len  + PAGE_SIZE - 1) >> PAGE_SHIFT);
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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