https://access.redhat.com/solutions/2791291
How do I enable 1GB size HugePage on X86-64 platform?
环境
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- HugePage
问题
- How do I enable 1GB size HugePage on X86-64 platform?
决议
-
To use 1GB size HugePage, CPU needs to support it. The presence of flag
pdpe1gbmeans CPU support 1 GB size HugePage. If flagpdpe1gbis missing then it is possible to enable 1GB size HugePage. -
Execute the following command to check CPU flag
pdpe1gbin/pro/cpuinfofile.
# 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
/sysinterface.
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) andhugepages= <number>is used to allocate HugeTLB pages at boot.
Red Hat Enterprsie Linux 8
- Set
hugepagesz=1Gandhugepages=5parameter in/boot/grub2/grubenvfile 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=1Gandhugepages=5parameter in/etc/sysconfig/grubfile 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 /boot/grub2/grub.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_hugepagesfile.
# 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
1GB Huge Page 在 X86-64 平台上的启用教程

本文详细介绍了如何在 Red Hat Enterprise Linux 7 和 8 上启用 1GB 大小的 Huge Page。首先检查 CPU 是否支持 pdpe1gb 标志,然后通过修改 grub 配置文件或使用 sysfs 接口来设置 hugepagesz 和 hugepages 参数。
662

被折叠的 条评论
为什么被折叠?



