From: Zi Yan Date: Sat, 14 Nov 2020 06:51:43 +0000 (-0800) Subject: mm/compaction: stop isolation if too many pages are isolated and we have pages to... X-Git-Tag: v5.9.9~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4629e4e7e098af0ec9d98316636651f3a86ec32;p=thirdparty%2Fkernel%2Fstable.git mm/compaction: stop isolation if too many pages are isolated and we have pages to migrate commit d20bdd571ee5c9966191568527ecdb1bd4b52368 upstream. 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. [vbabka@suse.cz: changelog addition] Fixes: 1da2f328fa64 (“mm,thp,compaction,cma: allow THP migration for CMA allocations”) Suggested-by: Vlastimil Babka Signed-off-by: Zi Yan Signed-off-by: Andrew Morton Cc: Cc: Mel Gorman Cc: Michal Hocko Cc: Rik van Riel Cc: Yang Shi Link: https://lkml.kernel.org/r/20201030183809.3616803-2-zi.yan@sent.com Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/mm/compaction.c b/mm/compaction.c index dd99c416cc7a9..cc1a7f600a865 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -818,6 +818,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;