From: Baolin Wang Date: Thu, 25 May 2023 12:54:01 +0000 (+0800) Subject: mm: compaction: skip fast freepages isolation if enough freepages are isolated X-Git-Tag: v6.6.7~2549^2~254 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a8d13355c660255266ece529e81e6cb26754941a;p=platform%2Fkernel%2Flinux-starfive.git mm: compaction: skip fast freepages isolation if enough freepages are isolated I've observed that fast isolation often isolates more pages than cc->migratepages, and the excess freepages will be released back to the buddy system. So skip fast freepages isolation if enough freepages are isolated to save some CPU cycles. Link: https://lkml.kernel.org/r/f39c2c07f2dba2732fd9c0843572e5bef96f7f67.1685018752.git.baolin.wang@linux.alibaba.com Signed-off-by: Baolin Wang Acked-by: Vlastimil Babka Cc: Mel Gorman Cc: Johannes Weiner Signed-off-by: Andrew Morton --- diff --git a/mm/compaction.c b/mm/compaction.c index ce6293b..767b081 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1528,6 +1528,10 @@ static void fast_isolate_freepages(struct compact_control *cc) spin_unlock_irqrestore(&cc->zone->lock, flags); + /* Skip fast search if enough freepages isolated */ + if (cc->nr_freepages >= cc->nr_migratepages) + break; + /* * Smaller scan on next order so the total scan is related * to freelist_scan_limit.