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] add dom0_max_mem hypervisor boot option

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] add dom0_max_mem hypervisor boot option
From: Ben Thomas <bthomas@xxxxxxxxxxxxxxx>
Date: Tue, 31 Oct 2006 14:42:31 -0500
Delivery-date: Thu, 02 Nov 2006 13:54:58 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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: Mozilla Thunderbird 1.0.8-1.1.fc4 (X11/20060501)
If you want to set dom0 to a specific memory size on a specific
machine, you can use the hypervisor boot option, dom0_mem.  However,
when working with a number of nodes, you may simply want to cap
dom0 memory usage without regard to the specific amount of memory
on each node. FOr this case, you cannot use dom0_mem, as the node
must have that much memory or more.  For this case, the boot option
dom0_max_mem was added.  If dom0_mem is unspecified (to preserve
current behavior), it will act as a ceiling/cap on the amount of
memory available to construct dom0.  Nodes with less memory will
continue to use all of their memory; nodes with more will apply
only the specified portion to dom0. Many words - simple idea.

Simple example: dom0 on all nodes should be 2GB or less, use the
option dom0_max_mem=2G


Signed-off-by: Ben Thomas (ben@xxxxxxxxxxxxxxx)

--
------------------------------------------------------------------------
Ben Thomas                                         Virtual Iron Software
bthomas@xxxxxxxxxxxxxxx                            Tower 1, Floor 2
978-849-1214                                       900 Chelmsford Street
                                                   Lowell, MA 01851
# If you want to set dom0 to a specific memory size on a specific machine,
# you use dom0_mem.  However, if you simply want to cap dom0 memory usage
# across a number of machine, regardless of size, you can't use dom0_mem.
# Add the hypervisor argument dom0_max_mem to allow this type of operation.
# dom0 memory will be capped. It might be less, but never more.
#
# Simple example: all dom0 on all nodes should be 2GB or less, use the
# option dom0_max_mem=2GB.
#
# Signed-off-by: Ben Thomas (ben@xxxxxxxxxxxxxxx)

Index: xen-unstable.hg/xen/arch/x86/domain_build.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/x86/domain_build.c    2006-10-30 
11:13:48.000000000 -0500
+++ xen-unstable.hg/xen/arch/x86/domain_build.c 2006-10-30 11:15:26.000000000 
-0500
@@ -58,6 +58,32 @@
 }
 custom_param("dom0_mem", parse_dom0_mem);
 
+static long dom0_max_nrpages;
+
+/*
+ * dom0_max_mem:
+ *  This parameter is used to specify a maximum size for dom0.
+ *  If there is less memory, that's ok.  If there's more, it's
+ *  capped at this limit.
+ *
+ * Note that this is only valid if dom0_mem is 0 (unspecified)
+ */
+
+static void parse_dom0_max_mem(char *s)
+{
+    unsigned long long bytes;
+    char *t = s;
+    if ( *s == '-' )
+    {
+        printk("dom0_max_mem must be >= 0\n");
+        return;
+    }
+
+    bytes = parse_size_and_unit(t);
+    dom0_max_nrpages = bytes >> PAGE_SHIFT;
+}
+custom_param("dom0_max_mem", parse_dom0_max_mem);
+
 static unsigned int opt_dom0_max_vcpus;
 integer_param("dom0_max_vcpus", opt_dom0_max_vcpus);
 
@@ -209,6 +235,7 @@
     unsigned long alloc_spfn;
     unsigned long alloc_epfn;
     unsigned long count;
+    long dom0_res_pages;
     struct page_info *page = NULL;
     start_info_t *si;
     struct vcpu *v = d->vcpu[0];
@@ -277,8 +304,14 @@
     if ( dom0_nrpages == 0 )
     {
         dom0_nrpages = avail_domheap_pages() + initial_images_nrpages();
-        dom0_nrpages = min(dom0_nrpages / 16, 128L << (20 - PAGE_SHIFT));
-        dom0_nrpages = -dom0_nrpages;
+        dom0_res_pages = min(dom0_nrpages / 16, 128L << (20 - PAGE_SHIFT));
+        dom0_nrpages -= dom0_res_pages;
+       if ( (dom0_max_nrpages > 0) && (dom0_nrpages > dom0_max_nrpages) )
+       {
+            printk("Limiting dom0 pages from %lu to %lu\n",
+                   dom0_nrpages, dom0_max_nrpages);
+           dom0_nrpages = dom0_max_nrpages;
+       }
     }
 
     /* Negative memory specification means "all memory - specified amount". */
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] add dom0_max_mem hypervisor boot option, Ben Thomas <=