Setting Transparent HugePages to madvise

Transparent HugePages memory is enabled by default with Oracle Linux. However, for optimal performance, Oracle recommends that you set Transparent HugePages to madvise on all Oracle Database servers UEK7 and later kernels and not disable Transparent HugePages as was recommended in prior releases.

If you install Oracle Database Preinstallation RPM, then it sets Transparent HugePages to madvise on all Oracle Database servers UEK7 and later kernels.

To set madvise on Transparent HugePages:

  1. For Oracle Linux and Red Hat Enterprise Linux, add or modify the transparent_hugepage=madvise parameter in the /etc/default/grub file:
    GRUB_TIMEOUT=5
    GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
    GRUB_DEFAULT=saved
    GRUB_DISABLE_SUBMENU=true
    GRUB_TERMINAL_OUTPUT="console"
    GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet numa=off transparent_hugepage=madvise"
    GRUB_DISABLE_RECOVERY="true"

    Note:

    The file name may vary depending on your operating system and hardware. For example, on Oracle Cloud Infrastructure (OCI) the grub.cfg file is located at /boot/efi/EFI/redhat/. Check your operating system documentation for the exact file name.
  2. Run the grub2–mkconfig command to regenerate the grub.cfg file.

    On Oracle Linux 8

    # grub2-mkconfig -o /boot/grub2/grub.cfg

    On Oracle Linux 9

    grub2-mkconfig -o /boot/grub2/grub.cfg --update-bls-cmdline
  3. Restart the system to make the changes permanent. If you do not want to restart your system, then enter the following command:
    # echo madvise >
          /sys/kernel/mm/transparent_hugepage/enabled
  4. To check if Transparent HugePages is enabled and configured with madvise, run one of the following commands as the root user:

    Oracle Linux kernels:

    # cat /sys/kernel/mm/transparent_hugepage/enabled

    Red Hat Enterprise Linux kernels:

    # cat /sys/kernel/mm/redhat_transparent_hugepage/enabled

    The following is a sample output that shows Transparent HugePages is being used and set to madvise.

    always [madvise] never