From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH] libxl: Wait for ballooning if free memory is increasing Date: Wed, 28 Jan 2015 13:05:25 +0000 Message-ID: <1422450325.14124.24.camel@citrix.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: Mike Latimer Cc: George Dunlap , Ian Jackson , Stefano Stabellini , Wei Liu , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Wed, 2015-01-21 at 22:22 -0700, Mike Latimer wrote: Sorry for the delay. > @@ -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 */ This isn't quite true -- you also reset the retry count if progress has been made. > + if (free_memkb <= free_memkb_prev) { > + retries--; I think you need to update prev here, otherwise after one successful iteration the condition is always true even if progress subsequently stalls. > + } else { > + retries = MAX_RETRIES; > + free_memkb_prev = free_memkb; ... iow the second assignment here should be after the if/else entirely. Given that this new loop can take significantly longer to fail I wonder if we should add some progress logging? xl has an xtl logger instance available so using xtl_progress might be an easy option. Maybe a separate patch though. Ian.