Commit 92917998 authored by David Hildenbrand's avatar David Hildenbrand Committed by Linus Torvalds

mm/memory_hotplug: drop valid_start/valid_end from test_pages_in_a_zone()

The callers are only interested in the actual zone, they don't care about
boundaries.  Return the zone instead to simplify.

Link: http://lkml.kernel.org/r/20200110183308.11849-1-david@redhat.comSigned-off-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oscar Salvador <osalvador@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 52fb87c8
...@@ -376,7 +376,6 @@ static ssize_t valid_zones_show(struct device *dev, ...@@ -376,7 +376,6 @@ static ssize_t valid_zones_show(struct device *dev,
struct memory_block *mem = to_memory_block(dev); struct memory_block *mem = to_memory_block(dev);
unsigned long start_pfn = section_nr_to_pfn(mem->start_section_nr); unsigned long start_pfn = section_nr_to_pfn(mem->start_section_nr);
unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block;
unsigned long valid_start_pfn, valid_end_pfn;
struct zone *default_zone; struct zone *default_zone;
int nid; int nid;
...@@ -389,11 +388,11 @@ static ssize_t valid_zones_show(struct device *dev, ...@@ -389,11 +388,11 @@ static ssize_t valid_zones_show(struct device *dev,
* The block contains more than one zone can not be offlined. * The block contains more than one zone can not be offlined.
* This can happen e.g. for ZONE_DMA and ZONE_DMA32 * This can happen e.g. for ZONE_DMA and ZONE_DMA32
*/ */
if (!test_pages_in_a_zone(start_pfn, start_pfn + nr_pages, default_zone = test_pages_in_a_zone(start_pfn,
&valid_start_pfn, &valid_end_pfn)) start_pfn + nr_pages);
if (!default_zone)
return sprintf(buf, "none\n"); return sprintf(buf, "none\n");
start_pfn = valid_start_pfn; strcat(buf, default_zone->name);
strcat(buf, page_zone(pfn_to_page(start_pfn))->name);
goto out; goto out;
} }
......
...@@ -96,8 +96,8 @@ extern int add_one_highpage(struct page *page, int pfn, int bad_ppro); ...@@ -96,8 +96,8 @@ extern int add_one_highpage(struct page *page, int pfn, int bad_ppro);
/* VM interface that may be used by firmware interface */ /* VM interface that may be used by firmware interface */
extern int online_pages(unsigned long pfn, unsigned long nr_pages, extern int online_pages(unsigned long pfn, unsigned long nr_pages,
int online_type, int nid); int online_type, int nid);
extern int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn, extern struct zone *test_pages_in_a_zone(unsigned long start_pfn,
unsigned long *valid_start, unsigned long *valid_end); unsigned long end_pfn);
extern unsigned long __offline_isolated_pages(unsigned long start_pfn, extern unsigned long __offline_isolated_pages(unsigned long start_pfn,
unsigned long end_pfn); unsigned long end_pfn);
......
...@@ -1172,14 +1172,13 @@ bool is_mem_section_removable(unsigned long start_pfn, unsigned long nr_pages) ...@@ -1172,14 +1172,13 @@ bool is_mem_section_removable(unsigned long start_pfn, unsigned long nr_pages)
} }
/* /*
* Confirm all pages in a range [start, end) belong to the same zone. * Confirm all pages in a range [start, end) belong to the same zone (skipping
* When true, return its valid [start, end). * memory holes). When true, return the zone.
*/ */
int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn, struct zone *test_pages_in_a_zone(unsigned long start_pfn,
unsigned long *valid_start, unsigned long *valid_end) unsigned long end_pfn)
{ {
unsigned long pfn, sec_end_pfn; unsigned long pfn, sec_end_pfn;
unsigned long start, end;
struct zone *zone = NULL; struct zone *zone = NULL;
struct page *page; struct page *page;
int i; int i;
...@@ -1200,24 +1199,15 @@ int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn, ...@@ -1200,24 +1199,15 @@ int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn,
continue; continue;
/* Check if we got outside of the zone */ /* Check if we got outside of the zone */
if (zone && !zone_spans_pfn(zone, pfn + i)) if (zone && !zone_spans_pfn(zone, pfn + i))
return 0; return NULL;
page = pfn_to_page(pfn + i); page = pfn_to_page(pfn + i);
if (zone && page_zone(page) != zone) if (zone && page_zone(page) != zone)
return 0; return NULL;
if (!zone)
start = pfn + i;
zone = page_zone(page); zone = page_zone(page);
end = pfn + MAX_ORDER_NR_PAGES;
} }
} }
if (zone) { return zone;
*valid_start = start;
*valid_end = min(end, end_pfn);
return 1;
} else {
return 0;
}
} }
/* /*
...@@ -1462,7 +1452,6 @@ static int __ref __offline_pages(unsigned long start_pfn, ...@@ -1462,7 +1452,6 @@ static int __ref __offline_pages(unsigned long start_pfn,
unsigned long offlined_pages = 0; unsigned long offlined_pages = 0;
int ret, node, nr_isolate_pageblock; int ret, node, nr_isolate_pageblock;
unsigned long flags; unsigned long flags;
unsigned long valid_start, valid_end;
struct zone *zone; struct zone *zone;
struct memory_notify arg; struct memory_notify arg;
char *reason; char *reason;
...@@ -1487,14 +1476,12 @@ static int __ref __offline_pages(unsigned long start_pfn, ...@@ -1487,14 +1476,12 @@ static int __ref __offline_pages(unsigned long start_pfn,
/* This makes hotplug much easier...and readable. /* This makes hotplug much easier...and readable.
we assume this for now. .*/ we assume this for now. .*/
if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start, zone = test_pages_in_a_zone(start_pfn, end_pfn);
&valid_end)) { if (!zone) {
ret = -EINVAL; ret = -EINVAL;
reason = "multizone range"; reason = "multizone range";
goto failed_removal; goto failed_removal;
} }
zone = page_zone(pfn_to_page(valid_start));
node = zone_to_nid(zone); node = zone_to_nid(zone);
/* set above range as isolated */ /* set above range as isolated */
......
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