WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: Keir.Fraser@xxxxxxxxxxxx
Subject: [Xen-devel] [Patch] by default don't give all memory to dom0
From: "Siddha, Suresh B" <suresh.b.siddha@xxxxxxxxx>
Date: Thu, 18 Aug 2005 12:24:13 -0700
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 18 Aug 2005 19:22:29 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.2.5.1i
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