From a8198d10622f1ee7343cb975838162ff18f8b1b3 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Wed, 20 Jan 2021 17:33:42 -0800 Subject: [PATCH] ANDROID: mm: use alloc_flags for cma first alloc policy rmqueue internal functions to allocate cma memory should use alloc_flags instead of gfp_flags because it's more restricted flags to be considered allocation context. Otherwise, we could allocate page from CMA area even though current context already disable cma memory allocation. For example, current allocation context is limited not to allocate the page from CMA area by PF_MEMALLOC_NOCMA to prevent longterm pin but it's ignored so the longterm pin page could be allocated from CMA area. Bug: 178019362 Signed-off-by: Minchan Kim Change-Id: I61bd4642c91ecd9153f6c59f89e296e8b515f1ad --- mm/page_alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d0d8e10d8525..026681880a1e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3424,7 +3424,7 @@ static struct page *__rmqueue_pcplist(struct zone *zone, int migratetype, do { /* First try to get CMA pages */ if (migratetype == MIGRATE_MOVABLE && - gfp_flags & __GFP_CMA) { + alloc_flags & ALLOC_CMA) { list = get_populated_pcp_list(zone, 0, pcp, get_cma_migrate_type(), alloc_flags); } @@ -3509,7 +3509,8 @@ struct page *rmqueue(struct zone *preferred_zone, trace_mm_page_alloc_zone_locked(page, order, migratetype); } if (!page) { - if (gfp_flags & __GFP_CMA && migratetype == MIGRATE_MOVABLE) + if (migratetype == MIGRATE_MOVABLE && + alloc_flags & ALLOC_CMA) page = __rmqueue_cma(zone, order, migratetype, alloc_flags); if (!page)