Changing the Current Status of Transparent HugePages

This procedure shows how to change the current status of THP by setting a value in the sysfs virtual file system.

For more information about using the sysfs virtual file system, see Oracle Linux 8: Managing Kernels and System Boot

To change the current status of THP, you need to write the preferred settings to /sys/kernel/mm/transparent_hugepage/enabled. The following example shows you how to set the status to always.

Note:

Virtual file systems such as sysfs provide a file system interface to items that aren't necessarily stored as files on disk. The sysfs files therefore don't always interact with file commands in the same way that regular physical files on disk would. In the example procedure, the echo command used doesn't overwrite /sys/kernel/mm/transparent_hugepage/enabled, as it would if used with a regular file, but instead changes the selected option.

  1. Check the current status of THP by reading the enabled parameter.
    sudo cat /sys/kernel/mm/transparent_hugepage/enabled
    always madvise [never]

    The value inside the square brackets represents the current setting.

  2. Set THP mode to always.
    echo always | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
  3. Confirm the change has been successful by reading the enabled parameter.
    sudo cat /sys/kernel/mm/transparent_hugepage/enabled
    [always] madvise never