Explicit Huge Pages V/s Transparent Huge Pages


There can be two types of HugePages in the system: Explicit Huge Pages which are allocated explicitly by vm.nr_hugepages sysctl parameter and Transparent Huge Pages which are allocated automatically by the kernel.


Verify if THP is enabled


tuned.service” on CentOS / RHEL 7 set the transparent_hugepage to always by default. Even if its disabled in grub kernel command line, the tuned service will set it to ‘always‘ during boot. Below command output confirm that the THP are enabled on the system.

# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never 


Note : Transparent Huge Pages cannot be enabled/disabled on a running machine and requires a reboot.


Steps to disable THP


1. Add the “transparent_hugepage=never” kernel parameter option to the grub2 configuration file. Append or change the “transparent_hugepage=never” kernel parameter on the GRUB_CMDLINE_LINUX option in /etc/default/grub file.

# vi /etc/default/grub
GRUB_CMDLINE_LINUX="nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet transparent_hugepage=never"


2. Rebuild the /boot/grub2/grub.cfg file by running the grub2-mkconfig -o command. Before rebuilding the GRUB2 configuration file, ensure to take a backup of the existing /boot/grub2/grub.cfg.


On BIOS-based machines

# grub2-mkconfig -o /boot/grub2/grub.cfg


On UEFI-based machines

# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg


3. Reboot the system and verify option are in effect.

 # shutdown -r now


4. Verify the parameter is set correctly

 # cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.10.0-514.10.2.el7.x86_64 root=/dev/mapper/vg_os-lv_root ro nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet transparent_hugepage=never LANG=en_US.UTF-8




If Transparent Huge Pages (THP) is still not disabled, continue and use one of the options below.


1. Disable tuned services


Disable the tuned services if it is re-enabling the THP using either of the below commands.

 # systemctl stop tuned
# systemctl disable tuned


 # tuned-adm off


2. Create a customized tuned profile with disabled THP


1. Another and recommended way is to create a customized tuned profile with THP disabled. Find out which profile is active, create a copy. In the following example we currently use the throughput-performance profile:

# tuned-adm active
Current active profile: throughput-performance 


2. To create a customized profile, create a new directory in /etc/tuned directory with the desired profile name.

 # mkdir /etc/tuned/nothp_profile


3. Then create a new tuned.conf file for nothp_profile, and insert the new tuning info:

# cat /etc/tuned/nothp_profile/tuned.conf 
include= throughput-performance



4. Make the script executable.

# chmod +x /etc/tuned/nothp_profile/tuned.conf 


5. Enable nothp_profile using the tuned-adm command.

 # tuned-adm profile nothp_profile


6. This change will immediately take effect and persist reboots. To verify if THP are disabled or not, run below command:

 # cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]


Was this answer helpful? 0 Users Found This Useful (0 Votes)