Commit 4f098af5 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Greg Kroah-Hartman

hv_balloon: simplify hv_online_page()/hv_page_online_one()

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: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 223e1e4d
...@@ -612,28 +612,17 @@ static struct notifier_block hv_memory_nb = { ...@@ -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. */ /* 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) 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; struct hv_hotadd_gap *gap;
unsigned long pfn = page_to_pfn(pg);
cur_start_pgp = (unsigned long)pfn_to_page(has->covered_start_pfn);
cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn);
/* The page is not backed. */ /* The page is not backed. */
if (((unsigned long)pg < cur_start_pgp) || if ((pfn < has->covered_start_pfn) || (pfn >= has->covered_end_pfn))
((unsigned long)pg >= cur_end_pgp))
return; return;
/* Check for gaps. */ /* Check for gaps. */
list_for_each_entry(gap, &has->gap_list, list) { list_for_each_entry(gap, &has->gap_list, list) {
cur_start_pgp = (unsigned long) if ((pfn >= gap->start_pfn) && (pfn < gap->end_pfn))
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)) {
return; return;
}
} }
/* This frame is currently backed; online the page. */ /* This frame is currently backed; online the page. */
...@@ -726,19 +715,13 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, ...@@ -726,19 +715,13 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
static void hv_online_page(struct page *pg) static void hv_online_page(struct page *pg)
{ {
struct hv_hotadd_state *has; struct hv_hotadd_state *has;
unsigned long cur_start_pgp;
unsigned long cur_end_pgp;
unsigned long flags; unsigned long flags;
unsigned long pfn = page_to_pfn(pg);
spin_lock_irqsave(&dm_device.ha_lock, flags); spin_lock_irqsave(&dm_device.ha_lock, flags);
list_for_each_entry(has, &dm_device.ha_region_list, list) { 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. */ /* The page belongs to a different HAS. */
if (((unsigned long)pg < cur_start_pgp) || if ((pfn < has->start_pfn) || (pfn >= has->end_pfn))
((unsigned long)pg >= cur_end_pgp))
continue; continue;
hv_page_online_one(has, pg); hv_page_online_one(has, pg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment