Metadata pages can have special requirements and can only be allocated if an architecture allows it. In the direct compaction case, the source pages that will be migrated will then be used to satisfy the allocation request that triggered the compaction. Make sure that the allocation allows the use of metadata pages when considering them for migration. When a page is freed during direct compaction, the page allocator will try to use that page to satisfy the allocation request. Don't capture a metadata page in this case, even if the allocation request would allow it, to increase the chances that the page is free when it needs to be taken from the allocator to store metadata. Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx> --- mm/compaction.c | 10 ++++++++-- mm/page_alloc.c | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index f132c02b0655..a29db409c5cc 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -23,6 +23,7 @@ #include <linux/freezer.h> #include <linux/page_owner.h> #include <linux/psi.h> +#include <asm/memory_metadata.h> #include "internal.h" #ifdef CONFIG_COMPACTION @@ -1307,11 +1308,16 @@ static bool suitable_migration_source(struct compact_control *cc, if (pageblock_skip_persistent(page)) return false; + block_mt = get_pageblock_migratetype(page); + + if (metadata_storage_enabled() && cc->direct_compaction && + is_migrate_metadata(block_mt) && + !(cc->alloc_flags & ALLOC_FROM_METADATA)) + return false; + if ((cc->mode != MIGRATE_ASYNC) || !cc->direct_compaction) return true; - block_mt = get_pageblock_migratetype(page); - if (cc->migratetype == MIGRATE_MOVABLE) return is_migrate_movable(block_mt); else diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bbb49b489230..011645d07ce9 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -654,6 +654,7 @@ compaction_capture(struct capture_control *capc, struct page *page, /* Do not accidentally pollute CMA or isolated regions*/ if (is_migrate_cma(migratetype) || + is_migrate_metadata(migratetype) || is_migrate_isolate(migratetype)) return false; -- 2.41.0