From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH] libxc: refactor memory allocation functions Date: Tue, 1 Dec 2015 12:03:16 +0000 Message-ID: <20151201120316.GP21588@citrix.com> References: <1448969956-26310-1-git-send-email-wei.liu2@citrix.com> <1448971124.15768.117.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a3jeX-0003Nf-JD for xen-devel@lists.xenproject.org; Tue, 01 Dec 2015 12:03:25 +0000 Content-Disposition: inline In-Reply-To: <1448971124.15768.117.camel@citrix.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 Campbell Cc: Juergen Gross , Xen-devel , Wei Liu , Ian Jackson List-Id: xen-devel@lists.xenproject.org On Tue, Dec 01, 2015 at 11:58:44AM +0000, Ian Campbell wrote: > On Tue, 2015-12-01 at 11:39 +0000, Wei Liu wrote: > > There were some problems with the original memory allocation functions: > > 1. xc_dom_alloc_segment and xc_dom_alloc_pad ended up calling > > =A0=A0=A0xc_dom_chk_alloc_pages while xc_dom_alloc_page open-coded ever= ything. > > 2. xc_dom_alloc_pad didn't call dom->allocate. > > = > > Refactor the code so that: > > 1. xc_dom_alloc_{segment,pad,page} end up calling > > =A0=A0=A0xc_dom_chk_alloc_pages. > > 2. xc_dom_chk_alloc_pages calls dom->allocate. > > = > > This way we avoid scattering dom->allocate over multiple locations and > > open-coding. > > = > > Also change the return type of xc_dom_alloc_page to xen_pfn_t and return > > an invalid pfn when xc_dom_chk_alloc_pages fails. > = > Given this presumably the handful of callers ought to gain some error > handling in a followup patch? > = Yes, that's for sure. > xc_dom_chk_alloc_pages does log, so at least the callers needn't bother > with that. > = > > Signed-off-by: Wei Liu > = > Acked-by: Ian Campbell > = > > --- > > Cc: Ian Campbell > > Cc: Ian Jackson > > Cc: Juergen Gross > > = > > We don't have INVALID_PFN, maybe we need one? > = > We have INVALID_MFN and INVALID_P2M_ENTRY, not sure if the latter fits the > bill (or if not how it is distinct from the former). > = Yeah, I'm aware of those but they don't seem to fit because they are used in MFN space. > > = > > Tested with Jessie with 64 bit pvgrub, Wheezy with 64 bit pvgrub, Wheezy > > pv > > guest, Wheezy HVM guest, Wheezy HVM with qemu stubdom. > = > Also by me in my previously failing environment =3D> > = > Tested-by: Ian Campbell > = > I think there are two more fixes in this space: > libxc: correct domain builder for 64 bit guest with 32 bit tools > libxc: use correct return type for do_memory_op() > = > I intend to pick up all three for commit in a moment, prod me if there are > others. > = This one and the other two are all that I'm aware of at the moment. Wei.