When proactive compaction is triggered via compact_memory and mTHP always-enabled orders are configured, skip isolating folios whose order is >= the minimum always-enabled mTHP order. These folios already satisfy mTHP allocation requirements and migrating them is unnecessary overhead. Signed-off-by: Bo Zhang --- mm/compaction.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/compaction.c b/mm/compaction.c index a4f87232ad80..a15ed2576562 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -837,6 +837,12 @@ static bool skip_isolation_on_order(int order, int target_order) */ if (!is_via_compact_memory(target_order) && order >= target_order) return true; + + /* We are compacting for multi-size THP allocation */ + if (is_via_compact_memory(target_order) && order >= compact_hpage_order() && + READ_ONCE(huge_anon_orders_always)) + return true; + /* * We limit memory compaction to pageblocks and won't try * creating free blocks of memory that are larger than that. -- 2.34.1