Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755599AbbGPOYV (ORCPT ); Thu, 16 Jul 2015 10:24:21 -0400 Received: from smtp.citrix.com ([66.165.176.89]:60897 "EHLO SMTP.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754245AbbGPOYU (ORCPT ); Thu, 16 Jul 2015 10:24:20 -0400 X-IronPort-AV: E=Sophos;i="5.15,488,1432598400"; d="scan'208";a="281609845" Date: Thu, 16 Jul 2015 15:23:13 +0100 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: Julien Grall CC: , , , , , Konrad Rzeszutek Wilk , Boris Ostrovsky , "David Vrabel" Subject: Re: [PATCH v2 02/20] xen: Introduce a function to split a Linux page into Xen page In-Reply-To: <1436474552-31789-3-git-send-email-julien.grall@citrix.com> Message-ID: References: <1436474552-31789-1-git-send-email-julien.grall@citrix.com> <1436474552-31789-3-git-send-email-julien.grall@citrix.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-DLP: MIA2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1793 Lines: 59 On Thu, 9 Jul 2015, Julien Grall wrote: > The Xen interface is always using 4KB page. This means that a Linux page > may be split across multiple Xen page when the page granularity is not > the same. > > This helper will break down a Linux page into 4KB chunk and call the > helper on each of them. > > Signed-off-by: Julien Grall > Cc: Konrad Rzeszutek Wilk > Cc: Boris Ostrovsky > Cc: David Vrabel > --- > Changes in v2: > - Patch added > --- > include/xen/page.h | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/include/xen/page.h b/include/xen/page.h > index 8ebd37b..b1f7722 100644 > --- a/include/xen/page.h > +++ b/include/xen/page.h > @@ -39,4 +39,24 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS]; > > extern unsigned long xen_released_pages; > > +typedef int (*xen_pfn_fn_t)(struct page *page, unsigned long pfn, void *data); > +/* Break down the page in 4KB granularity and call fn foreach xen pfn */ > +static inline int xen_apply_to_page(struct page *page, xen_pfn_fn_t fn, > + void *data) > +{ > + unsigned long pfn = xen_page_to_pfn(page); > + int i; > + int ret; please initialize ret to 0 > + for (i = 0; i < XEN_PFN_PER_PAGE; i++, pfn++) { > + ret = fn(page, pfn, data); > + if (ret) > + return ret; > + } > + > + return ret; > +} > + > + > #endif /* _XEN_PAGE_H */ Reviewed-by: Stefano Stabellini -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/