Re: [PATCH v2 3/4] mm: hugetlb: fix GFP mask propagation to CMA
From: Qi Zheng
Date: Fri Nov 06 2026 - 01:18:19 EST
On 11/6/26 1:50 PM, Oscar Salvador (SUSE) wrote:
On Fri, Nov 06, 2026 at 10:43:53AM +0800, Qi Zheng wrote:
I'd still prefer to keep __GFP_COMP so that
cma_alloc_frozen_compound() itself guarantees compound allocation,
without requiring callers to supply the flag.
Well, but aren't all callers hugetlb? And we already do supply __GFP_COMP there
for evident reasons.
And should that not be the case, and you want to catch someone who went rogue,
I would just place a WARN_ON_ONCE to catch it here, so we know who is not following
the rules.
Makes sense?
Ah, make sense.
How about this:
diff --git a/mm/cma.c b/mm/cma.c
index 876635a56180e..45017ed876f76 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -935,7 +935,8 @@ struct page *cma_alloc_frozen(struct cma *cma, unsigned long count,
struct page *cma_alloc_frozen_compound(struct cma *cma, unsigned int order, gfp_t gfp)
{
- gfp |= __GFP_COMP | __GFP_NOWARN;
+ if (WARN_ON_ONCE(!(gfp & __GFP_COMP)))
+ return NULL;
return __cma_alloc_frozen(cma, 1 << order, order, gfp);
}