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
Subject: [PATCH V2 10/12] hv_balloon: simplify hv_online_page()/hv_page_online_one()
Date: Sun, 4 Mar 2018 22:17:20 -0700 [thread overview]
Message-ID: <20180305051722.19157-10-kys@exchange.microsoft.com> (raw)
In-Reply-To: <20180305051722.19157-1-kys@exchange.microsoft.com>
From: Vitaly Kuznetsov <vkuznets@redhat.com>
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 <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
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
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2018-03-05 5:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-05 5:15 [PATCH V2 00/12] Drivers: hv: Miscellaneous fixes kys
2018-03-05 5:17 ` [PATCH V2 01/12] tools/hv: Fix IP reporting by KVP daemon with SRIOV kys
2018-03-05 5:17 ` [PATCH V2 02/12] hyper-v: use GFP_KERNEL for hv_context.hv_numa_map kys
2018-03-05 5:17 ` [PATCH V2 03/12] hv: Synthetic typo correction kys
2018-03-05 5:17 ` [PATCH V2 04/12] tools: hv: fix compiler warnings about major/target_fname kys
2018-03-05 5:17 ` [PATCH V2 05/12] tools: hv: include string.h in hv_fcopy_daemon kys
2018-03-05 5:17 ` [PATCH V2 06/12] vmbus/ring_buffer: remove some redundant helper function kys
2018-03-06 17:56 ` Greg KH
2018-03-05 5:17 ` [PATCH V2 07/12] hv_vmbus: Correct the stale comments regarding cpu affinity kys
2018-03-05 5:17 ` [PATCH V2 08/12] Drivers: hv: vmbus: Implement Direct Mode for stimer0 kys
2018-03-05 5:17 ` [PATCH V2 09/12] hv_balloon: fix printk loglevel kys
2018-03-05 5:17 ` kys [this message]
2018-03-05 5:17 ` [PATCH V2 11/12] hv_balloon: fix bugs in num_pages_onlined accounting kys
2018-03-05 5:17 ` [PATCH V2 12/12] hv_balloon: trace post_status kys
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180305051722.19157-10-kys@exchange.microsoft.com \
--to=kys@exchange.microsoft.com \
--cc=apw@canonical.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=jasowang@redhat.com \
--cc=kys@microsoft.com \
--cc=leann.ogasawara@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.cerri@canonical.com \
--cc=olaf@aepfle.de \
--cc=sthemmin@microsoft.com \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®