Mechanics of HugePages
I have a system with 8GB or RAM and accidentally set the nr_hugepages parameter to 5000 (~10GB). In practice the number allocated was limited by the available RAM at the time.
However, I am curious on a more fundamental level of how the Kernel deals with this.
-Is there some limit that the Kernel would impose on the percentage of RAM that can be allocated to Huge Pages?
-If the vast majority of RAM gets allocated to Huge Pages will that preclude many applications and/or libraries from getting loaded into memory or will they also get placed in Huge Pages?
-In general is there a reason to not allocate as much RAM as possible to Huge Pages?
Responses
Is there some limit that the Kernel would impose on the percentage of RAM that can be allocated to Huge Pages?
Static HugePage allocations need to be contiguous. So if you apply HP after boot, at least some RAM will be fragmented and you may not get the full allocation. This is why we recommend to apply static HP allocations on the GRUB kernel line.
If the vast majority of RAM gets allocated to Huge Pages will that preclude many applications and/or libraries from getting loaded into memory or will they also get placed in Huge Pages?
If an application does not request HugePages, it does not get them.
You can allocate all your RAM to HugePages and stop the system from booting.
In general is there a reason to not allocate as much RAM as possible to Huge Pages?
You should allocate as much as your HugePage-aware application needs and no more.
Unused HugePages will just be wasted RAM - reserved and never touched - which could otherwise be used by other applications or by the kernel as filesystem cache to speed up the system.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
