aboutsummaryrefslogtreecommitdiffstats
path: root/mm/compaction.c
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2013-02-22 19:32:25 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-23 20:50:10 -0500
commita9aacbccf3145355190d87f0df1731fb84fdd8c8 (patch)
tree52ac31c9be66f8114b3bff314fdc0802fce98f83 /mm/compaction.c
parent62b726c1b3cde6ab49304e8c1af41950ed855c3c (diff)
mm: compaction: do not accidentally skip pageblocks in the migrate scanner
Compaction uses the ALIGN macro incorrectly with the migrate scanner by adding pageblock_nr_pages to a PFN. It happened to work when initially implemented as the starting PFN was also aligned but with caching restarts and isolating in smaller chunks this is no longer always true. The impact is that the migrate scanner scans outside its current pageblock. As pfn_valid() is still checked properly it does not cause any failure and the impact of the bug is that in some cases it will scan more than necessary when it crosses a page boundary but by no more than COMPACT_CLUSTER_MAX. It is highly unlikely this is even measurable but it's still wrong so this patch addresses the problem. Signed-off-by: Mel Gorman <mgorman@suse.de> Reviewed-by: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/compaction.c')
-rw-r--r--mm/compaction.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/mm/compaction.c b/mm/compaction.c
index c62bd063d766..0d0248db36d8 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -611,8 +611,7 @@ check_compact_cluster:
611 continue; 611 continue;
612 612
613next_pageblock: 613next_pageblock:
614 low_pfn += pageblock_nr_pages; 614 low_pfn = ALIGN(low_pfn + 1, pageblock_nr_pages) - 1;
615 low_pfn = ALIGN(low_pfn, pageblock_nr_pages) - 1;
616 last_pageblock_nr = pageblock_nr; 615 last_pageblock_nr = pageblock_nr;
617 } 616 }
618 617
@@ -795,7 +794,7 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
795 low_pfn = max(cc->migrate_pfn, zone->zone_start_pfn); 794 low_pfn = max(cc->migrate_pfn, zone->zone_start_pfn);
796 795
797 /* Only scan within a pageblock boundary */ 796 /* Only scan within a pageblock boundary */
798 end_pfn = ALIGN(low_pfn + pageblock_nr_pages, pageblock_nr_pages); 797 end_pfn = ALIGN(low_pfn + 1, pageblock_nr_pages);
799 798
800 /* Do not cross the free scanner or scan within a memory hole */ 799 /* Do not cross the free scanner or scan within a memory hole */
801 if (end_pfn > cc->free_pfn || !pfn_valid(low_pfn)) { 800 if (end_pfn > cc->free_pfn || !pfn_valid(low_pfn)) {