All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Thomas <bthomas@virtualiron.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] add dom0_max_mem hypervisor boot option
Date: Tue, 31 Oct 2006 14:42:31 -0500	[thread overview]
Message-ID: <4547A727.9000900@virtualiron.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1218 bytes --]

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@virtualiron.com)

-- 
------------------------------------------------------------------------
Ben Thomas                                         Virtual Iron Software
bthomas@virtualiron.com                            Tower 1, Floor 2
978-849-1214                                       900 Chelmsford Street
                                                    Lowell, MA 01851

[-- Attachment #2: 10238_dom0_max_mem.patch --]
[-- Type: text/x-patch, Size: 2501 bytes --]

# 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@virtualiron.com)

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". */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

                 reply	other threads:[~2006-10-31 19:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4547A727.9000900@virtualiron.com \
    --to=bthomas@virtualiron.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.