Commit 32c6be0f authored by Baolin Wang's avatar Baolin Wang Committed by Liu Shixin
Browse files

mm: compaction: limit the suitable target page order to be less than cc->order

mainline inclusion
from mainline-v6.9-rc1
commit 1883e8ac96ddd73a87db7f2f8c06111148a3db6f
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9CXS6
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1883e8ac96ddd73a87db7f2f8c06111148a3db6f

--------------------------------

It can not improve the fragmentation if we isolate the target free pages
exceeding cc->order, especially when the cc->order is less than
pageblock_order.  For example, suppose the pageblock_order is MAX_ORDER
(size is 4M) and cc->order is 2M THP size, we should not isolate other 2M
free pages to be the migration target, which can not improve the
fragmentation.

Moreover this is also applicable for large folio compaction.

Link: https://lkml.kernel.org/r/afcd9377351c259df7a25a388a4a0d5862b986f4.1705928395.git.baolin.wang@linux.alibaba.com


Signed-off-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: default avatarMel Gorman <mgorman@techsingularity.net>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent 2dbf3faf
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1347,12 +1347,14 @@ static bool suitable_migration_target(struct compact_control *cc,
{
	/* If the page is a large free page, then disallow migration */
	if (PageBuddy(page)) {
		int order = cc->order > 0 ? cc->order : pageblock_order;

		/*
		 * We are checking page_order without zone->lock taken. But
		 * the only small danger is that we skip a potentially suitable
		 * pageblock, so it's not worth to check order for valid range.
		 */
		if (buddy_order_unsafe(page) >= pageblock_order)
		if (buddy_order_unsafe(page) >= order)
			return false;
	}