From patchwork Thu Sep 21 12:40:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113241 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1845922edb; Thu, 21 Sep 2017 05:42:50 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBXf57dIYj5Zo+/Zb0NaAng9ElueldvdV4mwACXC4aEagbpLi/oCuKqvxc/81P3lfX3N8Dn X-Received: by 10.36.105.142 with SMTP id e136mr1188855itc.17.1505997769979; Thu, 21 Sep 2017 05:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997769; cv=none; d=google.com; s=arc-20160816; b=C5OoeHR7gYOCvGe1wUWnrFV2csb3MEB0SxYS/w+AllS/8uV+9uybVacvMMEpjIvFs1 +3t25JnlOlqtKJmvkKY7lJwidngRXuL1H2um0XKeaVndlwq1jCCTS6L/RU4HQ24w68og r5DCSI0Ffy/e8aLDVUe92diWDOe9/3B4udR0lOw9mHFP1VWS8yz+L8q0EQz/4UOCfzns ty7UGu4p2pK4CYP8wCgSUXe667Zgrku9Abk2Fm8xyD+LwogVgnE40CKECI0Q6SI7KXW3 fK/R3Tnpp/U4/I6ZuSz1qTMaoSXZFyOGet00Dz1bEw5BMnwk4QXUjhrYbLPrrIZxbdXJ Bf6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=x38TadgwGI1qNjXneTCG3zrgx/9Xpf6nCUIgBvfxdq0=; b=A6mj8cVGYErF15EGLFnqgHREZo1NqFqGUZhTYL/hRPP8ofkcXooaDGkVRUFJOd8Zqs oUn/ArcUgtWkVFlB3xZ9qIg9mLbo1BTnSm9rl5zAIajYbIzva8KwaWY3Dr3or4XDQlCI S3A9bHcoLntPc4uCgrSzRy3+oUg3iK2RKPa+duBSQU78yqyWZfLbxr0zeeFWLiydCk0i yvn2eBs7QTeFeVsgAo0V4qqaYwgBbxGEkzeBf5pByMw8FNzeTIYpbE5MnwL8Itprt+k+ psHpijFCI13s1k+I8QbS0xY/gamuKpv6z0xG/Min0ivs3QGeYG71ShoSGpAzkDkmXW2s Iz4w== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x136si1529851itb.84.2017.09.21.05.42.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:49 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mi-0001Ex-Qx; Thu, 21 Sep 2017 12:40:52 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mh-0001Dq-Rq for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:40:51 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 1E/DD-25121-253B3C95; Thu, 21 Sep 2017 12:40:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTTdo8+F Ig9WXpC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oxZqwoLTgpUbHp1g7GB8StPFyMXh5DAZkaJ lvl3WSCc04wS7zYuZ+pi5ORgE9CUuPP5E5gtIiAtce3zZUaQImaBxYwSn/f3MoMkhAWSJPre/ GQHsVkEVCV6Hq5nBLF5BSwknn57zgpiSwjIS+xquwhmcwpYSrQd/gZmCwHV/JpwgnUCI/cCRo ZVjBrFqUVlqUW6RqZ6SUWZ6RkluYmZObqGBsZ6uanFxYnpqTmJScV6yfm5mxiBHq5nYGDcwdh 6wu8QoyQHk5Io77t1hyOF+JLyUyozEosz4otKc1KLDzHKcHAoSfA2bQLKCRalpqdWpGXmAEMN Ji3BwaMkApHmLS5IzC3OTIdInWLU5ei4efcPkxBLXn5eqpQ4rzlIkQBIUUZpHtwIWNhfYpSVE uZlZGBgEOIpSC3KzSxBlX/FKM7BqCTMqwwyhSczrwRu0yugI5iAjsjecADkiJJEhJRUA+Pi4/ wxfzjNlK6x3izdvuqcKl+e49xlp69s8tPawyPtqVz6N1H4fFPhH4ue6aGdadURz2bnrs6sO+8 UGeUZXyw8ySyZ6ZeQhYcFv5Haui8HZpu/YixIfPImW3XaGkufK/eXLrn4Zu2VZ6EzTwg+iJ5Q k7T/sZwQo1iDa+HLtcEi/zomKnW89ldiKc5INNRiLipOBAA9IJ+KdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1505997649!84945964!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37536 invoked from network); 21 Sep 2017 12:40:50 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:40:50 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7FC81164F; Thu, 21 Sep 2017 05:40:49 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 709133F58C; Thu, 21 Sep 2017 05:40:48 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:24 +0100 Message-Id: <20170921124035.2410-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 05/16] xen/x86: p2m-pod: Avoid redundant assignments in p2m_pod_demand_populate 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" gfn_aligned is assigned 3 times with the exact same formula. All the variables used are not modified, so consolidate in a single assignment at the beginning of the function. Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index f04d6e03e2..bcc87aee03 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -1079,7 +1079,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, { struct domain *d = p2m->domain; struct page_info *p = NULL; /* Compiler warnings */ - unsigned long gfn_aligned; + unsigned long gfn_aligned = (gfn >> order) << order; mfn_t mfn; unsigned long i; @@ -1102,7 +1102,6 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, if ( order == PAGE_ORDER_1G ) { pod_unlock(p2m); - gfn_aligned = (gfn >> order) << order; /* * Note that we are supposed to call p2m_set_entry() 512 times to * split 1GB into 512 2MB pages here. But We only do once here because @@ -1147,8 +1146,6 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, BUG_ON((mfn_x(mfn) & ((1UL << order) - 1)) != 0); - gfn_aligned = (gfn >> order) << order; - p2m_set_entry(p2m, gfn_aligned, mfn, order, p2m_ram_rw, p2m->default_access); @@ -1200,7 +1197,6 @@ remap_and_retry: * NOTE: In a p2m fine-grained lock scenario this might * need promoting the gfn lock from gfn->2M superpage. */ - gfn_aligned = (gfn >> order) << order; for ( i = 0; i < (1UL << order); i++ ) p2m_set_entry(p2m, gfn_aligned + i, INVALID_MFN, PAGE_ORDER_4K, p2m_populate_on_demand, p2m->default_access);