How to disable transparent hugepages (THP) on Red Hat Enterprise Linux?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 7 or later major version
  • transparent hugepages (THP)
  • tuned

Issue

  • How to disable transparent hugepages (THP) on Red Hat Enterprise Linux 7 or later?
  • Disabling transparent hugepages (THP) on Red Hat Enterprise Linux 7 is not taking effect.

Resolution

Follow the steps below

  • Add the transparent_hugepage=never to kernel command line.

      # grubby --args="transparent_hugepage=never" --update-kernel=ALL
    
  • Execute the zipl command for the s390x arch systems after making the above changes in the kernel commandline, to bring these changes into effect. Then follow the remaining steps as mentioned below.

  • System needs to be rebooted to apply the changes.

      # systemctl reboot
    
  • After rebooting there are several ways to confirm the change:

      # cat /proc/cmdline
      ( the transparent_hugepage=never argument should appear )
    
      # cat /sys/kernel/mm/transparent_hugepage/enabled
      always madvice [never]
    
      # grep AnonHugePages: /proc/meminfo
      AnonHugePages:        0 kB
    
      # grep nr_anon_transparent_hugepages /proc/vmstat
      nr_anon_transparent_hugepages 0
    

 


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:

        # tuned-adm active
        Current active profile: throughput-performance
      
    • To create customized profile, create a new directory in /etc/tuned directory with desired profile name.

        # mkdir /etc/tuned/myprofile-nothp
      
    • Then create a new tuned.conf file for myprofile-nothp, and insert the new tuning info:

        # cat /etc/tuned/myprofile-nothp/tuned.conf 
        [main]
        include=throughput-performance
      
        [vm]
        transparent_hugepages=never
      
    • Make the script executable:

        # chmod +x /etc/tuned/myprofile-nothp/tuned.conf 
      
    • Enable myprofile like so:

        # tuned-adm profile myprofile-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
        # systemctl disable 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.

Note: To enable transparent hugepages (THP) this process can be followed in reverse. Use...

    # grubby --remove-args=transparent_hugepage --update-kernel=ALL

    # systemctl reboot
SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.