Unix & Linux
linux memory huge-pages
Updated Thu, 30 Jun 2022 08:11:43 GMT

benefits of allocating huge pages at boot

[ moving the question from StackOverflow where it seems less appropriate ]

The kernel boots with default_hugepagesz=1G option, which defines size of the default page size. So when an application want large memory, the kernel will allocate it with 1G pages.

If the kernel boots with hugepages=N, i.e. allocate N huge pages at boot. So in this case, the kernel will automatically take a page from this pool, thus saving time on allocating memory?

When this pool runs out of available pages, how will the kernel allocate huge memory?


The advantage of allocating huge pages at boot is that the pages are pre-allocated, before memory is fragmented. The amount of allocated huge pages can also be changed at runtime, and an overcommit limit can be set the kernel will allocate new huge pages if necessary, up to the overcommit limit, as long as enough pages are available to convert to huge pages.

See the relevant kernel documentation for details.

External Links

External links referenced by this document: