Received: by 10.223.185.116 with SMTP id b49csp1615173wrg; Sun, 11 Feb 2018 16:47:54 -0800 (PST) X-Google-Smtp-Source: AH8x227DYtd9c2HZAItn4FGs65Ph/TbKpeAtP2IEhN+kmAy+G/rBQfOKg4vlova3pY673q9yHXmh X-Received: by 10.101.100.208 with SMTP id t16mr141651pgv.398.1518396473980; Sun, 11 Feb 2018 16:47:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518396473; cv=none; d=google.com; s=arc-20160816; b=U2RcesxVyEOuMt9B/xIlfbh14UDI6L6WKLuOTx4lmsgjakmlBVkarfieiprGtBexKL nkf6eW3s9m6nNILIl8P4caPpLsEmbZdzOdo3H9uYupO7Xb3EUKprlPBL4qjjU3akL6vM OzJ2NTOE1G/AKKUrkzGTGFjCjyNnHVxZXjLDYiAbPy9v4hyBniQ4iiisgJcqSNLRHIat K9ydWS+CWC71InN1ha3v1z3cPhZl+iFuDZjOY9wCgb40YFbPmf9prZ0Xz0HLzgsqObnn rM1vKnJoxIcFYlcPcSZ7pAZPGOOp0FO6g80w0BpJ8+2j948xQ9yfzU3erghyk6iyojOZ ybvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=GTQLATV3W2/YOtOXtY3EPQRnA/gDuscedbnj1zSfJTg=; b=UrSgvoPGp86U/54o7GcCcwyt+Fq1vB13Rp969p13ek1q40KvzSZ/9WVtq0IzXYjG56 En33O0RV68lhesEb+tlWo75GjIR4ABp4hD3h8TktqmUVgBJrp0Ds1eMvm6QZDIAekma9 53ocRVEXlFb+mg5fQYV/v1gcLZxoOok95AN5s77dOIAiYvHK0S7Vz8LOfMWOBncJAb7u 03b6x+HDdJNKZD3Sf+6SXzSt4+/yIN4dBitn7boxiFX9eP3EobRnYYRJ/9KoL9jedPNa GiDIcutJwlbO3PDFj4kfE/ovtlB7KrbtacGjRzepWgZBKo8FgpHNM/b7uGXHWQMbtARd x8uA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l12-v6si3101892plc.262.2018.02.11.16.47.39; Sun, 11 Feb 2018 16:47:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932369AbeBLAqM (ORCPT + 99 others); Sun, 11 Feb 2018 19:46:12 -0500 Received: from a2nlsmtp01-03.prod.iad2.secureserver.net ([198.71.225.37]:48080 "EHLO a2nlsmtp01-03.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932296AbeBLApx (ORCPT ); Sun, 11 Feb 2018 19:45:53 -0500 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id l23teasAvNMFyl23teH8Yb; Sun, 11 Feb 2018 17:33:37 -0700 x-originating-ip: 107.180.71.197 Received: from kys by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.89_1) (envelope-from ) id 1el23t-0001mm-Ei; Sun, 11 Feb 2018 17:33:37 -0700 From: kys@exchange.microsoft.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com, marcelo.cerri@canonical.com, sthemmin@microsoft.com Cc: "K . Y . Srinivasan" Subject: [PATCH 10/12] hv_balloon: simplify hv_online_page()/hv_page_online_one() Date: Sun, 11 Feb 2018 17:33:18 -0700 Message-Id: <20180212003320.6748-10-kys@exchange.microsoft.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212003320.6748-1-kys@exchange.microsoft.com> References: <20180212002958.6679-1-kys@exchange.microsoft.com> <20180212003320.6748-1-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfNlz0XpK94vnLd9YGAHOnLUSrKdaW3REP0kibOY4AR7nFiacVIwMXPvluS9XHiBhMf7a10C0r6OxQmyAfJxKlLVOtX01Vf0ofj6QfQ2Ctaqt0qi0he6X Z0Tv+iP6XpJVmq+22xf6u6Dr0586bCssXe3nRtof/1SI1/ktM0lWWxFzgY4DxooTQgEpUVfHrOp8j/cYzEQkrB0OpYqAEgkGesoWvde5gcIE7xCvX+tBE2vv zBbM0qYJgG2KXUJf90omtaBecUT/QyXwhkJCG7J9vdtKwy5tLobqWmMeAplwetFH2GKU/GXAsyD7G83N8IcQo/ZQuq6c89NLGW2MqAZxbaLy/Xzy4Lr8kVX/ 5I3ocXcuxVTy+sB+0Bsd2mCUscajn1tK4Lhp6vSGsx2BH5uIgP2wBGJa5R6h8QlYXV3jnonluvgA/LXhL6JDZMyy2ZNdb/sVYmvJYdP2AmdGtQa6+YoLSOm+ zREhgWcufhKkNbK5XoYSrAocOb9jJOYGlwt3Q1OOW/lZiPr6y5trf5JAWBE7cKxQ01Ik8vj/vUnUAlf/lLpJIHfaSRQBiNf5WkOxDg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vitaly Kuznetsov Instead of doing pfn_to_page() and continuosly casting page to unsigned long just cache the pfn of the page with page_to_pfn(). Signed-off-by: Vitaly Kuznetsov Signed-off-by: K. Y. Srinivasan --- drivers/hv/hv_balloon.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 1aece72da9ba..5b8e1ad1bcfe 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -612,28 +612,17 @@ static struct notifier_block hv_memory_nb = { /* Check if the particular page is backed and can be onlined and online it. */ static void hv_page_online_one(struct hv_hotadd_state *has, struct page *pg) { - unsigned long cur_start_pgp; - unsigned long cur_end_pgp; struct hv_hotadd_gap *gap; - - cur_start_pgp = (unsigned long)pfn_to_page(has->covered_start_pfn); - cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn); + unsigned long pfn = page_to_pfn(pg); /* The page is not backed. */ - if (((unsigned long)pg < cur_start_pgp) || - ((unsigned long)pg >= cur_end_pgp)) + if ((pfn < has->covered_start_pfn) || (pfn >= has->covered_end_pfn)) return; /* Check for gaps. */ list_for_each_entry(gap, &has->gap_list, list) { - cur_start_pgp = (unsigned long) - pfn_to_page(gap->start_pfn); - cur_end_pgp = (unsigned long) - pfn_to_page(gap->end_pfn); - if (((unsigned long)pg >= cur_start_pgp) && - ((unsigned long)pg < cur_end_pgp)) { + if ((pfn >= gap->start_pfn) && (pfn < gap->end_pfn)) return; - } } /* This frame is currently backed; online the page. */ @@ -726,19 +715,13 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, static void hv_online_page(struct page *pg) { struct hv_hotadd_state *has; - unsigned long cur_start_pgp; - unsigned long cur_end_pgp; unsigned long flags; + unsigned long pfn = page_to_pfn(pg); spin_lock_irqsave(&dm_device.ha_lock, flags); list_for_each_entry(has, &dm_device.ha_region_list, list) { - cur_start_pgp = (unsigned long) - pfn_to_page(has->start_pfn); - cur_end_pgp = (unsigned long)pfn_to_page(has->end_pfn); - /* The page belongs to a different HAS. */ - if (((unsigned long)pg < cur_start_pgp) || - ((unsigned long)pg >= cur_end_pgp)) + if ((pfn < has->start_pfn) || (pfn >= has->end_pfn)) continue; hv_page_online_one(has, pg); -- 2.15.1