mm: add & use zone_end_pfn() and zone_spans_pfn()
Add 2 helpers (zone_end_pfn() and zone_spans_pfn()) to reduce code duplication. This also switches to using them in compaction (where an additional variable needed to be renamed), page_alloc, vmstat, memory_hotplug, and kmemleak. Note that in compaction.c I avoid calling zone_end_pfn() repeatedly because I expect at some point the sycronization issues with start_pfn & spanned_pages will need fixing, either by actually using the seqlock or clever memory barrier usage. Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Cc: David Hansen <dave@linux.vnet.ibm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
9127ab4ff9
commit
108bcc96ef
@@ -299,7 +299,7 @@ static int __meminit move_pfn_range_left(struct zone *z1, struct zone *z2,
|
||||
pgdat_resize_lock(z1->zone_pgdat, &flags);
|
||||
|
||||
/* can't move pfns which are higher than @z2 */
|
||||
if (end_pfn > z2->zone_start_pfn + z2->spanned_pages)
|
||||
if (end_pfn > zone_end_pfn(z2))
|
||||
goto out_fail;
|
||||
/* the move out part mast at the left most of @z2 */
|
||||
if (start_pfn > z2->zone_start_pfn)
|
||||
@@ -315,7 +315,7 @@ static int __meminit move_pfn_range_left(struct zone *z1, struct zone *z2,
|
||||
z1_start_pfn = start_pfn;
|
||||
|
||||
resize_zone(z1, z1_start_pfn, end_pfn);
|
||||
resize_zone(z2, end_pfn, z2->zone_start_pfn + z2->spanned_pages);
|
||||
resize_zone(z2, end_pfn, zone_end_pfn(z2));
|
||||
|
||||
pgdat_resize_unlock(z1->zone_pgdat, &flags);
|
||||
|
||||
@@ -347,15 +347,15 @@ static int __meminit move_pfn_range_right(struct zone *z1, struct zone *z2,
|
||||
if (z1->zone_start_pfn > start_pfn)
|
||||
goto out_fail;
|
||||
/* the move out part mast at the right most of @z1 */
|
||||
if (z1->zone_start_pfn + z1->spanned_pages > end_pfn)
|
||||
if (zone_end_pfn(z1) > end_pfn)
|
||||
goto out_fail;
|
||||
/* must included/overlap */
|
||||
if (start_pfn >= z1->zone_start_pfn + z1->spanned_pages)
|
||||
if (start_pfn >= zone_end_pfn(z1))
|
||||
goto out_fail;
|
||||
|
||||
/* use end_pfn for z2's end_pfn if z2 is empty */
|
||||
if (z2->spanned_pages)
|
||||
z2_end_pfn = z2->zone_start_pfn + z2->spanned_pages;
|
||||
z2_end_pfn = zone_end_pfn(z2);
|
||||
else
|
||||
z2_end_pfn = end_pfn;
|
||||
|
||||
|
Reference in New Issue
Block a user