From: Mike Latimer Subject: Re: [PATCH] libxl: Wait for ballooning if free memory is increasing Date: Tue, 27 Jan 2015 21:54:58 -0700 Message-ID: <4635643.ev5hQb2ScF@mlatimer1.dnsdhcp.provo.novell.com> References: <1421904173-2941-1-git-send-email-mlatimer@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1421904173-2941-1-git-send-email-mlatimer@suse.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Wednesday, January 21, 2015 10:22:53 PM Mike Latimer wrote: > 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; Ping?