ia64/xen-unstable

changeset 10109:f4f2ff82e797

[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@novell.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri May 19 16:08:51 2006 +0100 (2006-05-19)
parents e7d7287ab222
children d714f923b7cf
files tools/python/xen/xend/image.py
line diff
     1.1 --- a/tools/python/xen/xend/image.py	Fri May 19 16:07:36 2006 +0100
     1.2 +++ b/tools/python/xen/xend/image.py	Fri May 19 16:08:51 2006 +0100
     1.3 @@ -19,6 +19,7 @@
     1.4  
     1.5  import os, string
     1.6  import re
     1.7 +import math
     1.8  
     1.9  import xen.lowlevel.xc
    1.10  from xen.xend import sxp
    1.11 @@ -141,11 +142,13 @@ class ImageHandler:
    1.12                            % (self.ostype, self.vm.getDomid(), str(result)))
    1.13  
    1.14  
    1.15 -    def getDomainMemory(self, mem):
    1.16 +    def getDomainMemory(self, mem_kb):
    1.17          """@return The memory required, in KiB, by the domain to store the
    1.18 -        given amount, also in KiB.  This is normally just mem, but HVM domains
    1.19 -        have overheads to account for."""
    1.20 -        return mem
    1.21 +        given amount, also in KiB.  This is normally just mem, but if HVM is
    1.22 +        supported, keep a little extra free."""
    1.23 +        if 'hvm' in xc.xeninfo()['xen_caps']:
    1.24 +            mem_kb += 4*1024;
    1.25 +        return mem_kb
    1.26  
    1.27      def buildDomain(self):
    1.28          """Build the domain. Define in subclass."""
    1.29 @@ -377,15 +380,20 @@ class HVMImageHandler(ImageHandler):
    1.30          os.waitpid(self.pid, 0)
    1.31          self.pid = 0
    1.32  
    1.33 -    def getDomainMemory(self, mem):
    1.34 +    def getDomainMemory(self, mem_kb):
    1.35          """@see ImageHandler.getDomainMemory"""
    1.36 -        page_kb = 4
    1.37 -        extra_pages = 0
    1.38          if os.uname()[4] == 'ia64':
    1.39              page_kb = 16
    1.40              # ROM size for guest firmware, ioreq page and xenstore page
    1.41              extra_pages = 1024 + 2
    1.42 -        return mem + extra_pages * page_kb
    1.43 +        else:
    1.44 +            page_kb = 4
    1.45 +            # This was derived emperically:
    1.46 +            #   2.4 MB overhead per 1024 MB RAM + 8 MB constant
    1.47 +            #   + 4 to avoid low-memory condition
    1.48 +            extra_mb = (2.4/1024) * (mem_kb/1024.0) + 12;
    1.49 +            extra_pages = int( math.ceil( extra_mb*1024 / page_kb ))
    1.50 +        return mem_kb + extra_pages * page_kb
    1.51  
    1.52      def register_shutdown_watch(self):
    1.53          """ add xen store watch on control/shutdown """