x86/shadow: sh_pagetable_dying() cleanup
PATCH 1/1 x86/shadow: sh_pagetable_dying() cleanup
Don't call shadow_hash_lookup() at all when get_gfn_query_unlocked() didn't return a valid MFN.
Also no need for local variables used only once, the more with scopes much wider than their actual use.
---
Question is whether we shouldn't also get rid of guest_l[234]e_get_paddr(), as they're now effectively unused.
xen/arch/x86/mm/shadow/multi.c +5 -6
@@ -4501,7 +4501,6 @@ static void sh_pagetable_dying(struct vcp2m_type_t p2mt;char *gl3pa =NULL ;guest_l3e_t *gl3e =NULL ; -paddr_t gl2a =0 ;unsigned long l3gfn;mfn_t l3mfn;
@@ -4528,7 +4527,6 @@ static void sh_pagetable_dying(struct vc }for ( i =0 ; i <4 ; i++ ) { -unsigned long gfn;mfn_t smfn, gmfn;if ( fast_path ) {
@@ -4540,10 +4538,11 @@ static void sh_pagetable_dying(struct vcelse {/* retrieving the l2s */ - gl2a =guest_l3e_get_paddr (gl3e[i]); - gfn = gl2a >>PAGE_SHIFT ; - gmfn =get_gfn_query_unlocked (d, gfn, &p2mt); - smfn =shadow_hash_lookup (d,mfn_x (gmfn), SH_type_l2_pae_shadow); + gmfn =get_gfn_query_unlocked (d,gfn_x (guest_l3e_get_gfn (gl3e[i])), + &p2mt); + smfn =likely (mfn_x (gmfn) !=INVALID_MFN ) + ?shadow_hash_lookup (d,mfn_x (gmfn), SH_type_l2_pae_shadow) + : gmfn; }if (mfn_valid (smfn) )
x86/shadow: sh_pagetable_dying() cleanup
Don't call shadow_hash_lookup() at all when get_gfn_query_unlocked() didn't return a valid MFN.
Also no need for local variables used only once, the more with scopes much wider than their actual use.
---
Question is whether we shouldn't also get rid of guest_l[234]e_get_paddr(), as they're now effectively unused.
xen/arch/x86/mm/shadow/multi.c +5 -6
@@ -4501,7 +4501,6 @@ static void sh_pagetable_dying(struct vcp2m_type_t p2mt;char *gl3pa =NULL ;guest_l3e_t *gl3e =NULL ; -paddr_t gl2a =0 ;unsigned long l3gfn;mfn_t l3mfn;
@@ -4528,7 +4527,6 @@ static void sh_pagetable_dying(struct vc }for ( i =0 ; i <4 ; i++ ) { -unsigned long gfn;mfn_t smfn, gmfn;if ( fast_path ) {
@@ -4540,10 +4538,11 @@ static void sh_pagetable_dying(struct vcelse {/* retrieving the l2s */ - gl2a =guest_l3e_get_paddr (gl3e[i]); - gfn = gl2a >>PAGE_SHIFT ; - gmfn =get_gfn_query_unlocked (d, gfn, &p2mt); - smfn =shadow_hash_lookup (d,mfn_x (gmfn), SH_type_l2_pae_shadow); + gmfn =get_gfn_query_unlocked (d,gfn_x (guest_l3e_get_gfn (gl3e[i])), + &p2mt); + smfn =likely (mfn_x (gmfn) !=INVALID_MFN ) + ?shadow_hash_lookup (d,mfn_x (gmfn), SH_type_l2_pae_shadow) + : gmfn; }if (mfn_valid (smfn) )
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 32 lines · Jan Beulich
Don't call
shadow_hash_lookup()at all whenget_gfn_query_unlocked()didn't return a valid MFN.Also no need for local variables used only once, the more with scopes much wider than their actual use.
Signed-off-by Jan Beulich <[email protected]>---
Question is whether we shouldn't also get rid of guest_l[234]e_get_paddr(), as they're now effectively unused.xen/arch/x86/mm/shadow/multi.c +0
-2@@ -4501,7 +4501,6 @@ static void sh_pagetable_dying(struct vcp2m_type_t p2mt;char *gl3pa =NULL ;guest_l3e_t *gl3e =NULL ; -paddr_t gl2a =0 ;unsigned long l3gfn;mfn_t l3mfn;@@ -4528,7 +4527,6 @@ static void sh_pagetable_dying(struct vc }for ( i =0 ; i <4 ; i++ ) { -unsigned long gfn;mfn_t smfn, gmfn;if ( fast_path ) {@@ -4540,10 +4538,11 @@ static void sh_pagetable_dying(struct vcelse {
xen/arch/x86/mm/shadow/multi.c static void sh_pagetable_dying(struct vc · line 4545
Quoted 10 lines
xen/arch/x86/mm/shadow/multi.c +5
-4/* retrieving the l2s */ - gl2a =guest_l3e_get_paddr (gl3e[i]); - gfn = gl2a >>PAGE_SHIFT ; - gmfn =get_gfn_query_unlocked (d, gfn, &p2mt); - smfn =shadow_hash_lookup (d,mfn_x (gmfn), SH_type_l2_pae_shadow); + gmfn =get_gfn_query_unlocked (d,gfn_x (guest_l3e_get_gfn (gl3e[i])), + &p2mt); + smfn =likely (mfn_x (gmfn) !=INVALID_MFN ) + ?shadow_hash_lookup (d,mfn_x (gmfn), SH_type_l2_pae_shadow) + : gmfn;
I think this is clearer as:
smfn = unlikely(mfn_x(gmfn) == INVALID_MFN)
: _mfn(INVALID_MFN)
? shadow_hash_lookup(d, mfn_x(gmfn), SH_type_l2_pae_shadow);With that change, Acked-by: Tim Deegan <[email protected]>
And yes, we can drop the _get_paddr() functions, if you like.
Cheers,
Tim.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel