From: "Qi Zheng" <zhengqi.arch@bytedance.com>
To: "Jose A. Perez de Azpillaga" <azpijr@gmail.com>,
"Qi Zheng" <qi.zheng@linux.dev>, <muchun.song@linux.dev>,
<osalvador@suse.de>, <david@kernel.org>,
<akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 5/5] mm: hugetlb: enable CMA allocation for PMD-sized pages
Date: Mon, 19 Oct 2026 15:32:13 +0800 [thread overview]
Message-ID: <b8d87b71-c5ca-43d8-8050-72fc14802ae1@bytedance.com> (raw)
In-Reply-To: <ddb1e84f-2cfc-4a99-85c4-9a8c6415dbb1@gmail.com>
On 10/18/26 3:07 AM, Jose A. Perez de Azpillaga wrote:
> On 10/16/26 12:07 PM, Qi Zheng wrote:
>> From: Qi Zheng <zhengqi.arch@bytedance.com>
>>
>> Allow hugetlb_cma=<capacity>@<page-size> to select the architecture's PMD
>> size in addition to its existing CMA size. PMD pages are 2M on x86-64 and
>> 2M, 32M or 512M on arm64 with 4K, 16K or 64K base pages.
>>
>> Give PMD pages their own pool without changing the original pool's sharing
>> among other gigantic sizes. On arm64 with 4K base pages, 32M and 1G pages
>> continue to use the default 1G-aligned pool. Unsuffixed arguments and an
>> explicit default size still configure that same pool.
>>
>> PMD requests use only the PMD pool, even when their order is gigantic.
>> Other gigantic requests use only the original pool. Apply this mapping
>> consistently to allocation, CMA-only policy and boot-time accounting.
>>
>> Move CMA allocation into the common fresh HugeTLB allocation path so
>> non-gigantic pages can use CMA. Align reservations to both the selected
>> page size and CMA's minimum alignment, and use a bitmap granularity no
>> larger than the selected order. Keep the original CMA area names and give
>> PMD areas distinct names. Document the syntax and pool selection.
>>
>> Assisted-by: LLM
>> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
>
> [snip]
>
>> + folio = hugetlb_cma_alloc_frozen_folio(order, gfp_mask, nid, nmask);
>> + if (!folio) {
>
> boot-time hugepages= goes through here too, so hugepages=128 with
> hugetlb_cma=512M@2M already uses half of the pool at boot. would buddy
> first and cma as fallback make more sense for PMD?
That makes sense.
Buddy-first can reduce CMA migration and leave more CMA capacity
for later allocations.
I'll use buddy first and CMA as a fallback for non-gigantic PMD pages,
while keeping hugetlb_cma_only=1 restricted to CMA and preserving the
existing gigantic allocation path.
>
> [snip]
>
>> + if (order != PMD_SHIFT - PAGE_SHIFT && order_is_gigantic(order))
>> order = hugetlb_cma_default_order;
>
> doesn't this take gigantic PMD-order pages out of the default pool even
> when no PMD pool is set? would trying the exact order first and then
> falling back to the default pool work?
Good point. Perhaps we should use the following selector with the two
fixed pools:
static struct hugetlb_cma_pool *hugetlb_cma_pool(unsigned int order)
{
struct hugetlb_cma_pool *pmd_pool = &hugetlb_cma[HUGETLB_CMA_PMD];
if (order == PMD_SHIFT - PAGE_SHIFT && pmd_pool->size)
return pmd_pool;
if (order_is_gigantic(order))
return &hugetlb_cma[HUGETLB_CMA_DEFAULT];
return NULL;
}
>
> I tested it on qemu and saw no issues, but I'm hesitant about the points
> above. I can give a Tested-by tag on the next version :)
Thanks! I'll send out a v2 as soon as possible.
next prev parent reply other threads:[~2026-10-19 7:34 UTC|newest]
Thread overview: 20+ 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 [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
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=b8d87b71-c5ca-43d8-8050-72fc14802ae1@bytedance.com \
--to=zhengqi.arch@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=azpijr@gmail.com \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=qi.zheng@linux.dev \
/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®