diff options
-rw-r--r-- | mm/compaction.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/mm/compaction.c b/mm/compaction.c index 37f976287068..627dc2e4320f 100644 --- a/mm/compaction.c +++ b/mm/compaction.c | |||
@@ -671,16 +671,20 @@ static void isolate_freepages(struct zone *zone, | |||
671 | struct compact_control *cc) | 671 | struct compact_control *cc) |
672 | { | 672 | { |
673 | struct page *page; | 673 | struct page *page; |
674 | unsigned long high_pfn, low_pfn, pfn, z_end_pfn, end_pfn; | 674 | unsigned long high_pfn, low_pfn, pfn, z_end_pfn; |
675 | int nr_freepages = cc->nr_freepages; | 675 | int nr_freepages = cc->nr_freepages; |
676 | struct list_head *freelist = &cc->freepages; | 676 | struct list_head *freelist = &cc->freepages; |
677 | 677 | ||
678 | /* | 678 | /* |
679 | * Initialise the free scanner. The starting point is where we last | 679 | * Initialise the free scanner. The starting point is where we last |
680 | * scanned from (or the end of the zone if starting). The low point | 680 | * successfully isolated from, zone-cached value, or the end of the |
681 | * is the end of the pageblock the migration scanner is using. | 681 | * zone when isolating for the first time. We need this aligned to |
682 | * the pageblock boundary, because we do pfn -= pageblock_nr_pages | ||
683 | * in the for loop. | ||
684 | * The low boundary is the end of the pageblock the migration scanner | ||
685 | * is using. | ||
682 | */ | 686 | */ |
683 | pfn = cc->free_pfn; | 687 | pfn = cc->free_pfn & ~(pageblock_nr_pages-1); |
684 | low_pfn = ALIGN(cc->migrate_pfn + 1, pageblock_nr_pages); | 688 | low_pfn = ALIGN(cc->migrate_pfn + 1, pageblock_nr_pages); |
685 | 689 | ||
686 | /* | 690 | /* |
@@ -700,6 +704,7 @@ static void isolate_freepages(struct zone *zone, | |||
700 | for (; pfn >= low_pfn && cc->nr_migratepages > nr_freepages; | 704 | for (; pfn >= low_pfn && cc->nr_migratepages > nr_freepages; |
701 | pfn -= pageblock_nr_pages) { | 705 | pfn -= pageblock_nr_pages) { |
702 | unsigned long isolated; | 706 | unsigned long isolated; |
707 | unsigned long end_pfn; | ||
703 | 708 | ||
704 | /* | 709 | /* |
705 | * This can iterate a massively long zone without finding any | 710 | * This can iterate a massively long zone without finding any |
@@ -734,13 +739,10 @@ static void isolate_freepages(struct zone *zone, | |||
734 | isolated = 0; | 739 | isolated = 0; |
735 | 740 | ||
736 | /* | 741 | /* |
737 | * As pfn may not start aligned, pfn+pageblock_nr_page | 742 | * Take care when isolating in last pageblock of a zone which |
738 | * may cross a MAX_ORDER_NR_PAGES boundary and miss | 743 | * ends in the middle of a pageblock. |
739 | * a pfn_valid check. Ensure isolate_freepages_block() | ||
740 | * only scans within a pageblock | ||
741 | */ | 744 | */ |
742 | end_pfn = ALIGN(pfn + 1, pageblock_nr_pages); | 745 | end_pfn = min(pfn + pageblock_nr_pages, z_end_pfn); |
743 | end_pfn = min(end_pfn, z_end_pfn); | ||
744 | isolated = isolate_freepages_block(cc, pfn, end_pfn, | 746 | isolated = isolate_freepages_block(cc, pfn, end_pfn, |
745 | freelist, false); | 747 | freelist, false); |
746 | nr_freepages += isolated; | 748 | nr_freepages += isolated; |