How to determine if the CPU supports HugePage? How to determine if the CPU supports HugePage? How to determine if the CPU supports 2MB size HugePage? How to check if CPU supports hugepages 2MB size. How to check if CPU supports HugePages 1GB Size. How to determine if the CPU supports 1GB size HugePage? How to change default hugepage size in CentOS or RHEL 7 Linux. How to check the default hugepage size. How to permanently change default hugepage size using GRUB2 in Linux.
This article was written while using RHEL 7, so it is safe to say that it also fully covers CentOS 7, Fedora, Oracle Enterprise Linux and generally the whole Red Hat family of operating systems and possibly Novell’s SLES and OpenSUSE.
Check if CPU supports HugePages 2MB Size
To check if CPU supports HugePages 2MB size, look out for the presence of flag pse in /proc/cpuinfo
. Here I am using uniq
because depending upon the no of processors and CPU, you may get a long output.
# cat /proc/cpuinfo | grep pse | 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 aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm epb ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm ida arat pln pts md_clear spec_ctrl intel_stibp flush_l1d
Or alternatively you can also execute below command for a cleaner output
# cat /proc/cpuinfo | egrep -o pse | head -n 1 pse
Check if CPU supports HugePages 1GB Size
To check if CPU supports HugePages 1GB size, look out for presence of flag pdpe1gb in /proc/cpuinfo
. Here I am using head -n 1
because depending upon the no of processors and CPU, you may get a long output so we only check the first output as all others would be same.
# cat /proc/cpuinfo | grep pdpe1gb | head -n 1
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 aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm epb ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm ida arat pln pts md_clear spec_ctrl intel_stibp flush_l1d
Or alternatively you can also execute below command for a cleaner output
# cat /proc/cpuinfo | egrep -o pdpe1gb | head -n 1 pdpe1gb
How to change default HugePage size?
To allocate huge pages of a specific size, one must precede the huge pages boot command parameters with a huge page size selection parameter "hugepagesz=
". must be specified in bytes with optional scale suffix [kKmMgG]. The default hugepage size may be selected with the "default_hugepagesz=
" boot parameter.
Check the current hugepage size in your Linux system. So currently my system is configured with 2MB of hugepage size but since my system supports 1GB hugepage size so I can change the same.
# grep Hugepagesize: /proc/meminfo
Hugepagesize: 2048 kB
Let us change default hugepage size from 2MB to 1GB on my system. I have updated my GRUB2 configuration under /etc/sysconfig/grub and have added default_hugepagesz=1G to change default hugepage size to 1GB as you can see below
# grep GRUB_CMDLINE_LINUX /etc/sysconfig/grub
GRUB_CMDLINE_LINUX="novga console=ttyS0,115200 panic=1 rd.md.uuid=2bf69f98:8507fb4d:bcd2633e:14aecb1c rd.lvm.lv=os/root rd.md.uuid=feef9526:9af37168:0e029a0d:1cf5a6d1 rd.md.uuid=5c13046e:592fe6da:bb4bb7cd:0057371a rhgb quiet default_hugepagesz=1G"
Next rebuild your GRUB2
~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-957.21.3.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-957.21.3.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-60aaa1c262314bc2afa5c309ae8a0978 Found initrd image: /boot/initramfs-0-rescue-60aaa1c262314bc2afa5c309ae8a0978.img done
Reboot the system to activate the changes
# shutdown -r now
Now post reboot re-verify the default hugepage size. As expected this has changed to 1GB
# grep Hugepagesize: /proc/meminfo
Hugepagesize: 1048576 kB
Verify the GRUB2 configuration
# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.10.0-957.21.3.el7.x86_64 root=/dev/mapper/os-root ro novga console=ttyS0,115200 panic=1 numa=off elevator=cfq rd.md.uuid=2bf69f98:8507fb4d:bcd2633e:14aecb1c rd.lvm.lv=os/root rd.md.uuid=feef9526:9af37168:0e029a0d:1cf5a6d1 rd.md.uuid=5c13046e:592fe6da:bb4bb7cd:0057371a noht biosdevname=0 net.ifnames=0 rhgb quiet console=tty0 ipv6.disable=1 mds=off transparent_hugepage=never default_hugepagesz=1G
Lastly I hope the steps from the article to check if CPU supports HugePages and to change default hugepage size on Linux was helpful. So, let me know your suggestions and feedback using the comment section.