How do I enable 1GB size HugePage on X86-64 platform?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 10
  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 7
  • HugePage

Issue

  • How do I enable 1GB size HugePage on X86-64 platform?

Resolution

  • To use 1GB size HugePage, CPU needs to support it. The presence of flag pdpe1gb means CPU support 1 GB size HugePage. If flag pdpe1gb is missing then it is not possible to enable 1GB size HugePage.

  • Execute the following command to check CPU flag pdpe1gb in /pro/cpuinfo file.

# grep pdpe1gb /proc/cpuinfo | uniq
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti intel_ppin ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts flush_l1d
  • The 1GB size HugePage can be enabled or disabled using the kernel boot parameters or using the files in /sys interface.

Steps to enable 1GB HugePage using the kernel boot parameter:

  • The kernel boot parameter hugepagesz= <size> is used to set the size of the HugeTLB pages (I.E. 2M, 1G) and hugepages= <number> is used to allocate HugeTLB pages at boot.

Red Hat Enterprsie Linux 9 & 10

  • Execute the below command to set Hugepages of 1 GB size.
# grubby --update-kernel=ALL --args="hugepagesz=1G hugepages=5"

Note: The above configuration will allocate 5 HugePages of 1 GB size. Modify the respective values accordingly.

  • Reboot the system.
# reboot
  • Verify the hugepages configuration.
# cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
5

Red Hat Enterprsie Linux 8

  • Set hugepagesz=1G and hugepages=5 parameter in /boot/grub2/grubenv file to allocated 5 pages of 1GB size HugePage.
# grep kernelopts /boot/grub2/grubenv
kernelopts=root=/dev/mapper/rhel-root ro resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet hugepagesz=1G hugepages=5

Red Hat Enterprsie Linux 7

  • Set hugepagesz=1G and hugepages=5 parameter in /etc/sysconfig/grub file to allocated 5 pages of 1GB size HugePage.
# grep GRUB_CMDLINE_LINUX /etc/sysconfig/grub
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root biosdevname=0 LANG=en_US.UTF-8 hugepagesz=1G hugepages=5

# grub2-mkconfig -o /etc/grub2.cfg
  • Reboot the system.
# reboot
  • Verify the 1GB size HugePage allocation using the following commands.
# cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
5

# hugeadm --pool-list
      Size  Minimum  Current  Maximum  Default
   2097152        0        0        0        *
1073741824        5        5        5         

Note: It is also possible to allocate both sizes of HugePage at the boot time.

  • The following kernel boot parameters will set 500 pages of 2MB size HugePage and 2 pages of 1GB HugePage on the system.
hugepagesz=2M hugepages=500 hugepagesz=1G hugepages=2

Steps to enable 1GB HugePage using the files in /sys interface:

  • Write the number of pages for 1 GB size HugePage in /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages file.
# echo 10 > /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
  • Verify the 1GB size HugePage allocation using following commands.
# cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
10

# hugeadm --pool-list
      Size  Minimum  Current  Maximum  Default
   2097152        0        0        0        *
1073741824       10       10       10       
SBR
Components
Category

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.