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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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 Use Iperf to Test Network Performance in Linux
  2. CentOS / RHEL : How to find which user run a specific command?
  3. How to Test Port [TCP/UDP] Connectivity from a Linux Server
  4. Beginners Guide to Managing Package Module Streams in CentOS/RHEL 8
  5. Beginners Guide to yum Configuration
  6. Volume “test_vg/lvol0” is not active locally – Error while running lvcreate
  7. Understanding The /etc/sysconfig Directory
  8. CentOS / RHEL 5 : dm-multipath file /etc/sysconfig/mkinitrd/multipath explained
  9. What are DNS Nameserver Types in Linux
  10. How to disable IPv6 on CentOS / RHEL 5

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable ACPI in CentOS/RHEL 7
  • How to Use real-time query to access data on a physical standby database
  • CentOS/RHEL 8: “ACPI MEMORY OR I/O RESET_REG” Server Hung after reboot
  • How to Create a Physical Standby Database by Using SQL and RMAN Commands
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary