linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hugetlb: increase hugepage reservations when using node-specific "hugepages=" cmdline
@ 2026-01-22  3:50 Li Zhe
  2026-01-22  3:53 ` Muchun Song
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Li Zhe @ 2026-01-22  3:50 UTC (permalink / raw)
  To: muchun.song, osalvador, david, akpm; +Cc: linux-mm, linux-kernel, lizhe.67

Commit 3dfd02c90037 ("hugetlb: increase number of reserving hugepages
via cmdline") raised the number of hugepages that can be reserved
through the boot-time "hugepages=" parameter for the non-node-specific
case, but left the node-specific form of the same parameter unchanged.

This patch extends the same optimization to node-specific reservations.
When HugeTLB vmemmap optimization (HVO) is enabled and a node cannot
satisfy the requested hugepages, the code first releases ordinary
struct-page memory of hugepages obtained from the buddy allocator,
allowing their struct-page memory to be reclaimed and reused for
additional hugepage reservations on that node.

This is particularly beneficial for configurations that require
identical, large per-node hugepage reservations. On a four-node, 384 GB
x86 VM, the patch raises the attainable 2 MiB hugepage reservation from
under 374 GB to more than 379 GB.

Signed-off-by: Li Zhe <lizhe.67@bytedance.com>
---
 mm/hugetlb.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a1832da0f623..008315616c3b 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3425,6 +3425,13 @@ static void __init hugetlb_hstate_alloc_pages_onenode(struct hstate *h, int nid)
 
 			folio = only_alloc_fresh_hugetlb_folio(h, gfp_mask, nid,
 					&node_states[N_MEMORY], NULL);
+			if (!folio && !list_empty(&folio_list) &&
+			    hugetlb_vmemmap_optimizable_size(h)) {
+				prep_and_add_allocated_folios(h, &folio_list);
+				INIT_LIST_HEAD(&folio_list);
+				folio = only_alloc_fresh_hugetlb_folio(h, gfp_mask, nid,
+						&node_states[N_MEMORY], NULL);
+			}
 			if (!folio)
 				break;
 			list_add(&folio->lru, &folio_list);
-- 
2.20.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hugetlb: increase hugepage reservations when using node-specific "hugepages=" cmdline
  2026-01-22  3:50 [PATCH] hugetlb: increase hugepage reservations when using node-specific "hugepages=" cmdline Li Zhe
@ 2026-01-22  3:53 ` Muchun Song
  2026-01-22 22:19 ` Andrew Morton
  2026-01-27 13:35 ` Oscar Salvador
  2 siblings, 0 replies; 6+ messages in thread
From: Muchun Song @ 2026-01-22  3:53 UTC (permalink / raw)
  To: Li Zhe; +Cc: osalvador, david, akpm, linux-mm, linux-kernel



> On Jan 22, 2026, at 11:50, Li Zhe <lizhe.67@bytedance.com> wrote:
> 
> Commit 3dfd02c90037 ("hugetlb: increase number of reserving hugepages
> via cmdline") raised the number of hugepages that can be reserved
> through the boot-time "hugepages=" parameter for the non-node-specific
> case, but left the node-specific form of the same parameter unchanged.
> 
> This patch extends the same optimization to node-specific reservations.
> When HugeTLB vmemmap optimization (HVO) is enabled and a node cannot
> satisfy the requested hugepages, the code first releases ordinary
> struct-page memory of hugepages obtained from the buddy allocator,
> allowing their struct-page memory to be reclaimed and reused for
> additional hugepage reservations on that node.
> 
> This is particularly beneficial for configurations that require
> identical, large per-node hugepage reservations. On a four-node, 384 GB
> x86 VM, the patch raises the attainable 2 MiB hugepage reservation from
> under 374 GB to more than 379 GB.
> 
> Signed-off-by: Li Zhe <lizhe.67@bytedance.com>

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




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hugetlb: increase hugepage reservations when using node-specific "hugepages=" cmdline
  2026-01-22  3:50 [PATCH] hugetlb: increase hugepage reservations when using node-specific "hugepages=" cmdline Li Zhe
  2026-01-22  3:53 ` Muchun Song
@ 2026-01-22 22:19 ` Andrew Morton
  2026-01-23  3:14   ` Li Zhe
  2026-01-27 13:35 ` Oscar Salvador
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2026-01-22 22:19 UTC (permalink / raw)
  To: Li Zhe; +Cc: muchun.song, osalvador, david, linux-mm, linux-kernel

On Thu, 22 Jan 2026 11:50:02 +0800 "Li Zhe" <lizhe.67@bytedance.com> wrote:

> Commit 3dfd02c90037 ("hugetlb: increase number of reserving hugepages
> via cmdline") raised the number of hugepages that can be reserved
> through the boot-time "hugepages=" parameter for the non-node-specific
> case, but left the node-specific form of the same parameter unchanged.
> 
> This patch extends the same optimization to node-specific reservations.
> When HugeTLB vmemmap optimization (HVO) is enabled and a node cannot
> satisfy the requested hugepages, the code first releases ordinary
> struct-page memory of hugepages obtained from the buddy allocator,
> allowing their struct-page memory to be reclaimed and reused for
> additional hugepage reservations on that node.
> 
> This is particularly beneficial for configurations that require
> identical, large per-node hugepage reservations. On a four-node, 384 GB
> x86 VM, the patch raises the attainable 2 MiB hugepage reservation from
> under 374 GB to more than 379 GB.
> 

Thanks.

I *think* the hugepages= documentation in
Documentation/admin-guide/mm/hugetlbpage.rst is still up to date and
complete, but can you please check it, see if there's somethig we should
do?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hugetlb: increase hugepage reservations when using node-specific "hugepages=" cmdline
  2026-01-22 22:19 ` Andrew Morton
@ 2026-01-23  3:14   ` Li Zhe
  2026-01-23  3:18     ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Li Zhe @ 2026-01-23  3:14 UTC (permalink / raw)
  To: akpm; +Cc: david, linux-kernel, linux-mm, lizhe.67, muchun.song, osalvador

On Thu, 22 Jan 2026 14:19:00 -0800, akpm@linux-foundation.org wrote:

> On Thu, 22 Jan 2026 11:50:02 +0800 "Li Zhe" <lizhe.67@bytedance.com> wrote:
> 
> > Commit 3dfd02c90037 ("hugetlb: increase number of reserving hugepages
> > via cmdline") raised the number of hugepages that can be reserved
> > through the boot-time "hugepages=" parameter for the non-node-specific
> > case, but left the node-specific form of the same parameter unchanged.
> > 
> > This patch extends the same optimization to node-specific reservations.
> > When HugeTLB vmemmap optimization (HVO) is enabled and a node cannot
> > satisfy the requested hugepages, the code first releases ordinary
> > struct-page memory of hugepages obtained from the buddy allocator,
> > allowing their struct-page memory to be reclaimed and reused for
> > additional hugepage reservations on that node.
> > 
> > This is particularly beneficial for configurations that require
> > identical, large per-node hugepage reservations. On a four-node, 384 GB
> > x86 VM, the patch raises the attainable 2 MiB hugepage reservation from
> > under 374 GB to more than 379 GB.
> > 
> 
> Thanks.
> 
> I *think* the hugepages= documentation in
> Documentation/admin-guide/mm/hugetlbpage.rst is still up to date and
> complete, but can you please check it, see if there's somethig we should
> do?

After carefully re-reading the documentation on the "hugepages="
parameter, I did not see any points that could or should be optimized
regarding the number of reserved huge pages.

Thanks,
Zhe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hugetlb: increase hugepage reservations when using node-specific "hugepages=" cmdline
  2026-01-23  3:14   ` Li Zhe
@ 2026-01-23  3:18     ` Andrew Morton
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2026-01-23  3:18 UTC (permalink / raw)
  To: Li Zhe; +Cc: david, linux-kernel, linux-mm, muchun.song, osalvador

On Fri, 23 Jan 2026 11:14:00 +0800 "Li Zhe" <lizhe.67@bytedance.com> wrote:

> > I *think* the hugepages= documentation in
> > Documentation/admin-guide/mm/hugetlbpage.rst is still up to date and
> > complete, but can you please check it, see if there's somethig we should
> > do?
> 
> After carefully re-reading the documentation on the "hugepages="
> parameter, I did not see any points that could or should be optimized
> regarding the number of reserved huge pages.

Wonderful, thanks!


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hugetlb: increase hugepage reservations when using node-specific "hugepages=" cmdline
  2026-01-22  3:50 [PATCH] hugetlb: increase hugepage reservations when using node-specific "hugepages=" cmdline Li Zhe
  2026-01-22  3:53 ` Muchun Song
  2026-01-22 22:19 ` Andrew Morton
@ 2026-01-27 13:35 ` Oscar Salvador
  2 siblings, 0 replies; 6+ messages in thread
From: Oscar Salvador @ 2026-01-27 13:35 UTC (permalink / raw)
  To: Li Zhe; +Cc: muchun.song, david, akpm, linux-mm, linux-kernel

On Thu, Jan 22, 2026 at 11:50:02AM +0800, Li Zhe wrote:
> Commit 3dfd02c90037 ("hugetlb: increase number of reserving hugepages
> via cmdline") raised the number of hugepages that can be reserved
> through the boot-time "hugepages=" parameter for the non-node-specific
> case, but left the node-specific form of the same parameter unchanged.
> 
> This patch extends the same optimization to node-specific reservations.
> When HugeTLB vmemmap optimization (HVO) is enabled and a node cannot
> satisfy the requested hugepages, the code first releases ordinary
> struct-page memory of hugepages obtained from the buddy allocator,
> allowing their struct-page memory to be reclaimed and reused for
> additional hugepage reservations on that node.
> 
> This is particularly beneficial for configurations that require
> identical, large per-node hugepage reservations. On a four-node, 384 GB
> x86 VM, the patch raises the attainable 2 MiB hugepage reservation from
> under 374 GB to more than 379 GB.
> 
> Signed-off-by: Li Zhe <lizhe.67@bytedance.com>

Acked-by: Oscar Salvador <osalvador@suse.de>


-- 
Oscar Salvador
SUSE Labs


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-27 13:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-22  3:50 [PATCH] hugetlb: increase hugepage reservations when using node-specific "hugepages=" cmdline Li Zhe
2026-01-22  3:53 ` Muchun Song
2026-01-22 22:19 ` Andrew Morton
2026-01-23  3:14   ` Li Zhe
2026-01-23  3:18     ` Andrew Morton
2026-01-27 13:35 ` Oscar Salvador

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox