How can I configure hugepages in Red Hat Enterprise Linux?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL) 5 or later

Issue

  • How can I configure hugepages in Red Hat Enterprise Linux?

Resolution

Preferred method for RHEL 10
The instructions are included in RHEL10 product documentation.

Preferred method for RHEL 9
The instructions are included in RHEL9 product documentation.

Preferred method for RHEL 5, 6, 7, 8
Use the hugepages=X kernel parameter to set X number of huge pages.

[root@rhel7 ~]# cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-3.10.0-1127.el7.x86_64 root=/dev/mapper/rhel_rhel7-root ro crashkernel=auto spectre_v2=retpoline rd.lvm.lv=rhel_rhel7/root rd.lvm.lv=rhel_rhel7/swap rhgb quiet hugepages=10

[root@rhel7 ~]# cat /proc/sys/vm/nr_hugepages
10

Huge page reservations are allocated from free and contiguous RAM. By using this method the allocation happens early in the boot process where memory is much more likely to be free and contiguous.

See also:

Alternate method:
Configure hugepages by using the kernel tunable vm.nr_hugepages


For example:

  1. Edit /etc/sysctl.conf file and specify the number of hugepages in the nr_hugepages :
    vm.nr_hugepages = 10
    
  2. Execute sysctl command.
    # sysctl -p
    <snip>
    vm.nr_hugepages = 10
    
  • Confirm in /proc/meminfo :

    # cat /proc/meminfo | grep Huge
    HugePages_Total:    10
    HugePages_Free:     10
    HugePages_Rsvd:      0
    Hugepagesize:     2048 kB
    

Note : It's recommended to restart the system after configuring hugepages as the chances of having free contiguous memory (for hugepages allocation) is much greater when a system is started.

Comments

  • For more details check the kernel documentation at : /usr/share/doc/kernel-doc-2.6.18/Documentation/vm/hugetlbpage.txt

Note: The above file is provided by the kernel-doc package.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments