From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juergen Gross Subject: Re: [PATCH 3/3] x86/xen: optimize get_phys_to_machine() Date: Wed, 07 Jan 2015 16:18:06 +0100 Message-ID: <54AD4E2E.2070103@suse.com> References: <1420642048-12236-1-git-send-email-david.vrabel@citrix.com> <1420642048-12236-4-git-send-email-david.vrabel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Y8sN6-00077m-IM for xen-devel@lists.xenproject.org; Wed, 07 Jan 2015 15:18:08 +0000 In-Reply-To: <1420642048-12236-4-git-send-email-david.vrabel@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: David Vrabel , xen-devel@lists.xenproject.org Cc: Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org On 01/07/2015 03:47 PM, David Vrabel wrote: > The page table walk is only needed to distinguish between identity and > missing, both of which have INVALID_P2M_ENTRY. As get_phys_to_machine is called by __pfn_to_mfn() only which already checks for mfn == INVALID_P2M_ENTRY this optimization will have an effect only in the early boot case with pfn >= xen_p2m_size. I doubt this is necessary. Juergen > > Signed-off-by: David Vrabel > --- > arch/x86/xen/p2m.c | 30 ++++++++++++++++++------------ > 1 file changed, 18 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c > index edbc7a6..a848201 100644 > --- a/arch/x86/xen/p2m.c > +++ b/arch/x86/xen/p2m.c > @@ -405,8 +405,7 @@ void __init xen_vmalloc_p2m_tree(void) > > unsigned long get_phys_to_machine(unsigned long pfn) > { > - pte_t *ptep; > - unsigned int level; > + unsigned long mfn; > > if (unlikely(pfn >= xen_p2m_size)) { > if (pfn < xen_max_p2m_pfn) > @@ -414,19 +413,26 @@ unsigned long get_phys_to_machine(unsigned long pfn) > > return IDENTITY_FRAME(pfn); > } > + > + mfn = xen_p2m_addr[pfn]; > > - ptep = lookup_address((unsigned long)(xen_p2m_addr + pfn), &level); > - BUG_ON(!ptep || level != PG_LEVEL_4K); > + if (unlikely(mfn == INVALID_P2M_ENTRY)) { > + pte_t *ptep; > + unsigned int level; > > - /* > - * The INVALID_P2M_ENTRY is filled in both p2m_*identity > - * and in p2m_*missing, so returning the INVALID_P2M_ENTRY > - * would be wrong. > - */ > - if (pte_pfn(*ptep) == PFN_DOWN(__pa(p2m_identity))) > - return IDENTITY_FRAME(pfn); > + ptep = lookup_address((unsigned long)(xen_p2m_addr + pfn), &level); > + BUG_ON(!ptep || level != PG_LEVEL_4K); > + > + /* > + * The INVALID_P2M_ENTRY is filled in both p2m_*identity > + * and in p2m_*missing, so returning the INVALID_P2M_ENTRY > + * would be wrong. > + */ > + if (pte_pfn(*ptep) == PFN_DOWN(__pa(p2m_identity))) > + return IDENTITY_FRAME(pfn); > + } > > - return xen_p2m_addr[pfn]; > + return mfn; > } > EXPORT_SYMBOL_GPL(get_phys_to_machine); > >