Skip to content

Commit 8854c55

Browse files
gormanmtorvalds
authored andcommitted
mm, compaction: keep cached migration PFNs synced for unusable pageblocks
Migrate has separate cached PFNs for ASYNC and SYNC* migration on the basis that some migrations will fail in ASYNC mode. However, if the cached PFNs match at the start of scanning and pageblocks are skipped due to having no isolation candidates, then the sync state does not matter. This patch keeps matching cached PFNs in sync until a pageblock with isolation candidates is found. The actual benefit is marginal given that the sync scanner following the async scanner will often skip a number of pageblocks but it's useless work. Any benefit depends heavily on whether the scanners restarted recently. Link: http://lkml.kernel.org/r/20190118175136.31341-16-mgorman@techsingularity.net Signed-off-by: Mel Gorman <mgorman@techsingularity.net> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Dan Carpenter <dan.carpenter@oracle.com> Cc: David Rientjes <rientjes@google.com> Cc: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9bebefd commit 8854c55

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

mm/compaction.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,7 @@ static enum compact_result compact_zone(struct compact_control *cc)
19711971
unsigned long end_pfn = zone_end_pfn(cc->zone);
19721972
unsigned long last_migrated_pfn;
19731973
const bool sync = cc->mode != MIGRATE_ASYNC;
1974+
bool update_cached;
19741975

19751976
cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask);
19761977
ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags,
@@ -2018,6 +2019,17 @@ static enum compact_result compact_zone(struct compact_control *cc)
20182019

20192020
last_migrated_pfn = 0;
20202021

2022+
/*
2023+
* Migrate has separate cached PFNs for ASYNC and SYNC* migration on
2024+
* the basis that some migrations will fail in ASYNC mode. However,
2025+
* if the cached PFNs match and pageblocks are skipped due to having
2026+
* no isolation candidates, then the sync state does not matter.
2027+
* Until a pageblock with isolation candidates is found, keep the
2028+
* cached PFNs in sync to avoid revisiting the same blocks.
2029+
*/
2030+
update_cached = !sync &&
2031+
cc->zone->compact_cached_migrate_pfn[0] == cc->zone->compact_cached_migrate_pfn[1];
2032+
20212033
trace_mm_compaction_begin(start_pfn, cc->migrate_pfn,
20222034
cc->free_pfn, end_pfn, sync);
20232035

@@ -2049,13 +2061,19 @@ static enum compact_result compact_zone(struct compact_control *cc)
20492061
last_migrated_pfn = 0;
20502062
goto out;
20512063
case ISOLATE_NONE:
2064+
if (update_cached) {
2065+
cc->zone->compact_cached_migrate_pfn[1] =
2066+
cc->zone->compact_cached_migrate_pfn[0];
2067+
}
2068+
20522069
/*
20532070
* We haven't isolated and migrated anything, but
20542071
* there might still be unflushed migrations from
20552072
* previous cc->order aligned block.
20562073
*/
20572074
goto check_drain;
20582075
case ISOLATE_SUCCESS:
2076+
update_cached = false;
20592077
last_migrated_pfn = start_pfn;
20602078
;
20612079
}

0 commit comments

Comments
 (0)