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

[Xen-changelog] [XEND] An empirical and more conservative memory-overhead estimate for PV and HVM guests.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID f4f2ff82e7977f2dcd4ed6312451d04113569c2b
# Parent  e7d7287ab222d9abd01f84dda21fa444798694ef
[XEND] An empirical and more conservative memory-overhead estimate for PV and 
HVM guests.

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.

Signed-off-by: Charles Coffing <ccoffing@xxxxxxxxxx>
---
 tools/python/xen/xend/image.py |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff -r e7d7287ab222 -r f4f2ff82e797 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Fri May 19 16:07:36 2006 +0100
+++ b/tools/python/xen/xend/image.py    Fri May 19 16:08:51 2006 +0100
@@ -19,6 +19,7 @@
 
 import os, string
 import re
+import math
 
 import xen.lowlevel.xc
 from xen.xend import sxp
@@ -141,11 +142,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."""
@@ -377,15 +380,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 """

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


 


Rackspace

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