Skip to contentSkip to conversation

Split the meaning of "dom0-min-mem = 0" to a new option

PATCH New Masaki Kanno 1 participant 1 message Apr 7, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Split the meaning of "dom0-min-mem = 0" to a new option

Hi,

I have written a patch to split the current meaning of "dom0-min-mem = 0" to a new option "enable-dom0-ballooning".

Best regards,
Kan

tools/examples/xend-config-xenapi.sxp +6 -1
diff -r e8f058b99171 tools/examples/xend-config-xenapi.sxp
@@ -170,8 +170,13 @@
 
 # Dom0 will balloon out when needed to free memory for domU.
 # dom0-min-mem is the lowest memory level (in MB) dom0 will get down to.
-# If dom0-min-mem=0, dom0 will never balloon out.
+# And when dom0 momory is decreased by xm mem-set, dom0-min-mem is used to
+# prevent dom0 memory from decreasing to too small size.
 (dom0-min-mem 196)
+
+# Whether to enable ballooning out dom0.
+# If enable-dom0-ballooning = no, dom0 will never balloon out.
+#(enable-dom0-ballooning yes)
 
 # In SMP system, dom0 will use dom0-cpus # of CPUS
 # If dom0-cpus = 0, dom0 will take all cpus available
tools/examples/xend-config.sxp +6 -1
diff -r e8f058b99171 tools/examples/xend-config.sxp
@@ -168,8 +168,13 @@
 
 # Dom0 will balloon out when needed to free memory for domU.
 # dom0-min-mem is the lowest memory level (in MB) dom0 will get down to.
-# If dom0-min-mem=0, dom0 will never balloon out.
+# And when dom0 momory is decreased by xm mem-set, dom0-min-mem is used to
+# prevent dom0 memory from decreasing to too small size.
 (dom0-min-mem 196)
+
+# Whether to enable ballooning out dom0.
+# If enable-dom0-ballooning = no, dom0 will never balloon out.
+#(enable-dom0-ballooning yes)
 
 # In SMP system, dom0 will use dom0-cpus # of CPUS
 # If dom0-cpus = 0, dom0 will take all cpus available
tools/python/xen/xend/XendOptions.py +3 -0
diff -r e8f058b99171 tools/python/xen/xend/XendOptions.py
@@ -278,6 +278,9 @@ class XendOptions:
 
     def get_dom0_min_mem(self):
         return self.get_config_int('dom0-min-mem', self.dom0_min_mem_default)
+
+    def get_enable_dom0_ballooning(self):
+        return self.get_config_bool('enable-dom0-ballooning', 'yes')
 
     def get_dom0_vcpus(self):
         return self.get_config_int('dom0-cpus', self.dom0_vcpus_default)
tools/python/xen/xend/balloon.py +9 -8
diff -r e8f058b99171 tools/python/xen/xend/balloon.py
@@ -81,8 +81,8 @@ def free(need_mem):
     # needs to balloon.  No matter where we expect the free memory to come
     # from, we need to wait for it to become available.
     #
-    # We are not allowed to balloon below dom0_min_mem, or if dom0_min_mem
-    # is 0, we cannot balloon at all.  Memory can still become available
+    # We are not allowed to balloon below dom0_min_mem, or if dom0_ballooning
+    # is False, we cannot balloon at all.  Memory can still become available
     # through a rebooting domain, however.
     #
     # Eventually, we time out (presumably because there really isn't enough
@@ -100,6 +100,7 @@ def free(need_mem):
 
     try:
         dom0_min_mem = xoptions.get_dom0_min_mem() * 1024
+        dom0_ballooning = xoptions.get_enable_dom0_ballooning()
         dom0_alloc = get_dom0_current_alloc()
 
         retries = 0
@@ -115,7 +116,7 @@ def free(need_mem):
         free_mem = physinfo['free_memory']
         scrub_mem = physinfo['scrub_memory']
         total_mem = physinfo['total_memory']
-        if dom0_min_mem > 0:
+        if dom0_ballooning:
             max_free_mem = total_mem - dom0_min_mem
         else:
             max_free_mem = total_mem - dom0_alloc
@@ -137,7 +138,7 @@ def free(need_mem):
                 log.debug("Balloon: %d KiB free; %d to scrub; need %d; retries: %d.",
                           free_mem, scrub_mem, need_mem, rlimit)
 
-            if dom0_min_mem > 0:
+            if dom0_ballooning:
                 dom0_alloc = get_dom0_current_alloc()
                 new_alloc = dom0_alloc - (need_mem - free_mem - scrub_mem)
 
@@ -163,10 +164,10 @@ def free(need_mem):
             last_free = free_mem + scrub_mem
 
         # Not enough memory; diagnose the problem.
-        if dom0_min_mem == 0:
-            raise VmError(('Not enough free memory and dom0_min_mem is 0, so '
-                           'I cannot release any more.  I need %d KiB but '
-                           'only have %d.') %
+        if not dom0_ballooning:
+            raise VmError(('Not enough free memory and enable-dom0-ballooning '
+                           'is False, so I cannot release any more.  '
+                           'I need %d KiB but only have %d.') %
                           (need_mem, free_mem))
         elif new_alloc < dom0_min_mem:
             raise VmError(

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel