Commit 520495fe authored by Cannon Matthews's avatar Cannon Matthews Committed by Linus Torvalds

mm: hugetlb: yield when prepping struct pages

When booting with very large numbers of gigantic (i.e.  1G) pages, the
operations in the loop of gather_bootmem_prealloc, and specifically
prep_compound_gigantic_page, takes a very long time, and can cause a
softlockup if enough pages are requested at boot.

For example booting with 3844 1G pages requires prepping
(set_compound_head, init the count) over 1 billion 4K tail pages, which
takes considerable time.

Add a cond_resched() to the outer loop in gather_bootmem_prealloc() to
prevent this lockup.

Tested: Booted with softlockup_panic=1 hugepagesz=1G hugepages=3844 and
no softlockup is reported, and the hugepages are reported as
successfully setup.

Link: default avatarCannon Matthews <>
Reviewed-by: default avatarAndrew Morton <>
Reviewed-by: default avatarMike Kravetz <>
Acked-by: default avatarMichal Hocko <>
Cc: Andres Lagar-Cavilla <>
Cc: Peter Feiner <>
Cc: Greg Thelen <>
Cc: <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 1e2c0436
......@@ -2163,6 +2163,7 @@ static void __init gather_bootmem_prealloc(void)
if (hstate_is_gigantic(h))
adjust_managed_page_count(page, 1 << h->order);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment