From: Muchun Song <muchun.song@linux.dev>
To: Sang-Heon Jeon <ekffu200098@gmail.com>
Cc: osalvador@suse.de, david@kernel.org, akpm@linux-foundation.org,
linux-mm@kvack.org
Subject: Re: [PATCH] mm/hugetlb_cma: restrict hugetlb_cma parameter to gigantic-page alignment
Date: Mon, 11 May 2026 10:52:59 +0800 [thread overview]
Message-ID: <7A1AFE39-BDA3-4919-9D3F-81ECC734F6CB@linux.dev> (raw)
In-Reply-To: <20260503084225.415980-1-ekffu200098@gmail.com>
> On May 3, 2026, at 16:42, Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
>
> Existing hugetlb_cma parameter handling logic rejects sizes smaller than
> one gigantic page, but rounds up larger sizes that are not a multiple
> of it. The two behaviors are inconsistent and neither is documented.
>
> To remove existing inconsistent and undefined behavior, restrict
> hugetlb_cma parameter to only accept multiples of the gigantic page size.
>
> After this restriction, the redundant round_up() in the allocation loop
> can be removed.
>
> The new restriction is also documented in kernel-parameters.txt.
>
> Also, including other minor changes for readability improvement with no
> functional change.
>
> Suggested-by: Muchun Song <muchun.song@linux.dev>
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> ---
> QEMU based test result
>
> 1) hugetlb_cma=1300M
> a) AS-IS : total 2G reserved
> [ 0.000000] hugetlb_cma: reserve 1300 MiB, up to 1024 MiB per node
> [ 0.000000] cma: Reserved 1024 MiB in 1 range
> [ 0.000000] hugetlb_cma: reserved 1024 MiB on node 0
> [ 0.000000] cma: Reserved 1024 MiB in 1 range
> [ 0.000000] hugetlb_cma: reserved 1024 MiB on node 1
>
> b) TO-BE : rejected
> [ 0.000000] hugetlb_cma: cma area must be a multiple of 1024 MiB
>
> 2) hugetlb_cma=0:1300M,1:1G
> a) AS-IS : 2G reserved on node 0, 1G reserved on node 1
> [ 0.000000] cma: Reserved 2048 MiB in 1 range
> [ 0.000000] hugetlb_cma: reserved 2048 MiB on node 0
> [ 0.000000] cma: Reserved 1024 MiB in 1 range
> [ 0.000000] hugetlb_cma: reserved 1024 MiB on node 1
>
> b) TO-BE : 1G reserved on node 1
> [ 0.000000] hugetlb_cma: cma area of node 0 must be a multiple of 1024 MiB
> [ 0.000000] cma: Reserved 1024 MiB in 1 range
> [ 0.000000] hugetlb_cma: reserved 1024 MiB on node 1
> ---
> Hello,
>
> This patch implements a new restriction to hugetlb_cma parameter that
> was suggested during the review of the previous patch [1].
> Thanks to Muchun for the guidance.
>
> [1] https://lore.kernel.org/all/BFB1F124-B599-4832-A9DA-F4931999BAF9@linux.dev/
>
> Best Regards,
> Sang-Heon Jeon
> ---
> .../admin-guide/kernel-parameters.txt | 4 +++
> mm/hugetlb_cma.c | 35 +++++++++----------
> 2 files changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 4d0f545fb3ec..23be2f64439c 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -2100,6 +2100,10 @@ Kernel parameters
> Format: nn[KMGTPE] or (node format)
> <node>:nn[KMGTPE][,<node>:nn[KMGTPE]]
>
> + The size must be a multiple of the gigantic page size.
> + When using node format, this applies to each per-node size.
> + Missaligned values are dropped with a warning.
^
Misaligned
Acked-by: Muchun Song <muchun.song@linux.dev>
Thanks.
next prev parent reply other threads:[~2026-05-11 2:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 8:42 [PATCH] mm/hugetlb_cma: restrict hugetlb_cma parameter to gigantic-page alignment Sang-Heon Jeon
2026-05-11 2:52 ` Muchun Song [this message]
2026-05-11 8:23 ` Oscar Salvador
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=7A1AFE39-BDA3-4919-9D3F-81ECC734F6CB@linux.dev \
--to=muchun.song@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=ekffu200098@gmail.com \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
/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