From: "Jan Beulich" Subject: Re: [PATCH v5 1/4] xen: move steal_page and donate_page to common code Date: Wed, 11 Sep 2013 07:31:08 +0100 Message-ID: <52302A4C02000078000F243A@nat28.tlf.novell.com> References: <1378742763-24299-1-git-send-email-stefano.stabellini@eu.citrix.com> <522F12FC02000078000F1CDB@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VJdxJ-0001FC-O7 for xen-devel@lists.xenproject.org; Wed, 11 Sep 2013 06:31:13 +0000 In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: xen-devel , keir@xen.org, Ian.Campbell@citrix.com, tim@xen.org List-Id: xen-devel@lists.xenproject.org >>> On 10.09.13 at 19:20, Stefano Stabellini wrote: > On Tue, 10 Sep 2013, Jan Beulich wrote: >> >>> On 09.09.13 at 18:06, Stefano Stabellini > wrote: >> > --- a/xen/common/memory.c >> > +++ b/xen/common/memory.c >> > @@ -230,6 +230,91 @@ int guest_remove_page(struct domain *d, unsigned long > gmfn) >> > return 1; >> > } >> > >> > +int donate_page( >> > + struct domain *d, struct page_info *page, unsigned int memflags) >> > +{ >> > + spin_lock(&d->page_alloc_lock); >> > + >> > + if ( is_xen_heap_page(page) || (page_get_owner(page) != NULL) ) >> > + goto fail; >> > + >> > + if ( d->is_dying ) >> > + goto fail; >> > + >> > + if ( page->count_info & ~(PGC_allocated | 1) ) >> >> While the literal 1 was acceptable in arch specific code, I'm not sure >> it really is in generic code. Nothing enforces that an arch has the >> count starting at bit 0. Even if it reads a little odd, using >> (-PGC_count_mask & PGC_count_mask) would probably be an >> acceptable replacement here and further down. > > (-PGC_count_mask & PGC_count_mask) is always 0. > > I guess you mean: > > if ( page->count_info & ~(PGC_count_mask | PGC_allocated) ) No, I really meant what I wrote, resulting in if ( page->count_info & ~(PGC_allocated | (-PGC_count_mask & PGC_count_mask)) ) Jan