From: Ian Campbell Subject: Re: [PATCH v3 14/14] libxl: build a device tree for ARM guests Date: Mon, 11 Nov 2013 12:14:26 +0000 Message-ID: <1384172066.8909.49.camel@kazak.uk.xensource.com> References: <1383842678.3189.15.camel@kazak.uk.xensource.com> <1383842696-8598-14-git-send-email-ian.campbell@citrix.com> <21115.52782.630571.603241@mariner.uk.xensource.com> <1383846095.3189.27.camel@kazak.uk.xensource.com> <21115.53794.622439.875372@mariner.uk.xensource.com> <1383903020.3189.38.camel@kazak.uk.xensource.com> <21116.65511.25177.194074@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <21116.65511.25177.194074@mariner.uk.xensource.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: Ian Jackson Cc: stefano.stabellini@eu.citrix.com, tim@xen.org, julien.grall@linaro.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Fri, 2013-11-08 at 15:14 +0000, Ian Jackson wrote: > Ian Campbell writes ("Re: [PATCH v3 14/14] libxl: build a device tree for ARM guests"): > > On Thu, 2013-11-07 at 17:47 +0000, Ian Jackson wrote: > > > Personally I normally do something like this > > > fdt_size += 4096; > > > fdt_size <<= 2; > > > which avoids the if (fdt_size). The only downside is that the > > > answers aren't uniformly powers of 2. > > > > TBH I could just go with += and avoid the <<=, I don't actually expect > > an FDT to be so large that exponentially increasing size is that > > important. > > Bear in mind that each of these iterations dumps a bunch of garbage > into the gc. True. We have a bunch of such loops over libxl though. Or was you concern the larger than usual allocation for the fdt itself more than the various sundry allocations during creation? Perhaps I should use libxl__realloc for the big one anyway. > > > How would > > for(fdt_size = 4096; fdt_size < FDT_SIZE_MAX; fdt_size <<= 2) > > and use continue on error in the macro, with a break at the bottom of > > the loop (success) sit with you? > > That would be OK, but using "continue" makes the macro unsuitable to > use in a loop, which is less good. I think it's worth a goto to make > the macro loop-safe. OK. > > If you prefer "continue" you can do "goto resize_continue" and put > resize_continue at the end of the loop. > > Ian.