From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] x86/shadow: sh_pagetable_dying() cleanup Date: Wed, 08 Jun 2016 07:17:00 -0600 Message-ID: <575836EC02000078000F3131@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartA197A3DC.0__=" Return-path: Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAdMO-0002vm-Fr for xen-devel@lists.xenproject.org; Wed, 08 Jun 2016 13:17:28 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartA197A3DC.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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. Signed-off-by: Jan Beulich --- Question is whether we shouldn't also get rid of guest_l[234]e_get_paddr(), as they're now effectively unused. --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -4501,7 +4501,6 @@ static void sh_pagetable_dying(struct vc p2m_type_t p2mt; char *gl3pa =3D NULL; guest_l3e_t *gl3e =3D NULL; - paddr_t gl2a =3D 0; unsigned long l3gfn; mfn_t l3mfn; =20 @@ -4528,7 +4527,6 @@ static void sh_pagetable_dying(struct vc } for ( i =3D 0; i < 4; i++ ) { - unsigned long gfn; mfn_t smfn, gmfn; =20 if ( fast_path ) { @@ -4540,10 +4538,11 @@ static void sh_pagetable_dying(struct vc else { /* retrieving the l2s */ - gl2a =3D guest_l3e_get_paddr(gl3e[i]); - gfn =3D gl2a >> PAGE_SHIFT; - gmfn =3D get_gfn_query_unlocked(d, gfn, &p2mt); - smfn =3D shadow_hash_lookup(d, mfn_x(gmfn), SH_type_l2_pae_sha= dow); + gmfn =3D get_gfn_query_unlocked(d, gfn_x(guest_l3e_get_gfn(gl3= e[i])), + &p2mt); + smfn =3D likely(mfn_x(gmfn) !=3D INVALID_MFN) + ? shadow_hash_lookup(d, mfn_x(gmfn), SH_type_l2_pae_sha= dow) + : gmfn; } =20 if ( mfn_valid(smfn) ) --=__PartA197A3DC.0__= Content-Type: text/plain; name="x86-sh-get-gfn.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-sh-get-gfn.patch" x86/shadow: sh_pagetable_dying() cleanup=0A=0ADon't call shadow_hash_lookup= () at all when get_gfn_query_unlocked()=0Adidn't return a valid MFN.=0A=0AA= lso no need for local variables used only once, the more with scopes=0Amuch= wider than their actual use.=0A=0ASigned-off-by: Jan Beulich =0A---=0AQuestion is whether we shouldn't also get rid of=0Aguest_l[2= 34]e_get_paddr(), as they're now effectively unused.=0A=0A--- a/xen/arch/x8= 6/mm/shadow/multi.c=0A+++ b/xen/arch/x86/mm/shadow/multi.c=0A@@ -4501,7 = +4501,6 @@ static void sh_pagetable_dying(struct vc=0A p2m_type_t = p2mt;=0A char *gl3pa =3D NULL;=0A guest_l3e_t *gl3e =3D NULL;=0A- = paddr_t gl2a =3D 0;=0A unsigned long l3gfn;=0A mfn_t l3mfn;=0A = =0A@@ -4528,7 +4527,6 @@ static void sh_pagetable_dying(struct vc=0A = }=0A for ( i =3D 0; i < 4; i++ )=0A {=0A- unsigned long = gfn;=0A mfn_t smfn, gmfn;=0A =0A if ( fast_path ) {=0A@@ = -4540,10 +4538,11 @@ static void sh_pagetable_dying(struct vc=0A = else=0A {=0A /* retrieving the l2s */=0A- = gl2a =3D guest_l3e_get_paddr(gl3e[i]);=0A- gfn =3D gl2a >> = PAGE_SHIFT;=0A- gmfn =3D get_gfn_query_unlocked(d, gfn, = &p2mt);=0A- smfn =3D shadow_hash_lookup(d, mfn_x(gmfn), = SH_type_l2_pae_shadow);=0A+ gmfn =3D get_gfn_query_unlocked(d, = gfn_x(guest_l3e_get_gfn(gl3e[i])),=0A+ = &p2mt);=0A+ smfn =3D likely(mfn_x(gmfn) !=3D INVALID_MFN)= =0A+ ? shadow_hash_lookup(d, mfn_x(gmfn), SH_type_l2_pae_= shadow)=0A+ : gmfn;=0A }=0A =0A if ( = mfn_valid(smfn) )=0A --=__PartA197A3DC.0__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --=__PartA197A3DC.0__=--