• 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 modify snmp service to listen to an alternative port in CentOS/RHEL
  2. How to query and modify kernel parameters using sysctl (Immediately and persistently) in CentOS / RHEL
  3. How to Check Swap Usage Live via the ‘top’ Command in Linux
  4. How to Migrate CentOS/RHEL 6 iptables Rules to CentOS/RHEL 7 firewalld
  5. OpenLDAP Server and Client Utilities list
  6. CentOS / RHEL : Resize (reduce) non-root EXT3/4 filesystem on non-LVM device (hard disk partition)
  7. fdisk: Unable to write /dev/sdg: Bad file descriptor – error while formatting USB disk
  8. How to use ‘yum’ to connect ULN on CentOS/RHEL/OEL 6
  9. How to increase swap space on Linux
  10. XFS error: Unable to mount filesystem With Noacl Permission in CentOS/RHEL 7

You May Also Like

Primary Sidebar

Recent Posts

  • Oracle Database – Configuring Secure Application Roles
  • Extend rule sets by using factors in Oracle Database Vault
  • What are Command Rules in oracle Database
  • Using Rule Sets in Oracle Database Vault
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary