All of lore.kernel.org
 help / color / mirror / Atom feed
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: round up per_node before logging it
Date: Thu, 23 Apr 2026 10:11:58 +0800	[thread overview]
Message-ID: <06EBF760-EFAF-4EA7-AFEE-EBDCEB01752B@linux.dev> (raw)
In-Reply-To: <20260422143353.852257-1-ekffu200098@gmail.com>



> On Apr 22, 2026, at 22:33, Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
> 
> When the user requests a total hugetlb CMA size without per-node
> specification, hugetlb_cma_reserve() computes per_node from
> hugetlb_cma_size and the number of nodes that have memory
> 
>        per_node = DIV_ROUND_UP(hugetlb_cma_size,
>                                nodes_weight(hugetlb_bootmem_nodes));
> 
> The reservation loop later computes
> 
>        size = round_up(min(per_node, hugetlb_cma_size - reserved),
>                          PAGE_SIZE << order);
> 
> So the actually reserved per_node size is multiple of (PAGE_SIZE <<
> order), but the logged per_node is not rounded up, so it may be smaller
> than the actual reserved size.
> 
> For example, as the existing comment describes, if a 3 GB area is
> requested on a machine with 4 NUMA nodes that have memory, 1 GB is
> allocated on the first three nodes, but the printed log is
> 
>        hugetlb_cma: reserve 3072 MiB, up to 768 MiB per node
> 
> Round per_node up to (PAGE_SIZE << order) before logging so that the
> printed log always matches the actual reserved size. No functional change
> to the actual reservation size, as the following case analysis shows
> 
> 1. remaining (hugetlb_cma_size - reserved) >= rounded per_node
> - AS-IS: min() picks unrounded per_node;
>    round_up() returns rounded per_node
> - TO-BE: min() picks rounded per_node;
>    round_up() returns rounded per_node (no-op)
> 2. remaining < unrounded per_node
> - AS-IS: min() picks remaining;
>    round_up() returns round_up(remaining)
> - TO-BE: min() picks remaining;
>    round_up() returns round_up(remaining)
> 3. unrounded per_node <= remaining < rounded per_node
> - AS-IS: min() picks unrounded per_node;
>    round_up() returns rounded per_node
> - TO-BE: min() picks remaining;
>    round_up() returns round_up(remaining) equals rounded per_node
> 
> Fixes: cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma") # 5.7
                                                                                         ^
                                                                           we do not add a suffix to Fixes tag.
                                                                           We usually add it to stable tag.

Reviewed-by: Muchun Song <muchun.song@linux.dev>

Thanks.



      reply	other threads:[~2026-04-23  2:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-22 14:33 [PATCH] mm/hugetlb_cma: round up per_node before logging it Sang-Heon Jeon
2026-04-23  2:11 ` Muchun Song [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=06EBF760-EFAF-4EA7-AFEE-EBDCEB01752B@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.