[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 3/3] x86/xen: optimize get_phys_to_machine()



The page table walk is only needed to distinguish between identity and
missing, both of which have INVALID_P2M_ENTRY.

Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx>
---
 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);
 
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.