• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL 7 : How to disable Transparent Huge pages (THP)

by admin

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_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
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"
GRUB_DISABLE_RECOVERY="true"

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

Troubleshooting

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

OR

# 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 customized profile, create a new directory in /etc/tuned directory with 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 
[main]
include= throughput-performance

[vm]
transparent_hugepages=never

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]
CentOS / RHEL 6 : How to disable Transparent Huge pages (THP)

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How to Migrate virtual machines from one host to another in the Red Hat Virtualization environment
  2. apache2ctl: command not found
  3. ubuntu-drivers: command not found
  4. CentOS / RHEL : How to get the date and time of executed command in the history command output
  5. UNIX / Linux : How to lock or disable an user account
  6. iftop: command not found
  7. How to restrict ssh logins by user and client address on CentOS/RHEL
  8. CentOS / RHEL : How to add, delete and display LVM tags
  9. dpkg-scanpackages: command not found
  10. How to Enable IPv6 In CentOS / RHEL 5

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright