All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Charles Coffing" <ccoffing@novell.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH]  Fix auto-ballooning of dom0 for HVM domains
Date: Thu, 18 May 2006 13:04:04 -0400	[thread overview]
Message-ID: <446C5554.D169.003C.0@novell.com> (raw)

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

Hi,

I've been trying to make the auto-ballooning of domain 0 work reliably
for HVM domains.

Patch #1 is a simple bug fix, in preparation for patch #2.  Patch #2
tries to calculate how much memory is needed for HVM domains (XenSource
bug #521) and is certainly open for discussion.  Patches apply cleanly
to both 3.0-testing and unstable.

Patch #1 (xen-hvm-auto-balloon.diff):
When a domain (whether para- or fully-virtualized) reports how much
overhead memory it requires (via getDomainMemory in image.py), all such
memory was immediately allocated to the domain itself.  This is
certainly incorrect for HVM domains, since additional
increase_reservation calls are made later in qemu.  Since all ballooned
memory is already taken, qemu will fail.  The fix is to treat the
requested memory size and the overhead size as separate values.  The
requested memory size is immediately allocated to the new domain; the
overhead is left unallocated for whatever else might need it later.

Patch #2 (xen-get-dom-memory.diff):
This patch calculates the overhead needed for HVM domains.  If HVM is
supported by the hardware, I add a little ballooning overhead to
paravirtualized VMs also, to avoid low-memory situations.  (There are
various unchecked alloc_domheap_pages calls in shadow*.c that I am
trying to avoid tripping over for now...)  The values in this patch work
fine on 32 bit; I may update them later based on feedback and/or testing
on 64 bit.

Thanks,
Chuck


[-- Attachment #2: xen-hvm-auto-balloon.diff --]
[-- Type: application/octet-stream, Size: 657 bytes --]

Index: xen-3.0-testing/tools/python/xen/xend/XendDomainInfo.py
===================================================================
--- xen-3.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py
+++ xen-3.0-testing/tools/python/xen/xend/XendDomainInfo.py
@@ -1247,7 +1247,7 @@ class XendDomainInfo:
             m = self.image.getDomainMemory(self.info['memory'] * 1024)
             balloon.free(m)
             xc.domain_setmaxmem(self.domid, m)
-            xc.domain_memory_increase_reservation(self.domid, m, 0, 0)
+            xc.domain_memory_increase_reservation(self.domid, self.info['memory'] * 1024, 0, 0)
 
             self.createChannels()
 

[-- Attachment #3: xen-get-dom-memory.diff --]
[-- Type: application/octet-stream, Size: 2054 bytes --]

Index: xen-3.0-testing/tools/python/xen/xend/image.py
===================================================================
--- xen-3.0-testing.orig/tools/python/xen/xend/image.py
+++ xen-3.0-testing/tools/python/xen/xend/image.py
@@ -19,6 +19,7 @@
 
 import os, string
 import re
+import math
 
 import xen.lowlevel.xc
 from xen.xend import sxp
@@ -143,11 +144,13 @@ class ImageHandler:
                           % (self.ostype, self.vm.getDomid(), str(result)))
 
 
-    def getDomainMemory(self, mem):
+    def getDomainMemory(self, mem_kb):
         """@return The memory required, in KiB, by the domain to store the
-        given amount, also in KiB.  This is normally just mem, but HVM domains
-        have overheads to account for."""
-        return mem
+        given amount, also in KiB.  This is normally just mem, but if HVM is
+        supported, keep a little extra free."""
+        if 'hvm' in xc.xeninfo()['xen_caps']:
+            mem_kb += 4*1024;
+        return mem_kb
 
     def buildDomain(self):
         """Build the domain. Define in subclass."""
@@ -379,15 +382,20 @@ class HVMImageHandler(ImageHandler):
         os.waitpid(self.pid, 0)
         self.pid = 0
 
-    def getDomainMemory(self, mem):
+    def getDomainMemory(self, mem_kb):
         """@see ImageHandler.getDomainMemory"""
-        page_kb = 4
-        extra_pages = 0
         if os.uname()[4] == 'ia64':
             page_kb = 16
             # ROM size for guest firmware, ioreq page and xenstore page
             extra_pages = 1024 + 2
-        return mem + extra_pages * page_kb
+        else:
+            page_kb = 4
+            # This was derived emperically:
+            #   2.4 MB overhead per 1024 MB RAM + 8 MB constant
+            #   + 4 to avoid low-memory condition
+            extra_mb = (2.4/1024) * (mem_kb/1024.0) + 12;
+            extra_pages = int( math.ceil( extra_mb*1024 / page_kb ))
+        return mem_kb + extra_pages * page_kb
 
     def register_shutdown_watch(self):
         """ add xen store watch on control/shutdown """

[-- Attachment #4: 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-05-18 17:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-18 17:04 Charles Coffing [this message]
2006-05-18 18:11 ` [PATCH] Fix auto-ballooning of dom0 for HVM domains Charles Coffing
  -- strict thread matches above, loose matches on Subject: below --
2006-05-19  4:23 Jiang, Yunhong
2006-05-19 15:15 ` Ewan Mellor
2006-05-19 19:59 ` Charles Coffing
2006-05-19 16:29 Jiang, Yunhong
2006-05-22  8:51 Tian, Kevin
2006-05-22  9:06 ` Keir Fraser
2006-05-22 14:51 ` Charles Coffing
2006-05-22 15:03   ` Keir Fraser
2006-05-22 15:15     ` Charles Coffing
2006-05-22  9:09 Tian, Kevin

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=446C5554.D169.003C.0@novell.com \
    --to=ccoffing@novell.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.