mm/page_alloc: don't use PCP list for THP-sized allocations when using PF_MEMALLOC_PIN

Upstream: no

In the past, movable allocations could be disallowed from CMA through
PF_MEMALLOC_PIN. However, since commit 5d0a661d80 ("mm/page_alloc: use
only one PCP list for THP-sized allocations"), THP-sized pages of
different types are put into one PCP list. When allocate a THP with
PF_MEMALLOC_PIN, it would accidentally get a CMA page from PCP list,
which will cause the program to not run correctly. So, PCP list can't
be used for THP-sized allocations when using PF_MEMALLOC_PIN.

Fixes: 5d0a661d80 ("mm/page_alloc: use only one PCP list for THP-sized allocations")
Signed-off-by: yangge <yangge@hygon.cn>
Signed-off-by: hanliyang <hanliyang@hygon.cn>
This commit is contained in:
yangge 2024-03-22 08:32:28 -04:00 committed by hanliyang
parent d0eb7cacd6
commit 05848df6e8
1 changed files with 10 additions and 0 deletions

View File

@ -2774,10 +2774,20 @@ struct page *rmqueue(struct zone *preferred_zone,
WARN_ON_ONCE((gfp_flags & __GFP_NOFAIL) && (order > 1));
if (likely(pcp_allowed_order(order))) {
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
if (!IS_ENABLED(CONFIG_CMA) || alloc_flags & ALLOC_CMA ||
order != pageblock_order) {
page = rmqueue_pcplist(preferred_zone, zone, order,
migratetype, alloc_flags);
if (likely(page))
goto out;
}
#else
page = rmqueue_pcplist(preferred_zone, zone, order,
migratetype, alloc_flags);
if (likely(page))
goto out;
#endif
}
page = rmqueue_buddy(preferred_zone, zone, order, alloc_flags,