Skip to contentSkip to conversation

mm/hugetlb: two-phase hugepage allocation when reservation is high

PATCH Li,Rongqing 2 participants 2 messages Aug 27, 2025 Memory management

lore
Share & tools
lore
#0 lore raw
Quoted 36 lines

Not sure if something like the following could fly:

mm/hugetlb.c index renamed from mm/hugetlb.c +0 -0

1f42186a85ea4..dfb4d717b8a02 100644

mm/hugetlb.c +0 -2
@@ -3595,8 +3595,6 @@ static unsigned long __init
 hugetlb_pages_alloc_boot(struct hstate *h)
         unsigned long jiffies_end;
 
         job.thread_fn   = hugetlb_pages_alloc_boot_node;
-       job.start       = 0;
-       job.size        = h->max_huge_pages;
 
         /*

* job.max_threads is 25% of the available cpu threads by default.

mm/hugetlb.c +1 -2
@@ -3620,10 +3618,24 @@ static unsigned long __init
 hugetlb_pages_alloc_boot(struct hstate *h)
         }
 
         job.max_threads = hugepage_allocation_threads;
-       job.min_chunk   = h->max_huge_pages /
 hugepage_allocation_threads;
 
         jiffies_start = jiffies;
-       padata_do_multithreaded(&job);
+       /* TODO: comment why we retry and how it interacts with

vmemmap op. */

mm/hugetlb.c +7 -0
+       while (h->nr_huge_pages != h->max_huge_pages) {
+               unsigned long remaining = h->max_huge_pages -
+ h->nr_huge_pages;
+
+               job.start       = h->nr_huge_pages;
+               job.size        = remaining;
+               job.min_chunk   = remaining /

hugepage_allocation_threads;

mm/hugetlb.c

Quoted 4 lines
mm/hugetlb.c +4 -0
+               padata_do_multithreaded(&job);
+
+               if (hugetlb_vmemmap_optimizable(h))
+                       break;

It should be:

           if (!hugetlb_vmemmap_optimizable(h))
                     break;

other is fine to me

thanks

-Li

Quoted 15 lines
mm/hugetlb.c +5 -0
+
+               /* Stop if there is no progress. */
+               if (remaining == h->max_huge_pages - h->nr_huge_pages)
+                       break;
+       }
         jiffies_end = jiffies;
 
         pr_info("HugeTLB: allocation took %dms with

hugepage_allocation_threads=%ld\n",

--
Cheers

David / dhildenb

#1 lore raw
Quoted 42 lines · Li,Rongqing
Quoted 36 lines

Not sure if something like the following could fly:

mm/hugetlb.c index renamed from mm/hugetlb.c +0 -0

1f42186a85ea4..dfb4d717b8a02 100644

mm/hugetlb.c +0 -2
@@ -3595,8 +3595,6 @@ static unsigned long __init
 hugetlb_pages_alloc_boot(struct hstate *h)
          unsigned long jiffies_end;
 
          job.thread_fn   = hugetlb_pages_alloc_boot_node;
-       job.start       = 0;
-       job.size        = h->max_huge_pages;
 
          /*

* job.max_threads is 25% of the available cpu threads by default.

mm/hugetlb.c +1 -2
@@ -3620,10 +3618,24 @@ static unsigned long __init
 hugetlb_pages_alloc_boot(struct hstate *h)
          }
 
          job.max_threads = hugepage_allocation_threads;
-       job.min_chunk   = h->max_huge_pages /
 hugepage_allocation_threads;
 
          jiffies_start = jiffies;
-       padata_do_multithreaded(&job);
+       /* TODO: comment why we retry and how it interacts with

vmemmap op. */

mm/hugetlb.c +7 -0
+       while (h->nr_huge_pages != h->max_huge_pages) {
+               unsigned long remaining = h->max_huge_pages -
+ h->nr_huge_pages;
+
+               job.start       = h->nr_huge_pages;
+               job.size        = remaining;
+               job.min_chunk   = remaining /

hugepage_allocation_threads;

mm/hugetlb.c

Quoted 4 lines
mm/hugetlb.c +4 -0
+               padata_do_multithreaded(&job);
+
+               if (hugetlb_vmemmap_optimizable(h))
+                       break;

It should be:

Quoted 2 lines
            if (!hugetlb_vmemmap_optimizable(h))
                      break;

Very right.

Signature · 3 lines
Cheers

David / dhildenb