Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Qi Zheng <qi.zheng@linux.dev>
To: Lance Yang <lance.yang@linux.dev>
Cc: muchun.song@linux.dev, osalvador@suse.de, david@kernel.org,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, zhengqi.arch@bytedance.com
Subject: Re: [PATCH 5/5] mm: hugetlb: enable CMA allocation for PMD-sized pages
Date: Tue, 20 Oct 2026 18:23:49 +0800	[thread overview]
Message-ID: <04c89538-28c8-4d03-92c1-08d854a46ac4@linux.dev> (raw)
In-Reply-To: <20261020091653.14959-1-lance.yang@linux.dev>

Hi Lance,

On 10/20/26 5:16 PM, Lance Yang wrote:
> 
> On Fri, Oct 16, 2026 at 06:07:36PM +0800, Qi Zheng wrote:
>> From: Qi Zheng <zhengqi.arch@bytedance.com>
> [...]
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index 218fbaee6f7e5..8c00fd9d0658d 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -1362,18 +1362,8 @@ static struct folio *dequeue_hugetlb_folio(struct hstate *h, gfp_t gfp_mask,
>> static struct folio *alloc_gigantic_frozen_folio(int order, gfp_t gfp_mask,
>> 		int nid, nodemask_t *nodemask)
>> {
>> -	struct folio *folio;
>> -
>> -	folio = hugetlb_cma_alloc_frozen_folio(order, gfp_mask, nid, nodemask);
>> -	if (folio)
>> -		return folio;
>> -
>> -	if (hugetlb_cma_exclusive_alloc(order))
>> -		return NULL;
>> -
>> -	folio = (struct folio *)alloc_contig_frozen_pages(1 << order, gfp_mask,
>> -							  nid, nodemask);
>> -	return folio;
>> +	return (struct folio *)alloc_contig_frozen_pages(1 << order, gfp_mask,
>> +							 nid, nodemask);
>> }
>> #else /* !CONFIG_ARCH_HAS_GIGANTIC_PAGE || !CONFIG_CONTIG_ALLOC */
>> static struct folio *alloc_gigantic_frozen_folio(int order, gfp_t gfp_mask, int nid,
>> @@ -1849,11 +1839,18 @@ static struct folio *only_alloc_fresh_hugetlb_folio(struct hstate *h,
>> 	if (nid == NUMA_NO_NODE)
>> 		nid = numa_mem_id();
>>
>> -	if (order_is_gigantic(order))
>> -		folio = alloc_gigantic_frozen_folio(order, gfp_mask, nid, nmask);
>> -	else
>> -		folio = alloc_buddy_frozen_folio(order, gfp_mask, nid, nmask,
>> -						 node_alloc_noretry);
>> +	folio = hugetlb_cma_alloc_frozen_folio(order, gfp_mask, nid, nmask);
>> +	if (!folio) {
> 
> Emm ... what about PF_MEMALLOC_PIN here?
> 
> If a FOLL_LONGTERM migration out of CMA needs a fresh hugetlb folio,
> this can allocate another CMA folio as the target.
> 
> With HVO disabled, the old folio is freed back to CMA and can be picked
> again again again.
> 
> I guess we'd keep migrating between CMA folios without ever completing
> the pin ... even if pinnable buddy memory is available, no?

Yes, you are right. A fresh migration target can come from CMA again,
causing repeated migration without completing the pin, even when
pinnable buddy memory is available.

The same missing PF_MEMALLOC_PIN check also affects 1 GiB CMA
allocations, so I had planned to fix it separately.

Thanks,
Qi

> 
> [...]
> 
> Cheers, Lance



  reply	other threads:[~2026-10-20 10:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 10:07 [PATCH 0/5] mm: hugetlb: add CMA support for PMD-sized page Qi Zheng
2026-10-16 10:07 ` [PATCH 1/5] mm: hugetlb: add explicit page size to hugetlb_cma Qi Zheng
2026-10-17 17:31   ` Jose A. Perez de Azpillaga
2026-10-16 10:07 ` [PATCH 2/5] mm: hugetlb: group CMA pool and reservation state Qi Zheng
2026-10-17 17:53   ` Jose A. Perez de Azpillaga
2026-10-16 10:07 ` [PATCH 3/5] mm: hugetlb: track CMA reservations by page order Qi Zheng
2026-10-17 18:41   ` Jose A. Perez de Azpillaga
2026-10-19  7:10     ` Qi Zheng
2026-10-16 10:07 ` [PATCH 4/5] mm: hugetlb: avoid recursive CMA allocation during migration Qi Zheng
2026-10-17 18:54   ` Jose A. Perez de Azpillaga
2026-10-19  7:17     ` Qi Zheng
2026-10-16 10:07 ` [PATCH 5/5] mm: hugetlb: enable CMA allocation for PMD-sized pages Qi Zheng
2026-10-17 19:07   ` Jose A. Perez de Azpillaga
2026-10-19  7:32     ` Qi Zheng
2026-10-20  9:16   ` Lance Yang
2026-10-20 10:23     ` Qi Zheng [this message]
2026-10-19  6:50 ` [PATCH 0/5] mm: hugetlb: add CMA support for PMD-sized page Muchun Song
2026-10-19  7:37   ` Qi Zheng
2026-10-19  7:50     ` Muchun Song
2026-10-19  8:20       ` Jose A. Perez de Azpillaga
2026-10-19  8:43         ` Muchun Song
2026-10-19  9:17           ` Jose A. Perez de Azpillaga
2026-10-19 12:18             ` David Hildenbrand (Arm)
2026-10-20  7:46               ` Qi Zheng

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=04c89538-28c8-4d03-92c1-08d854a46ac4@linux.dev \
    --to=qi.zheng@linux.dev \
    --cc=akpm@linux-foundation.org \
    --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@suse.de \
    --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