How to disable transparent hugepages (THP) on Red Hat Enterprise Linux 7, 8 and 9
How to disable transparent hugepages (THP) on Red Hat Enterprise Linux 7, 8 and 9
・ How to disable transparent hugepages (THP) on Red Hat Enterprise Linux 7, 8 and 9.pdf |
Environment
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
- transparent hugepages (THP)
- tuned
Issue
- How to disable transparent hugepages (THP) on Red Hat Enterprise Linux 7, 8 and 9
- Disabling transparent hugepages (THP) on Red Hat Enterprise Linux 7 is not taking effect.
Resolution
Follow the steps below.
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. Only include the parameter once.
cp -p /etc/default/grub{,.bak.`date +%Y%m%d`} |
Verify the parameter is set correctly, like GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap ... transparent_hugepage=never
sed -n '/GRUB_CMDLINE_LINUX/p' /etc/default/grub |
Rebuild the /boot/grub2/grub.cfg file by running the grub2-mkconfig -o command as follows:
Please ensure to take a backup of the existing /boot/grub2/grub.cfg before rebuilding.
Detect whether Linux runs in UEFI or BIOS mode: [ /sys/firmware/efi ] && echo UEFI || echo BIOS
- On BIOS-based machines: ~]#
grub2-mkconfig -o /boot/grub2/grub.cfg - On UEFI-based machines: ~]#
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Reboot the system and verify option has been added.
shutdown -r now |
Verify the parameter is set correctly
~]$ cat /proc/cmdline |
If Transparent Huge Pages (THP) is still not disabled, continue and use one of the options below
Option 1: (Recommended) create a customized tuned profile with disabled THP
With this resolution we will create a customized version of the currently running profile. The customized version will disable THP.
Find out which profile is active, create a copy. In the following example we currently use the throughput-performance profile:
~]$ sudo tuned-adm active |
Current active profile: throughput-performance
To create customized profile, create a new directory in /etc/tuned directory with desired profile name.
sudo mkdir /etc/tuned/profile-nothp |
Then create a new tuned.conf file for profile-nothp, and insert the new tuning info:
sudo bash -c "cat > /etc/tuned/profile-nothp/tuned.conf" <<EOF |
Make the script executable:
sudo chmod +x /etc/tuned/profile-nothp/tuned.conf |
Enable myprofile like so:
sudo tuned-adm profile profile-nothp |
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 |
Option 2: (Alternative) Disable tuned services
This resolution will disable the tuned services.
systemctl stop tuned |
OR
tuned-adm off |
Now add "transparent_hugepage=never" kernel parameter in grub2 configuration file as explained in steps 1-3 above.
Reboot the server for changes to take effect.