From patchwork Wed Jun 8 13:17:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9164599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74DC460572 for ; Wed, 8 Jun 2016 13:19:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66AF622A2A for ; Wed, 8 Jun 2016 13:19:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B5CB281FE; Wed, 8 Jun 2016 13:19:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D365622A2A for ; Wed, 8 Jun 2016 13:19:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAdMP-0002vs-23; Wed, 08 Jun 2016 13:17:29 +0000 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 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 81/AA-06230-7EA18575; Wed, 08 Jun 2016 13:17:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRWlGSWpSXmKPExsXS6fjDS/e5VES 4we6fwhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bWy9sZC3rkKtZPm8PUwPhMrIuRk0NIIE9i 880OZhCbV8BOYnbvMjBbQsBQYt/8VWxdjBwcLAKqEkeWRIKE2QTUJdqebWcFCYsIGEicO5oEE mYWkJPYfHcaE4gtLGAp8fjwWyaQEl4BQYm/O4QhSuwkbk9qYZzAyDULITMLSQbC1pJ4+OsWC4 StLbFs4WtmkHJmAWmJ5f84IMKmElv7DjNhKnGQ2LIrfgEjxypG9eLUorLUIl1DvaSizPSMktz EzBxdQwMzvdzU4uLE9NScxKRiveT83E2MwLBjAIIdjDufOx1ilORgUhLlVXQPDxfiS8pPqcxI LM6ILyrNSS0+xKjBwSGwbdfqC4xSLHn5ealKEryGwPAWEixKTU+tSMvMAUYGTKkEB4+SCK8tS Jq3uCAxtzgzHSJ1ilFRSpxXCiQhAJLIKM2Da4NF4yVGWSlhXkago4R4ClKLcjNLUOVfMYpzMC oJ88qATOHJzCuBm/4KaDET0OLlR8JBFpckIqSkGhjNUp8zzZjNu/DktfnrTRQLmK1ZGc51mzz hPLta7taXjwp/p04url19OyD/t9ktq913d+gFb+x5mcSSpcR6c6722py/lhniAtuKWWNyXV+a zrynsS5gbXv41y1qEWfbbi4M4p1ubiPywPNi3p5VZYvmXJbtMVWTc/f7uON69Pvw1cUe51uva +QpsRRnJBpqMRcVJwIAaaPsDMECAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1465391845!17942133!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64886 invoked from network); 8 Jun 2016 13:17:26 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-11.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Jun 2016 13:17:26 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 08 Jun 2016 07:17:03 -0600 Message-Id: <575836EC02000078000F3131@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Wed, 08 Jun 2016 07:17:00 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Tim Deegan Subject: [Xen-devel] [PATCH] x86/shadow: sh_pagetable_dying() cleanup X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. 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. 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 = 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 vc else { /* 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) ) --- 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 = 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 vc else { /* 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) )