Skip to content

Commit

Permalink
mm/compaction: avoid rescanning pageblocks in isolate_freepages
Browse files Browse the repository at this point in the history
The compaction free scanner in isolate_freepages() currently remembers PFN
of the highest pageblock where it successfully isolates, to be used as the
starting pageblock for the next invocation.  The rationale behind this is
that page migration might return free pages to the allocator when
migration fails and we don't want to skip them if the compaction
continues.

Since migration now returns free pages back to compaction code where they
can be reused, this is no longer a concern.  This patch changes
isolate_freepages() so that the PFN for restarting is updated with each
pageblock where isolation is attempted.  Using stress-highalloc from
mmtests, this resulted in 10% reduction of the pages scanned by the free
scanner.

Note that the somewhat similar functionality that records highest
successful pageblock in zone->compact_cached_free_pfn, remains unchanged. 
This cache is used when the whole compaction is restarted, not for
multiple invocations of the free scanner during single compaction.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Rik van Riel <riel@redhat.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
tehcaster authored and hnaz committed May 17, 2014
1 parent e3b9196 commit a290e23
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions mm/compaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,12 +705,6 @@ static void isolate_freepages(struct zone *zone,
zone_end_pfn(zone));
low_pfn = ALIGN(cc->migrate_pfn + 1, pageblock_nr_pages);

/*
* If no pages are isolated, the block_start_pfn < low_pfn check
* will kick in.
*/
next_free_pfn = 0;

/*
* Isolate free pages until enough are available to migrate the
* pages on cc->migratepages. We stop searching if the migrate
Expand Down Expand Up @@ -751,19 +745,19 @@ static void isolate_freepages(struct zone *zone,
continue;

/* Found a block suitable for isolating free pages from */
next_free_pfn = block_start_pfn;
isolated = isolate_freepages_block(cc, block_start_pfn,
block_end_pfn, freelist, false);
nr_freepages += isolated;

/*
* Record the highest PFN we isolated pages from. When next
* looking for free pages, the search will restart here as
* page migration may have returned some pages to the allocator
* Set a flag that we successfully isolated in this pageblock.
* In the next loop iteration, zone->compact_cached_free_pfn
* will not be updated and thus it will effectively contain the
* highest pageblock we isolated pages from.
*/
if (isolated && next_free_pfn == 0) {
if (isolated)
cc->finished_update_free = true;
next_free_pfn = block_start_pfn;
}
}

/* split_free_page does not map the pages */
Expand Down

0 comments on commit a290e23

Please sign in to comment.