[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v4 2/3] x86/shadow: re-use variables in shadow_get_page_from_l1e()
There's little point in doing multiple mfn_to_page() or page_get_owner() on all the same MFN. Calculate them once at the start of the function. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Tim Deegan <tim@xxxxxxx> --- v5: Integrate into series. Re-base. v2: Re-base. --- a/xen/arch/x86/mm/shadow/set.c +++ b/xen/arch/x86/mm/shadow/set.c @@ -88,19 +88,25 @@ static int inline shadow_get_page_from_l1e(shadow_l1e_t sl1e, struct domain *d, p2m_type_t type) { int res; - mfn_t mfn; - struct domain *owner; + mfn_t mfn = shadow_l1e_get_mfn(sl1e); + const struct page_info *pg = NULL; + struct domain *owner = NULL; ASSERT(!sh_l1e_is_magic(sl1e)); ASSERT(shadow_mode_refcounts(d)); + if ( mfn_valid(mfn) ) + { + pg = mfn_to_page(mfn); + owner = page_get_owner(pg); + } + /* * Check whether refcounting is suppressed on this page. For example, * VMX'es APIC access MFN is just a surrogate page. It doesn't actually * get accessed, and hence there's no need to refcount it. */ - mfn = shadow_l1e_get_mfn(sl1e); - if ( mfn_valid(mfn) && page_refcounting_suppressed(mfn_to_page(mfn)) ) + if ( pg && page_refcounting_suppressed(pg) ) return 0; res = get_page_from_l1e(sl1e, d, d); @@ -111,9 +117,7 @@ shadow_get_page_from_l1e(shadow_l1e_t sl */ if ( unlikely(res < 0) && !shadow_mode_translate(d) && - mfn_valid(mfn = shadow_l1e_get_mfn(sl1e)) && - (owner = page_get_owner(mfn_to_page(mfn))) && - (d != owner) ) + owner && (d != owner) ) { res = xsm_priv_mapping(XSM_TARGET, d, owner); if ( !res ) @@ -136,9 +140,8 @@ shadow_get_page_from_l1e(shadow_l1e_t sl * already have checked that we're supposed to have access, so * we can just grab a reference directly. */ - mfn = shadow_l1e_get_mfn(sl1e); - if ( mfn_valid(mfn) ) - res = get_page_from_l1e(sl1e, d, page_get_owner(mfn_to_page(mfn))); + if ( owner ) + res = get_page_from_l1e(sl1e, d, owner); } if ( unlikely(res < 0) )
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |