Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754342AbbGXJzY (ORCPT ); Fri, 24 Jul 2015 05:55:24 -0400 Received: from smtp.citrix.com ([66.165.176.89]:7087 "EHLO SMTP.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753459AbbGXJzV (ORCPT ); Fri, 24 Jul 2015 05:55:21 -0400 X-IronPort-AV: E=Sophos;i="5.15,537,1432598400"; d="scan'208";a="284023633" Message-ID: <55B20B56.7020605@citrix.com> Date: Fri, 24 Jul 2015 10:54:30 +0100 From: Julien Grall User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: David Vrabel , CC: , , , Boris Ostrovsky , Subject: Re: [Xen-devel] [PATCH v2 02/20] xen: Introduce a function to split a Linux page into Xen page References: <1436474552-31789-1-git-send-email-julien.grall@citrix.com> <1436474552-31789-3-git-send-email-julien.grall@citrix.com> <55B205FB.5080209@citrix.com> In-Reply-To: <55B205FB.5080209@citrix.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-DLP: MIA1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2340 Lines: 71 On 24/07/15 10:31, David Vrabel wrote: > On 09/07/15 21:42, 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. > [...] >> --- 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) > > I think this should be outlined (unless you have measurements that > support making it inlined). I don't have any performance measurements. Although, when Linux is using 4KB page granularity, the loop in this helper will be dropped by the helper. The code would look like: unsigned long pfn = xen_page_to_pfn(page); ret = fn(page, fn, data); if (ret) return ret; The compiler could even inline the callback (fn). So it drops 2 functions call. > > Also perhaps make it > > int xen_for_each_gfn(struct page *page, > xen_gfn_fn_t fn, void *data); gfn standing for Guest Frame Number right? > or > > int xen_for_each_gfn(struct page **page, unsigned int count, > xen_gfn_fn_t fn, void *data); count being the number of Linux page or Xen page? We have some code (see xlate_mmu patch #19) requiring to iter on a specific number of Xen page. I was thinking to introduce a separate function for iterating on a specific number of Xen PFN. We don't want to introduce it for everyone as we need to hide this complexity from most the caller. In general case, the 2 suggestions would not be very useful. Most of the time we have some actions to do per Linux page (see the balloon code for instance). Regards, -- Julien Grall -- 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/