aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZi Yan <[email protected]>2020-11-13 22:51:43 -0800
committerLinus Torvalds <[email protected]>2020-11-14 11:26:03 -0800
commitd20bdd571ee5c9966191568527ecdb1bd4b52368 (patch)
treed34960496812c3fee82d7fd56136ebe5638ac5a6
parent38935861d85a4d9a353d1dd5a156c97700e2765d (diff)
mm/compaction: stop isolation if too many pages are isolated and we have pages to migrate
In isolate_migratepages_block, if we have too many isolated pages and nr_migratepages is not zero, we should try to migrate what we have without wasting time on isolating. In theory it's possible that multiple parallel compactions will cause too_many_isolated() to become true even if each has isolated less than COMPACT_CLUSTER_MAX, and loop forever in the while loop. Bailing immediately prevents that. [[email protected]: changelog addition] Fixes: 1da2f328fa64 (“mm,thp,compaction,cma: allow THP migration for CMA allocations”) Suggested-by: Vlastimil Babka <[email protected]> Signed-off-by: Zi Yan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Yang Shi <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--mm/compaction.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mm/compaction.c b/mm/compaction.c
index d549a4521edf..13cb7a961b31 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -817,6 +817,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
* delay for some time until fewer pages are isolated
*/
while (unlikely(too_many_isolated(pgdat))) {
+ /* stop isolation if there are still pages not migrated */
+ if (cc->nr_migratepages)
+ return 0;
+
/* async migration should just abort */
if (cc->mode == MIGRATE_ASYNC)
return 0;