From patchwork Mon Oct 2 12:59:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9980811 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 9A95E60365 for ; Mon, 2 Oct 2017 13:02:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DAA2201F3 for ; Mon, 2 Oct 2017 13:02:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 829832888C; Mon, 2 Oct 2017 13:02:15 +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 2A909201F3 for ; Mon, 2 Oct 2017 13:02:15 +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 1dz0KE-0003co-NW; Mon, 02 Oct 2017 12:59:58 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KE-0003cR-2l for xen-devel@lists.xen.org; Mon, 02 Oct 2017 12:59:58 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id EA/87-18674-D4832D95; Mon, 02 Oct 2017 12:59:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdfH4lK kwYdZuhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bfs1kFrwUrfp3pYm5g/MnbxcjFISSwmVFi 9qenbBDOaUaJH6/usHQxcnKwCWhK3Pn8iQnEFhGQlrj2+TIjSBGzwGJGic/7e5lBEsICSRKnb 64Fs1kEVCV2NbwEa+AVsJSY+/EPO4gtISAvsavtIiuIzSlgJfH++EcwWwio5nj3JKYJjNwLGB lWMWoUpxaVpRbpGhnqJRVlpmeU5CZm5ugaGpjq5aYWFyemp+YkJhXrJefnbmIEeriegYFxB+P dyX6HGCU5mJREeZkNL0UK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuBNMQfKCRalpqdWpGXmAEMN Ji3BwaMkwlsMkuYtLkjMLc5Mh0idYtTl6Lh59w+TEEtefl6qlDhvBUiRAEhRRmke3AhY2F9il JUS5mVkYGAQ4ilILcrNLEGVf8UozsGoJMxbCzKFJzOvBG7TK6AjmICOmNN1AeSIkkSElFQD4w HP8oT6xUIfiraEBKxPZJc7EX5Nej9fSsi2A9O/nmv4qvlLwmHj+vtXbXbFHvB6on/JQ/XUzWf fVU8+nvYkm8cuePnWts47+0QE+66edTggfmNSq8vyyssVDdsX7r/80+yKkcJdt9PS37a+Y2M8 ObPu0rKHbo9ip1ZX/Z5bN+Xfjg/ZaytDJ19TYinOSDTUYi4qTgQADEQP0nYCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-206.messagelabs.com!1506949196!85727806!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 63509 invoked from network); 2 Oct 2017 12:59:56 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-206.messagelabs.com with SMTP; 2 Oct 2017 12:59:56 -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 E33A915BF; Mon, 2 Oct 2017 05:59:55 -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 D453C3F53D; Mon, 2 Oct 2017 05:59:54 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:31 +0100 Message-Id: <20171002125941.11274-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 05/15] 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" X-Virus-Scanned: ClamAV using ClamSMTP 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: George Dunlap Reviewed-by: Wei Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add George's and Wei's reviewed-by 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);