ANDROID: Fix CMA pages placement in correct pcp_list

Background:
Currently, CMA pages are placed at the default index, which
allows unmovable allocations to consume these CMA pages from
the default index. This misplacement leads to failures in
migrating pages when CMA requests memory, causing CMA allocation
failures. Ensure THP pages with migrate type MIGRATE_CMA are
placed in the correct pcp_list, specifically the MOVABLE list.

Page owner backtrace:
Page allocated via order 9, mask 0x52dc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_ZERO), pid 1, tgid 1 (swapper/0), ts 1065952310 ns
PFN 0x23d200 type Unmovable Block 4585 type CMA Flags 0x4000000000000040(head|zone=1|kasantag=0x0)
 post_alloc_hook+0x228/0x230
 prep_new_page+0x28/0x148
 get_page_from_freelist+0x19d0/0x1a38
 __alloc_pages_noprof+0x1b0/0x440
 ___kmalloc_large_node+0xb4/0x1ec
 __kmalloc_large_node_noprof+0x2c/0xec
 __kmalloc_node_noprof+0x39c/0x548
 __kvmalloc_node_noprof+0xd8/0x18c
 nf_ct_alloc_hashtable+0x64/0x108
 nf_nat_init+0x3c/0xf8
 do_one_initcall+0x150/0x3c0
 do_initcall_level+0xa4/0x15c
 do_initcalls+0x70/0xc0
 do_basic_setup+0x1c/0x28
 kernel_init_freeable+0xcc/0x130
 kernel_init+0x20/0x1ac

Fixes: 3f2cf700ae ("ANDROID: mm: add cma pcp list")
Bug: 418728342
Change-Id: I0e693d7e7f02a1f73a0edb11df37907c81008228
Signed-off-by: akash.tyagi <akash.tyagi@mediatek.com>
This commit is contained in:
akash.tyagi
2025-05-19 18:23:58 +05:30
committed by Juan Yescas
parent ae38a8a0e4
commit b93d53f5dd

View File

@@ -617,6 +617,9 @@ static inline unsigned int order_to_pindex(int migratetype, int order)
VM_BUG_ON(order != HPAGE_PMD_ORDER);
movable = migratetype == MIGRATE_MOVABLE;
#ifdef CONFIG_CMA
movable |= migratetype == MIGRATE_CMA;
#endif
return NR_LOWORDER_PCP_LISTS + movable;
}