Received: by 10.223.185.116 with SMTP id b49csp2200662wrg; Sun, 4 Mar 2018 21:21:49 -0800 (PST) X-Google-Smtp-Source: AG47ELshhXsRe/GgNksxnVEylQP5qN9oD0LJICok6Z7DDqIVvCVGjBc8WXMYEhZJOk+ouXixGAYU X-Received: by 2002:a17:902:3124:: with SMTP id w33-v6mr12313388plb.119.1520227309340; Sun, 04 Mar 2018 21:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520227309; cv=none; d=google.com; s=arc-20160816; b=P9Rgj+w1SB18uppQvfrIrMgKoZ87tZnfjbroKMMlL6EMxVnATmJZEKZ/GFsfR5TStD +ooSr8EJ7lRgz5QhvyjdNu0X7c6/OJ5ucmBVXrd9nolDfBUrdh3w4VSC3UDvpHVgvE2z ujoMQckoUsmwQvX4IswZTOJwJvZmODPh5GQ7wP/OFS+wqiNZyeXacOUW41NlAND59xfL Af36A+Y+EcaIO1+XkxnEfRTDJx1Mo09l0Bewxhi9sZXQP0n4MJE6daZFGfJVUIrm2Iz1 TcT1SGYJlAsc5IgQxhn7MJ+jiW8VljkcNXwTReVym5Fsu+eqqxHQdaWFJ9j/LLhPvZ17 aIZw== 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=V425YJ27p290NlWMlMVGj6VgO+Pim7EsXi/7F3ABatMXtASd26frDjo5lRnMgU7EiP GsFHIrladYlZLwUpocQI6UEuW+aZ+7H1jJRibG0UbW3V4u6N4yovkGVFQcq1J00/WEbM PGZ5MMv1Z/uQsZ6BQVCJx9G2bOlCHIIvVNVjipCniw0Cxvhk6avs9KwryK/okD8lTNCK tYLCZSD4tplk9qQZMV01wpsgWLVVkINpT2CyCvLxzTThqMz54crnmdrFr3dq7S4Ogecu bXTCmH6k2WAIxqm4omAAmoY/UIdpHseeTlVG0uTUBjTNO6ZUIfuce8A9jE8hG5RYYzgy 4+3A== 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 ba10-v6si8674809plb.5.2018.03.04.21.21.34; Sun, 04 Mar 2018 21:21:49 -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 S1752728AbeCEFTr (ORCPT + 99 others); Mon, 5 Mar 2018 00:19:47 -0500 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:50524 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752368AbeCEFSf (ORCPT ); Mon, 5 Mar 2018 00:18:35 -0500 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id siVCezclUSVmQsiVCeCvbV; Sun, 04 Mar 2018 22:17:34 -0700 x-originating-ip: 107.180.71.197 Received: from kys by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.89_1) (envelope-from ) id 1esiVB-00050k-SP; Sun, 04 Mar 2018 22:17:33 -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 V2 10/12] hv_balloon: simplify hv_online_page()/hv_page_online_one() Date: Sun, 4 Mar 2018 22:17:20 -0700 Message-Id: <20180305051722.19157-10-kys@exchange.microsoft.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180305051722.19157-1-kys@exchange.microsoft.com> References: <20180305051539.19079-1-kys@exchange.microsoft.com> <20180305051722.19157-1-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfGPod2Aq1F7Gl0vXcGjm8mc5VZZfYkcJzPxLWeMzb60LzC9bQxSgrYk54qNnqEOSPz9+zLbNRgGqHDgTNeRMK+h6LIqfys84BYE3fNZs8SpNi/rhjfFi C5uGqLVQu0lSGz64qLFVy9cbyFyWNHUpdC0U2Wz21/mr8GE13OJ2rLDATiGYOWU62VkNRomIKWFvmacmUw0V2+WOEut2op5pt4St+3OJWg4IRleudj8cy4IY dIsgFm0MvImhLe84gbb8bJqwDX8/42nhpyCxHcNNqdJuQ+XwhD5aS4Snqj5gT+W0lXnXEzIeSOpiQtG4WM9Q3tY6ASKMhNzKyl8czNrr3vGsUo6jknFuL0ZZ CwVNr2BVwypLU65mDGLY36P3xnS9dWxm2W3558yEVdRWVJoGyCCnzyexuqYVrNjvOo8WXnxWMiWgU2oey3u0A/hvTPyJDDxLSHRlUPMlbCtuUiAHfGy9FZ70 LzVJcv1RQVw4Svr2OO9oPkfry12OEUPTkJxQNf1i08cUDac5Mqtdvsw+cJ7eW0jmLoInAufc7hPi9Q20Leaux0/06wscUJj5VVZ3bg== 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