linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/page_alloc: skip THP-sized PCP list when allocating non-CMA THP-sized page
@ 2024-06-04  9:14 yangge1116
  2024-06-04 12:01 ` Baolin Wang
  2024-06-17 10:26 ` Barry Song
  0 siblings, 2 replies; 23+ messages in thread
From: yangge1116 @ 2024-06-04  9:14 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, baolin.wang, liuzixing, yangge

From: yangge <yangge1116@126.com>

Since commit 5d0a661d808f ("mm/page_alloc: use only one PCP list for
THP-sized allocations") no longer differentiates the migration type
of pages in THP-sized PCP list, it's possible to get a CMA page from
the list, in some cases, it's not acceptable, for example, allocating
a non-CMA page with PF_MEMALLOC_PIN flag returns a CMA page.

The patch forbids allocating non-CMA THP-sized page from THP-sized
PCP list to avoid the issue above.

Fixes: 5d0a661d808f ("mm/page_alloc: use only one PCP list for THP-sized allocations")
Signed-off-by: yangge <yangge1116@126.com>
---
 mm/page_alloc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2e22ce5..0bdf471 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2987,10 +2987,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 != HPAGE_PMD_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,
-- 
2.7.4



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2024-06-19  8:35 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-04  9:14 [PATCH] mm/page_alloc: skip THP-sized PCP list when allocating non-CMA THP-sized page yangge1116
2024-06-04 12:01 ` Baolin Wang
2024-06-04 12:36   ` yangge1116
2024-06-06  3:06     ` Baolin Wang
2024-06-06  9:10       ` yangge1116
2024-06-17 10:43       ` Barry Song
2024-06-17 11:36         ` Baolin Wang
2024-06-17 11:55           ` Barry Song
2024-06-18  3:31             ` yangge1116
2024-06-17 10:26 ` Barry Song
2024-06-17 12:47   ` yangge1116
2024-06-18  1:34     ` yangge1116
2024-06-18  1:55       ` Barry Song
2024-06-18  3:31         ` yangge1116
2024-06-18  4:10           ` Barry Song
2024-06-18  5:49             ` yangge1116
2024-06-18  6:55             ` yangge1116
2024-06-18  6:58               ` Barry Song
2024-06-18  7:51                 ` yangge1116
2024-06-19  5:34                   ` Ge Yang
2024-06-19  8:20                     ` Barry Song
2024-06-19  8:35                       ` Ge Yang
2024-06-18  3:40         ` yangge1116

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox