* Re: [RFC PATCH] mm/hugetlb_cma: round up per_node before logging it
2026-04-21 23:02 [RFC PATCH] mm/hugetlb_cma: round up per_node before logging it Sang-Heon Jeon
@ 2026-04-22 6:20 ` Muchun Song
2026-04-22 9:49 ` Sang-Heon Jeon
2026-04-28 11:57 ` kernel test robot
2026-04-28 23:23 ` kernel test robot
2 siblings, 1 reply; 5+ messages in thread
From: Muchun Song @ 2026-04-22 6:20 UTC (permalink / raw)
To: Sang-Heon Jeon; +Cc: osalvador, david, akpm, linux-mm
> On Apr 22, 2026, at 07:02, 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
>
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> ---
> Hello,
>
> While looking into boot information, I found a minor issue.
> I am sending this patch as an RFC because of the two additional
> questions below (one directly related, the other indirectly related)
>
> 1. This patch only fixes the log output, not the reservation result itself.
> Do I need to add Fixes tag on this case? (i.e., Does this patch need backporting?)
> If so, I'll add below commit.
>
> Fixes: cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma") # 5.7
Yes, it is recommended to add a Fixes tag. The rule of thumb in the kernel
community is that if a patch fixes an issue (even a cosmetic one like a log
message), it should have a Fixes tag for proper traceability.
However, please note that having a Fixes: tag **does not automatically mean
it will be backported** to stable trees. Backporting usually requires an
explicit `Cc: <stable@vger.kernel.org>` tag, which is reserved for functional
bugs, crashes, or incorrect logic. Since this patch only corrects a log message,
I would not recommend adding the `Cc: stable` tag unless you believe this
misleading log has severe consequences (e.g., breaking userspace scripts that
parse it).
> 2. When node_specific_cma_alloc is true, the reservation loop can break
> out early due to round_up() before all specified nodes are reserved.
> Is this intentional or a bug?
>
> For example, with hugetlb_cma=0:1300M,1:1300M,2:1300M and (PAGE_SIZE
> << order) is 1GB
To me, this is a strange configuration. While the documentation doesn't
explicitly forbid this type of allocation, it doesn't clearly state whether
it's supported either. So I am curious why you have such configuration?
If we say that upward alignment is allowed—for example, allocating 2GB
when a user requests 1300MB—you’ll notice the code explicitly fails to
support configurations smaller than 1GB (where no upward alignment occurs).
These two alignment requirements are contradictory.
Personally, I’m inclined to view this as undefined behavior. If we’re going
to fix this, I think it is better to restrict user input to strictly follow
huge-page alignment. This should also help simplify our processing logic.
Let me know if anyone sees a downside to this approach!
>
> hugetlb_cma_size_in_node[0..2] = 1300MB
> hugetlb_cma_size = 3900MB
>
> Actual reserved size is rounded up from 1300MB to 2GB
>
> iter 1 (node 0): reserved: 2GB, 2GB < 3900MB, continue
> iter 2 (node 1): reserved: 4GB, 4GB >= 3900MB, break
>
> As a result, node 2 was specified but no CMA area is reserved. If this is
> unintended, I would be happy to send a follow-up patch to fix it.
>
> If I misunderstood anything, please feel free to let me know.
>
> Best Regards,
> Sang-Heon Jeon
> ---
> mm/hugetlb_cma.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/hugetlb_cma.c b/mm/hugetlb_cma.c
> index f83ae4998990..4a92a9e38500 100644
> --- a/mm/hugetlb_cma.c
> +++ b/mm/hugetlb_cma.c
> @@ -204,6 +204,7 @@ void __init hugetlb_cma_reserve(void)
> */
> per_node = DIV_ROUND_UP(hugetlb_cma_size,
> nodes_weight(hugetlb_bootmem_nodes));
> + per_node = round_up(per_node, PAGE_SIZE << order)
Missing semicolon at the end of this statement. I'm not sure if you
actually tested this patch?
Muchun,
Thanks.
> pr_info("hugetlb_cma: reserve %lu MiB, up to %lu MiB per node\n",
> hugetlb_cma_size / SZ_1M, per_node / SZ_1M);
> }
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC PATCH] mm/hugetlb_cma: round up per_node before logging it
2026-04-22 6:20 ` Muchun Song
@ 2026-04-22 9:49 ` Sang-Heon Jeon
0 siblings, 0 replies; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-04-22 9:49 UTC (permalink / raw)
To: Muchun Song; +Cc: osalvador, david, akpm, linux-mm
Hello,
On Wed, Apr 22, 2026 at 3:21 PM Muchun Song <muchun.song@linux.dev> wrote:
>
>
>
> > On Apr 22, 2026, at 07:02, 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
> >
> > Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> > ---
> > Hello,
> >
> > While looking into boot information, I found a minor issue.
> > I am sending this patch as an RFC because of the two additional
> > questions below (one directly related, the other indirectly related)
> >
> > 1. This patch only fixes the log output, not the reservation result itself.
> > Do I need to add Fixes tag on this case? (i.e., Does this patch need backporting?)
> > If so, I'll add below commit.
> >
> > Fixes: cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma") # 5.7
>
> Yes, it is recommended to add a Fixes tag. The rule of thumb in the kernel
> community is that if a patch fixes an issue (even a cosmetic one like a log
> message), it should have a Fixes tag for proper traceability.
>
> However, please note that having a Fixes: tag **does not automatically mean
> it will be backported** to stable trees. Backporting usually requires an
> explicit `Cc: <stable@vger.kernel.org>` tag, which is reserved for functional
> bugs, crashes, or incorrect logic. Since this patch only corrects a log message,
> I would not recommend adding the `Cc: stable` tag unless you believe this
> misleading log has severe consequences (e.g., breaking userspace scripts that
> parse it).
Thank you for the detailed explanation. Until now I had understood
`Cc: stable` tag as the explicit backport request and `Fixes` as an
implicit one. Your clarification is very helpful.
I also agree with your opinion that this patch is not appropriate for
the `Cc: stable` tag. I will add the `Fixes` tag only to the next
patch.
> > 2. When node_specific_cma_alloc is true, the reservation loop can break
> > out early due to round_up() before all specified nodes are reserved.
> > Is this intentional or a bug?
> >
> > For example, with hugetlb_cma=0:1300M,1:1300M,2:1300M and (PAGE_SIZE
> > << order) is 1GB
>
> To me, this is a strange configuration. While the documentation doesn't
> explicitly forbid this type of allocation, it doesn't clearly state whether
> it's supported either. So I am curious why you have such configuration?
This is an example scenario to describe the situation below. So, it is
not a real configuration from the real world.
> If we say that upward alignment is allowed—for example, allocating 2GB
> when a user requests 1300MB—you’ll notice the code explicitly fails to
> support configurations smaller than 1GB (where no upward alignment occurs).
> These two alignment requirements are contradictory.
>
> Personally, I’m inclined to view this as undefined behavior. If we’re going
> to fix this, I think it is better to restrict user input to strictly follow
> huge-page alignment. This should also help simplify our processing logic.
> Let me know if anyone sees a downside to this approach!
>
Thanks for the detailed description. I think your suggestion is very reasonable.
TBH, I'm not as familiar with hugetlb as you are, but I'd be happy to
work on this with your guidance.
> >
> > hugetlb_cma_size_in_node[0..2] = 1300MB
> > hugetlb_cma_size = 3900MB
> >
> > Actual reserved size is rounded up from 1300MB to 2GB
> >
> > iter 1 (node 0): reserved: 2GB, 2GB < 3900MB, continue
> > iter 2 (node 1): reserved: 4GB, 4GB >= 3900MB, break
> >
> > As a result, node 2 was specified but no CMA area is reserved. If this is
> > unintended, I would be happy to send a follow-up patch to fix it.
> >
> > If I misunderstood anything, please feel free to let me know.
> >
> > Best Regards,
> > Sang-Heon Jeon
> > ---
> > mm/hugetlb_cma.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/mm/hugetlb_cma.c b/mm/hugetlb_cma.c
> > index f83ae4998990..4a92a9e38500 100644
> > --- a/mm/hugetlb_cma.c
> > +++ b/mm/hugetlb_cma.c
> > @@ -204,6 +204,7 @@ void __init hugetlb_cma_reserve(void)
> > */
> > per_node = DIV_ROUND_UP(hugetlb_cma_size,
> > nodes_weight(hugetlb_bootmem_nodes));
> > + per_node = round_up(per_node, PAGE_SIZE << order)
>
> Missing semicolon at the end of this statement. I'm not sure if you
> actually tested this patch?
Oops, It's my mistake. I tested with QEMU and I'll attach test result
to the next patch
> Muchun,
> Thanks.
>
> > pr_info("hugetlb_cma: reserve %lu MiB, up to %lu MiB per node\n",
> > hugetlb_cma_size / SZ_1M, per_node / SZ_1M);
> > }
> > --
> > 2.43.0
> >
>
Best Regards,
Sang-Heon Jeon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH] mm/hugetlb_cma: round up per_node before logging it
2026-04-21 23:02 [RFC PATCH] mm/hugetlb_cma: round up per_node before logging it Sang-Heon Jeon
2026-04-22 6:20 ` Muchun Song
@ 2026-04-28 11:57 ` kernel test robot
2026-04-28 23:23 ` kernel test robot
2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-04-28 11:57 UTC (permalink / raw)
To: Sang-Heon Jeon; +Cc: llvm, oe-kbuild-all
Hi Sang-Heon,
[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:
[auto build test ERROR on v7.0]
[also build test ERROR on linus/master]
[cannot apply to akpm-mm/mm-everything next-20260427]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sang-Heon-Jeon/mm-hugetlb_cma-round-up-per_node-before-logging-it/20260427-012923
base: v7.0
patch link: https://lore.kernel.org/r/20260421230220.4122996-1-ekffu200098%40gmail.com
patch subject: [RFC PATCH] mm/hugetlb_cma: round up per_node before logging it
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20260428/202604281948.FEX8Kc9q-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260428/202604281948.FEX8Kc9q-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202604281948.FEX8Kc9q-lkp@intel.com/
All errors (new ones prefixed by >>):
>> mm/hugetlb_cma.c:208:3: error: expected expression
208 | pr_info("hugetlb_cma: reserve %lu MiB, up to %lu MiB per node\n",
| ^
include/linux/printk.h:584:2: note: expanded from macro 'pr_info'
584 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
| ^
include/linux/printk.h:511:26: note: expanded from macro 'printk'
511 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
| ^
include/linux/printk.h:481:3: note: expanded from macro 'printk_index_wrap'
481 | ({ \
| ^
1 error generated.
vim +208 mm/hugetlb_cma.c
9fac145b6d3fe5 Mike Rapoport (Microsoft 2026-01-11 142)
9fac145b6d3fe5 Mike Rapoport (Microsoft 2026-01-11 143) void __init hugetlb_cma_reserve(void)
9fac145b6d3fe5 Mike Rapoport (Microsoft 2026-01-11 144) {
9fac145b6d3fe5 Mike Rapoport (Microsoft 2026-01-11 145) unsigned long size, reserved, per_node, order;
474fe91f213a40 Frank van der Linden 2025-02-28 146 bool node_specific_cma_alloc = false;
474fe91f213a40 Frank van der Linden 2025-02-28 147 int nid;
474fe91f213a40 Frank van der Linden 2025-02-28 148
9fac145b6d3fe5 Mike Rapoport (Microsoft 2026-01-11 149) if (!hugetlb_cma_size)
9fac145b6d3fe5 Mike Rapoport (Microsoft 2026-01-11 150) return;
9fac145b6d3fe5 Mike Rapoport (Microsoft 2026-01-11 151)
9fac145b6d3fe5 Mike Rapoport (Microsoft 2026-01-11 152) order = arch_hugetlb_cma_order();
7a9c0bf0aec621 Mike Rapoport (Microsoft 2026-01-11 153) if (!order) {
7a9c0bf0aec621 Mike Rapoport (Microsoft 2026-01-11 154) pr_warn("hugetlb_cma: the option isn't supported by current arch\n");
9fac145b6d3fe5 Mike Rapoport (Microsoft 2026-01-11 155) return;
7a9c0bf0aec621 Mike Rapoport (Microsoft 2026-01-11 156) }
9fac145b6d3fe5 Mike Rapoport (Microsoft 2026-01-11 157)
474fe91f213a40 Frank van der Linden 2025-02-28 158 /*
474fe91f213a40 Frank van der Linden 2025-02-28 159 * HugeTLB CMA reservation is required for gigantic
474fe91f213a40 Frank van der Linden 2025-02-28 160 * huge pages which could not be allocated via the
474fe91f213a40 Frank van der Linden 2025-02-28 161 * page allocator. Just warn if there is any change
474fe91f213a40 Frank van der Linden 2025-02-28 162 * breaking this assumption.
474fe91f213a40 Frank van der Linden 2025-02-28 163 */
474fe91f213a40 Frank van der Linden 2025-02-28 164 VM_WARN_ON(order <= MAX_PAGE_ORDER);
474fe91f213a40 Frank van der Linden 2025-02-28 165
8d88b0769e256c Frank van der Linden 2025-04-02 166 hugetlb_bootmem_set_nodes();
8d88b0769e256c Frank van der Linden 2025-04-02 167
474fe91f213a40 Frank van der Linden 2025-02-28 168 for (nid = 0; nid < MAX_NUMNODES; nid++) {
474fe91f213a40 Frank van der Linden 2025-02-28 169 if (hugetlb_cma_size_in_node[nid] == 0)
474fe91f213a40 Frank van der Linden 2025-02-28 170 continue;
474fe91f213a40 Frank van der Linden 2025-02-28 171
8d88b0769e256c Frank van der Linden 2025-04-02 172 if (!node_isset(nid, hugetlb_bootmem_nodes)) {
474fe91f213a40 Frank van der Linden 2025-02-28 173 pr_warn("hugetlb_cma: invalid node %d specified\n", nid);
474fe91f213a40 Frank van der Linden 2025-02-28 174 hugetlb_cma_size -= hugetlb_cma_size_in_node[nid];
474fe91f213a40 Frank van der Linden 2025-02-28 175 hugetlb_cma_size_in_node[nid] = 0;
474fe91f213a40 Frank van der Linden 2025-02-28 176 continue;
474fe91f213a40 Frank van der Linden 2025-02-28 177 }
474fe91f213a40 Frank van der Linden 2025-02-28 178
474fe91f213a40 Frank van der Linden 2025-02-28 179 if (hugetlb_cma_size_in_node[nid] < (PAGE_SIZE << order)) {
474fe91f213a40 Frank van der Linden 2025-02-28 180 pr_warn("hugetlb_cma: cma area of node %d should be at least %lu MiB\n",
474fe91f213a40 Frank van der Linden 2025-02-28 181 nid, (PAGE_SIZE << order) / SZ_1M);
474fe91f213a40 Frank van der Linden 2025-02-28 182 hugetlb_cma_size -= hugetlb_cma_size_in_node[nid];
474fe91f213a40 Frank van der Linden 2025-02-28 183 hugetlb_cma_size_in_node[nid] = 0;
474fe91f213a40 Frank van der Linden 2025-02-28 184 } else {
474fe91f213a40 Frank van der Linden 2025-02-28 185 node_specific_cma_alloc = true;
474fe91f213a40 Frank van der Linden 2025-02-28 186 }
474fe91f213a40 Frank van der Linden 2025-02-28 187 }
474fe91f213a40 Frank van der Linden 2025-02-28 188
474fe91f213a40 Frank van der Linden 2025-02-28 189 /* Validate the CMA size again in case some invalid nodes specified. */
474fe91f213a40 Frank van der Linden 2025-02-28 190 if (!hugetlb_cma_size)
474fe91f213a40 Frank van der Linden 2025-02-28 191 return;
474fe91f213a40 Frank van der Linden 2025-02-28 192
474fe91f213a40 Frank van der Linden 2025-02-28 193 if (hugetlb_cma_size < (PAGE_SIZE << order)) {
474fe91f213a40 Frank van der Linden 2025-02-28 194 pr_warn("hugetlb_cma: cma area should be at least %lu MiB\n",
474fe91f213a40 Frank van der Linden 2025-02-28 195 (PAGE_SIZE << order) / SZ_1M);
474fe91f213a40 Frank van der Linden 2025-02-28 196 hugetlb_cma_size = 0;
474fe91f213a40 Frank van der Linden 2025-02-28 197 return;
474fe91f213a40 Frank van der Linden 2025-02-28 198 }
474fe91f213a40 Frank van der Linden 2025-02-28 199
474fe91f213a40 Frank van der Linden 2025-02-28 200 if (!node_specific_cma_alloc) {
474fe91f213a40 Frank van der Linden 2025-02-28 201 /*
474fe91f213a40 Frank van der Linden 2025-02-28 202 * If 3 GB area is requested on a machine with 4 numa nodes,
474fe91f213a40 Frank van der Linden 2025-02-28 203 * let's allocate 1 GB on first three nodes and ignore the last one.
474fe91f213a40 Frank van der Linden 2025-02-28 204 */
8d88b0769e256c Frank van der Linden 2025-04-02 205 per_node = DIV_ROUND_UP(hugetlb_cma_size,
8d88b0769e256c Frank van der Linden 2025-04-02 206 nodes_weight(hugetlb_bootmem_nodes));
1260cb5196af67 Sang-Heon Jeon 2026-04-22 207 per_node = round_up(per_node, PAGE_SIZE << order)
474fe91f213a40 Frank van der Linden 2025-02-28 @208 pr_info("hugetlb_cma: reserve %lu MiB, up to %lu MiB per node\n",
474fe91f213a40 Frank van der Linden 2025-02-28 209 hugetlb_cma_size / SZ_1M, per_node / SZ_1M);
474fe91f213a40 Frank van der Linden 2025-02-28 210 }
474fe91f213a40 Frank van der Linden 2025-02-28 211
474fe91f213a40 Frank van der Linden 2025-02-28 212 reserved = 0;
8d88b0769e256c Frank van der Linden 2025-04-02 213 for_each_node_mask(nid, hugetlb_bootmem_nodes) {
474fe91f213a40 Frank van der Linden 2025-02-28 214 int res;
474fe91f213a40 Frank van der Linden 2025-02-28 215 char name[CMA_MAX_NAME];
474fe91f213a40 Frank van der Linden 2025-02-28 216
474fe91f213a40 Frank van der Linden 2025-02-28 217 if (node_specific_cma_alloc) {
474fe91f213a40 Frank van der Linden 2025-02-28 218 if (hugetlb_cma_size_in_node[nid] == 0)
474fe91f213a40 Frank van der Linden 2025-02-28 219 continue;
474fe91f213a40 Frank van der Linden 2025-02-28 220
474fe91f213a40 Frank van der Linden 2025-02-28 221 size = hugetlb_cma_size_in_node[nid];
474fe91f213a40 Frank van der Linden 2025-02-28 222 } else {
474fe91f213a40 Frank van der Linden 2025-02-28 223 size = min(per_node, hugetlb_cma_size - reserved);
474fe91f213a40 Frank van der Linden 2025-02-28 224 }
474fe91f213a40 Frank van der Linden 2025-02-28 225
474fe91f213a40 Frank van der Linden 2025-02-28 226 size = round_up(size, PAGE_SIZE << order);
474fe91f213a40 Frank van der Linden 2025-02-28 227
474fe91f213a40 Frank van der Linden 2025-02-28 228 snprintf(name, sizeof(name), "hugetlb%d", nid);
474fe91f213a40 Frank van der Linden 2025-02-28 229 /*
474fe91f213a40 Frank van der Linden 2025-02-28 230 * Note that 'order per bit' is based on smallest size that
474fe91f213a40 Frank van der Linden 2025-02-28 231 * may be returned to CMA allocator in the case of
474fe91f213a40 Frank van der Linden 2025-02-28 232 * huge page demotion.
474fe91f213a40 Frank van der Linden 2025-02-28 233 */
474fe91f213a40 Frank van der Linden 2025-02-28 234 res = cma_declare_contiguous_multi(size, PAGE_SIZE << order,
474fe91f213a40 Frank van der Linden 2025-02-28 235 HUGETLB_PAGE_ORDER, name,
474fe91f213a40 Frank van der Linden 2025-02-28 236 &hugetlb_cma[nid], nid);
474fe91f213a40 Frank van der Linden 2025-02-28 237 if (res) {
474fe91f213a40 Frank van der Linden 2025-02-28 238 pr_warn("hugetlb_cma: reservation failed: err %d, node %d",
474fe91f213a40 Frank van der Linden 2025-02-28 239 res, nid);
474fe91f213a40 Frank van der Linden 2025-02-28 240 continue;
474fe91f213a40 Frank van der Linden 2025-02-28 241 }
474fe91f213a40 Frank van der Linden 2025-02-28 242
474fe91f213a40 Frank van der Linden 2025-02-28 243 reserved += size;
474fe91f213a40 Frank van der Linden 2025-02-28 244 pr_info("hugetlb_cma: reserved %lu MiB on node %d\n",
474fe91f213a40 Frank van der Linden 2025-02-28 245 size / SZ_1M, nid);
474fe91f213a40 Frank van der Linden 2025-02-28 246
474fe91f213a40 Frank van der Linden 2025-02-28 247 if (reserved >= hugetlb_cma_size)
474fe91f213a40 Frank van der Linden 2025-02-28 248 break;
474fe91f213a40 Frank van der Linden 2025-02-28 249 }
474fe91f213a40 Frank van der Linden 2025-02-28 250
474fe91f213a40 Frank van der Linden 2025-02-28 251 if (!reserved)
474fe91f213a40 Frank van der Linden 2025-02-28 252 /*
474fe91f213a40 Frank van der Linden 2025-02-28 253 * hugetlb_cma_size is used to determine if allocations from
474fe91f213a40 Frank van der Linden 2025-02-28 254 * cma are possible. Set to zero if no cma regions are set up.
474fe91f213a40 Frank van der Linden 2025-02-28 255 */
474fe91f213a40 Frank van der Linden 2025-02-28 256 hugetlb_cma_size = 0;
474fe91f213a40 Frank van der Linden 2025-02-28 257 }
474fe91f213a40 Frank van der Linden 2025-02-28 258
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC PATCH] mm/hugetlb_cma: round up per_node before logging it
2026-04-21 23:02 [RFC PATCH] mm/hugetlb_cma: round up per_node before logging it Sang-Heon Jeon
2026-04-22 6:20 ` Muchun Song
2026-04-28 11:57 ` kernel test robot
@ 2026-04-28 23:23 ` kernel test robot
2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-04-28 23:23 UTC (permalink / raw)
To: Sang-Heon Jeon; +Cc: oe-kbuild-all
Hi Sang-Heon,
[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:
[auto build test ERROR on v7.0]
[also build test ERROR on linus/master]
[cannot apply to akpm-mm/mm-everything next-20260428]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sang-Heon-Jeon/mm-hugetlb_cma-round-up-per_node-before-logging-it/20260427-012923
base: v7.0
patch link: https://lore.kernel.org/r/20260421230220.4122996-1-ekffu200098%40gmail.com
patch subject: [RFC PATCH] mm/hugetlb_cma: round up per_node before logging it
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20260429/202604290752.kPjM1Hkb-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260429/202604290752.kPjM1Hkb-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202604290752.kPjM1Hkb-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from include/asm-generic/bug.h:31,
from arch/x86/include/asm/bug.h:193,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:7,
from mm/hugetlb_cma.c:3:
mm/hugetlb_cma.c: In function 'hugetlb_cma_reserve':
>> include/linux/printk.h:481:10: error: expected expression before '{' token
481 | ({ \
| ^
include/linux/printk.h:511:26: note: in expansion of macro 'printk_index_wrap'
511 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/printk.h:584:9: note: in expansion of macro 'printk'
584 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~
mm/hugetlb_cma.c:208:17: note: in expansion of macro 'pr_info'
208 | pr_info("hugetlb_cma: reserve %lu MiB, up to %lu MiB per node\n",
| ^~~~~~~
In file included from include/linux/math64.h:6,
from include/linux/time64.h:5,
from include/linux/restart_block.h:9,
from include/linux/thread_info.h:14,
from include/linux/spinlock.h:60,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/mm.h:8:
>> include/linux/math.h:25:55: error: called object is not a function or function pointer
25 | #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
mm/hugetlb_cma.c:207:28: note: in expansion of macro 'round_up'
207 | per_node = round_up(per_node, PAGE_SIZE << order)
| ^~~~~~~~
vim +481 include/linux/printk.h
337015573718b1 Chris Down 2021-06-15 459
337015573718b1 Chris Down 2021-06-15 460 /*
337015573718b1 Chris Down 2021-06-15 461 * Some subsystems have their own custom printk that applies a va_format to a
337015573718b1 Chris Down 2021-06-15 462 * generic format, for example, to include a device number or other metadata
337015573718b1 Chris Down 2021-06-15 463 * alongside the format supplied by the caller.
337015573718b1 Chris Down 2021-06-15 464 *
337015573718b1 Chris Down 2021-06-15 465 * In order to store these in the way they would be emitted by the printk
337015573718b1 Chris Down 2021-06-15 466 * infrastructure, the subsystem provides us with the start, fixed string, and
337015573718b1 Chris Down 2021-06-15 467 * any subsequent text in the format string.
337015573718b1 Chris Down 2021-06-15 468 *
337015573718b1 Chris Down 2021-06-15 469 * We take a variable argument list as pr_fmt/dev_fmt/etc are sometimes passed
337015573718b1 Chris Down 2021-06-15 470 * as multiple arguments (eg: `"%s: ", "blah"`), and we must only take the
337015573718b1 Chris Down 2021-06-15 471 * first one.
337015573718b1 Chris Down 2021-06-15 472 *
337015573718b1 Chris Down 2021-06-15 473 * subsys_fmt_prefix must be known at compile time, or compilation will fail
337015573718b1 Chris Down 2021-06-15 474 * (since this is a mistake). If fmt or level is not known at compile time, no
337015573718b1 Chris Down 2021-06-15 475 * index entry will be made (since this can legitimately happen).
337015573718b1 Chris Down 2021-06-15 476 */
337015573718b1 Chris Down 2021-06-15 477 #define printk_index_subsys_emit(subsys_fmt_prefix, level, fmt, ...) \
337015573718b1 Chris Down 2021-06-15 478 __printk_index_emit(fmt, level, subsys_fmt_prefix)
337015573718b1 Chris Down 2021-06-15 479
337015573718b1 Chris Down 2021-06-15 480 #define printk_index_wrap(_p_func, _fmt, ...) \
337015573718b1 Chris Down 2021-06-15 @481 ({ \
337015573718b1 Chris Down 2021-06-15 482 __printk_index_emit(_fmt, NULL, NULL); \
337015573718b1 Chris Down 2021-06-15 483 _p_func(_fmt, ##__VA_ARGS__); \
337015573718b1 Chris Down 2021-06-15 484 })
337015573718b1 Chris Down 2021-06-15 485
337015573718b1 Chris Down 2021-06-15 486
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread