All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxl: Wait for ballooning if free memory is increasing
@ 2015-01-22  5:22 Mike Latimer
  2015-01-28  4:54 ` Mike Latimer
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mike Latimer @ 2015-01-22  5:22 UTC (permalink / raw)
  To: xen-devel

During domain startup, all required memory ballooning must complete
within a maximum window of 33 seconds (3 retries, 11 seconds of delay).
If not, domain creation is aborted with a 'failed to free memory' error.

In order to accommodate large domains or slower hardware (which require
substantially longer to balloon memory) the free memory process should
retry as long as the amount of free memory is increasing on each
iteration of the loop.

---
 tools/libxl/xl_cmdimpl.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 0b02a6c..f87efc0 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -2194,8 +2194,9 @@ static int preserve_domain(uint32_t *r_domid, libxl_event *event,
 
 static int freemem(uint32_t domid, libxl_domain_build_info *b_info)
 {
-    int rc, retries = 3;
-    uint32_t need_memkb, free_memkb;
+    int rc, retries;
+    const int MAX_RETRIES = 3;
+    uint32_t need_memkb, free_memkb, free_memkb_prev = 0;
 
     if (!autoballoon)
         return 0;
@@ -2204,6 +2205,7 @@ static int freemem(uint32_t domid, libxl_domain_build_info *b_info)
     if (rc < 0)
         return rc;
 
+    retries = MAX_RETRIES;
     do {
         rc = libxl_get_free_memory(ctx, &free_memkb);
         if (rc < 0)
@@ -2228,7 +2230,13 @@ static int freemem(uint32_t domid, libxl_domain_build_info *b_info)
         if (rc < 0)
             return rc;
 
-        retries--;
+        /* only decrement retry count if free_memkb is not increasing */
+        if (free_memkb <= free_memkb_prev) {
+            retries--;
+        } else {
+            retries = MAX_RETRIES;
+            free_memkb_prev = free_memkb;
+        }
     } while (retries > 0);
 
     return ERROR_NOMEM;
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-30 19:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-22  5:22 [PATCH] libxl: Wait for ballooning if free memory is increasing Mike Latimer
2015-01-28  4:54 ` Mike Latimer
2015-01-28 11:28 ` Wei Liu
2015-01-28 13:05 ` Ian Campbell
2015-01-29  0:14   ` Mike Latimer
2015-01-29 10:14     ` Ian Campbell
2015-01-30 19:58       ` Mike Latimer

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.