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: 114599 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653552qgn; Mon, 2 Oct 2017 06:01:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAIKjyu3CV7eJ6Ypnn72zKY5OdOTG3tKnK4A85RTuzrnPu/iMtFI3juVX9ypZELBwNoea0v X-Received: by 10.107.24.133 with SMTP id 127mr25031240ioy.115.1506949318417; Mon, 02 Oct 2017 06:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949318; cv=none; d=google.com; s=arc-20160816; b=X5X42AjsKUDLscpGbATC5+/Kt6fLaq4/44Rwtv6qhKo7z75mG54JwLLGVnImb9UoCW L6xRrosz6cEUN/i/WxGM9ttbLDy76gVenjgA7oWc7Dy6iPeh0LyNRwFNIO4df6gXbY+F qLsfGTH6/1epHf6bQxoRM4AX99WqU3z/jSf6IW8C8RTyl0FGRhf+7hAnp7ACv0j3GssL 2j5yQ99V5ks7wIOgonVFnwAZE9noNQq+OoKZ1keEAoaohM2krsSCKDdC1GS+pT3bFj5Q vgQ0voPd3rqZxBi5utJ5qQWHA2n9IMh4tN+d4Y6XwwL71UcBqX/8GkYxnQ52++JvB5+Z BV4Q== 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=6mFGRGeEvkFbGibadCG7Ovr1nDsYChaFfZMn/Euw93c=; b=FJgFtSZskHCjPp2C8fyFeqYWRW4mrliKjFW2PiUA8GBdCedCvld9t9oOjhTkW9sSBR jg0/FHSQwhfQGTtzzd4RLUOH/mMMt3zhnE+iBUs0AqK18U8oyt6XPASYvqj2wXdKYLxf aRav8USixnDfmLpqWJIQAH6UN+4CtxWc5bMqwslTZ8XWUAuW+2wy+181cPirbkfGwUKF dTFvafM/NsL4qSwg4enla6Jpw9q48WFl9I1FQH37U8TltMeVNk6OzM2i79RFn4mqMIox OdNtDbC6bz5fdkxW+0KFq5IhZnap0tfeb6NqO+Z5246GTnksogqX58aYQvnTwcbm7PBJ vQQQ== 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 g84si8987547iof.76.2017.10.02.06.01.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:01:58 -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 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" 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);