summaryrefslogtreecommitdiffstats
path: root/mm/compaction.c
diff options
context:
space:
mode:
authorMel Gorman <mgorman@techsingularity.net>2019-03-05 18:45:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-06 00:07:17 -0500
commit8854c55f54bcc104e3adae42abe16948286ec75c (patch)
tree0a7ea9d9c74534019d11145c8b5b303823882221 /mm/compaction.c
parent9bebefd59084af7c75b66eeee241bf0777f39b88 (diff)
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>
Diffstat (limited to 'mm/compaction.c')
-rw-r--r--mm/compaction.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/mm/compaction.c b/mm/compaction.c
index e609415059e8..78ae182aaf34 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1971,6 +1971,7 @@ static enum compact_result compact_zone(struct compact_control *cc)
1971 unsigned long end_pfn = zone_end_pfn(cc->zone); 1971 unsigned long end_pfn = zone_end_pfn(cc->zone);
1972 unsigned long last_migrated_pfn; 1972 unsigned long last_migrated_pfn;
1973 const bool sync = cc->mode != MIGRATE_ASYNC; 1973 const bool sync = cc->mode != MIGRATE_ASYNC;
1974 bool update_cached;
1974 1975
1975 cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask); 1976 cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask);
1976 ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags, 1977 ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags,
@@ -2018,6 +2019,17 @@ static enum compact_result compact_zone(struct compact_control *cc)
2018 2019
2019 last_migrated_pfn = 0; 2020 last_migrated_pfn = 0;
2020 2021
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
2021 trace_mm_compaction_begin(start_pfn, cc->migrate_pfn, 2033 trace_mm_compaction_begin(start_pfn, cc->migrate_pfn,
2022 cc->free_pfn, end_pfn, sync); 2034 cc->free_pfn, end_pfn, sync);
2023 2035
@@ -2049,6 +2061,11 @@ static enum compact_result compact_zone(struct compact_control *cc)
2049 last_migrated_pfn = 0; 2061 last_migrated_pfn = 0;
2050 goto out; 2062 goto out;
2051 case ISOLATE_NONE: 2063 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
2052 /* 2069 /*
2053 * We haven't isolated and migrated anything, but 2070 * We haven't isolated and migrated anything, but
2054 * there might still be unflushed migrations from 2071 * there might still be unflushed migrations from
@@ -2056,6 +2073,7 @@ static enum compact_result compact_zone(struct compact_control *cc)
2056 */ 2073 */
2057 goto check_drain; 2074 goto check_drain;
2058 case ISOLATE_SUCCESS: 2075 case ISOLATE_SUCCESS:
2076 update_cached = false;
2059 last_migrated_pfn = start_pfn; 2077 last_migrated_pfn = start_pfn;
2060 ; 2078 ;
2061 } 2079 }