From: Qi Zheng <qi.zheng@linux.dev>
To: "Oscar Salvador (SUSE)" <osalvador@kernel.org>
Cc: muchun.song@linux.dev, osalvador@suse.de, david@kernel.org,
akpm@linux-foundation.org, azpijr@gmail.com,
lance.yang@linux.dev, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, stable@vger.kernel.org,
Qi Zheng <zhengqi.arch@bytedance.com>
Subject: Re: [PATCH v3 3/3] mm: hugetlb: fix GFP mask propagation to CMA
Date: Mon, 9 Nov 2026 11:10:56 +0800 [thread overview]
Message-ID: <c266ecbe-167e-4a99-9e40-ea4740eda7c8@linux.dev> (raw)
In-Reply-To: <au9ZvQObSY3y2s2c@localhost.localdomain>
On 11/8/26 1:02 AM, Oscar Salvador (SUSE) wrote:
> On Sat, Nov 07, 2026 at 06:30:47PM +0800, Qi Zheng wrote:
>> From: Qi Zheng <zhengqi.arch@bytedance.com>
>>
>> cma_alloc_frozen_compound() uses GFP_KERNEL, allowing direct reclaim
>> during the first MPOL_PREFERRED_MANY allocation attempt even though
>> the caller clears __GFP_DIRECT_RECLAIM.
>>
>> Pass the caller's GFP mask through the helper so CMA respects its
>> reclaim constraints when trying the preferred nodes.
>>
>> Fixes: 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
>> Acked-by: Muchun Song <muchun.song@linux.dev>
>> Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
>
> Reviewed-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
>
> A comment below:
>
>> --- a/mm/cma.c
>> +++ b/mm/cma.c
>> @@ -933,9 +933,10 @@ struct page *cma_alloc_frozen(struct cma *cma, unsigned long count,
>> return __cma_alloc_frozen(cma, count, align, gfp);
>> }
>>
>> -struct page *cma_alloc_frozen_compound(struct cma *cma, unsigned int order)
>> +struct page *cma_alloc_frozen_compound(struct cma *cma, unsigned int order, gfp_t gfp)
>> {
>> - gfp_t gfp = GFP_KERNEL | __GFP_COMP | __GFP_NOWARN;
>> + if (WARN_ON_ONCE(!(gfp & __GFP_COMP)))
>> + return NULL;
>
> I think this needs a comment explaining why we are checking for __GFP_COMP,
> because it might not be obvious to the casual reader.
> Something like:
>
> "The only caller of cma_alloc_frozen_compound() is hugetlb, and hugetlb
> constructs its gfp mask via htlb_alloc_mask(), which already sets
> __GFP_COMP. Check here for usecases bypassing htlb_alloc_mask()."
OK, will add this comment.
Thanks,
Qi
>
>
> Maybe in the future we do have some other users of this function which are outside
> of the hugetlb realm, but if we are propagating the gfp mask down the chain to this
> point, we do have to check that those users are also setting __GFP_COMP.
>
>
>
prev parent reply other threads:[~2026-11-09 3:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 10:30 [PATCH v3 0/3] mm: hugetlb: fix CMA-related issues Qi Zheng
2026-11-07 10:30 ` [PATCH v3 1/3] x86: hugetlb: disable default CMA reservations on 32-bit kernel Qi Zheng
2026-11-07 10:30 ` [PATCH v3 2/3] mm: gup: allow long-term pins of CMA-allocated HugeTLB folios Qi Zheng
2026-11-07 17:58 ` David Hildenbrand (Arm)
2026-11-09 3:10 ` Qi Zheng
2026-11-07 10:30 ` [PATCH v3 3/3] mm: hugetlb: fix GFP mask propagation to CMA Qi Zheng
2026-11-07 17:02 ` Oscar Salvador (SUSE)
2026-11-09 3:10 ` Qi Zheng [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c266ecbe-167e-4a99-9e40-ea4740eda7c8@linux.dev \
--to=qi.zheng@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=azpijr@gmail.com \
--cc=david@kernel.org \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@kernel.org \
--cc=osalvador@suse.de \
--cc=stable@vger.kernel.org \
--cc=zhengqi.arch@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®