Configuring HugePages on Linux

HugePages is a feature integrated into the Linux kernel. For Oracle Database, using HugePages reduces the operating system maintenance of page states and increases Translation Lookaside Buffer (TLB) hit ratio.

To configure HugePages on Linux:
  1. Check if the kernel supports HugePages:
    $ grep Huge /proc/meminfo
  2. Some Linux systems do not support HugePages by default. For such systems, build the Linux kernel using the CONFIG_HUGETLBFS and CONFIG_HUGETLB_PAGE configuration options. CONFIG_HUGETLBFS is located under File Systems and CONFIG_HUGETLB_PAGE is available when you select CONFIG_HUGETLBFS.
  3. Edit the memlock setting in the /etc/security/limits.conf file.
    Specify the memlock setting in KB. Set the maximum locked memory limit to at least 90 percent of the current RAM when you enable HugePages memory and at least to 3145728 KB (3 GB) if you disable HugePages. For example, if you have 64 GB RAM, then add the following entries to increase the maximum locked-in-memory address space:
    *   soft   memlock    60397977
    *   hard   memlock    60397977
    You can also set the memlock value higher than your SGA requirements.
  4. Log in as the oracle user again and run the ulimit -l command to verify the new memlock setting:
    $ ulimit -l
    60397977
  5. Run the following command to display the value of the Hugepagesize variable:
    $ grep Hugepagesize /proc/meminfo
  6. Complete the following procedure to create a script that computes recommended values for hugepages configuration for the current shared memory segments:
    1. Create a text file hugepages_settings.sh
      See My Oracle Support note 401749.1 to create the hugepages_settings.sh script.
    2. Change the permission of the hugepages_settings.sh file:
      $ chmod +x hugepages_settings.sh
  7. Run the hugepages_settings.sh script to compute values for the hugepages configuration.
    $ ./hugepages_settings.sh

    Note:

    Before you run this script, ensure that all the applications that use hugepages run.
  8. Set the following kernel parameter, where value is the HugePages value that you determined in Step 7:
    # sysctl -w vm.nr_hugepages=value
  9. To ensure that HugePages is allocated after the system restarts, add the following entry to the /etc/sysctl.conf file, where value is the HugePages value that you determined in Step 7:
    vm.nr_hugepages=value

    Note:

    If you cannot set your HugePages allocation using nr_hugepages, then your available memory may be fragmented. Restart your server for the Hugepages allocation to take effect.
  10. Run the following command to check the available hugepages:
    $ grep Huge /proc/meminfo
  11. Restart the instance.
  12. Run the following command to check the available hugepages (1 or 2 pages free):
    $ grep Huge /proc/meminfo