summaryrefslogtreecommitdiff
path: root/scripts/stackusage
diff options
context:
space:
mode:
authorPratyush Yadav (Google) <pratyush@kernel.org>2026-08-01 10:48:29 +0200
committerMike Rapoport (Microsoft) <rppt@kernel.org>2026-08-04 09:28:39 +0300
commit7d163a75f8211b4a21b0375109ffe3330126c1e4 (patch)
tree141086a4b43277e17f038ffc167c743ac74d39b9 /scripts/stackusage
parent27766611309ab34f36153cc79830d3ab88880977 (diff)
downloadlinux-7d163a75f8211b4a21b0375109ffe3330126c1e4.tar.gz
linux-7d163a75f8211b4a21b0375109ffe3330126c1e4.zip
memblock: make HugeTLB bootmem allocation work with KHO
Gigantic huge page allocation is somewhat broken currently when KHO is used. Firstly, they break KHO scratch size accounting. RSRV_KERN is used to track how much memory is reserved for use by the kernel. Since hugetlb::alloc_bootmem() calls the memblock_alloc*() APIs, the hugepages allocated also get marked as RSRV_KERN. Allocations marked RSRV_KERN are used by KHO to calculate how much scratch space it should reserve to make sure the next kernel has enough memory to boot when it is in scratch-only phase. Counting hugepages in that blows up scratch size, and can lead to the scratch allocation failing, making KHO unusable. This will show up when huge pages make up more than 50% of the system, which is a fairly common use case. Secondly, while not supported right now, huge pages are user memory and can be preserved via KHO. The scratch spaces should not have any preserved memory. Allocating hugepages from scratch (on a KHO boot) can lead to them being un-preservable. Introduce memblock_alloc_hugetlb(). This lets memblock tailor to the needs of hugetb without exposing those details to the general allocation routines. First, it does not use mirrored memory for hugetlb. Mirrored memory is a limited resource that is best saved for kernel data structures, not user memory. Second, if the free memory area found by memblock_find_in_range_node() is a part of a KHO scratch area, the free area is not used. Allocation is retried starting after the free area to ensure no hugepages come from KHO scratch. Third, it simplifies the argument list by baking in some hugetlb assumptions like alignment and exact_nid. This also simplifies allocation logic in alloc_bootmem(). Also introduce MEMBLOCK_RSRV_HUGETLB to mark reservations made for HugeTLB. This will be used by KHO in future patches to correctly calculate scratch sizes. Refactor some of the preparation logic like kmemleak tracking and accepting memory into a separate helper memblock_prep_allocation(), and use it from both memblock_alloc_hugetlb() and the usual memblock_alloc_range_nid(). Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org> Link: https://patch.msgid.link/20260801084833.1897543-21-pratyush@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Diffstat (limited to 'scripts/stackusage')
0 files changed, 0 insertions, 0 deletions