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 <minchan@google.com>
Change-Id: I61bd4642c91ecd9153f6c59f89e296e8b515f1ad
This commit is contained in:
Minchan Kim 2021-01-20 17:33:42 -08:00
parent 4e1a8c589d
commit a8198d1062

View File

@ -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)