Working with hugetlbfs large page support

Typical tasks for working with hugetlbfs large page support include reading the current number of large pages, changing the number of large pages, and display information about available large pages.

About this task

The large page memory can be used through mmap() or SysV shared memory system calls. More detailed information can be found in the Linux® kernel source tree under Documentation/vm/hugetlbpage.txt, including implementation examples.

Your database product might support large page memory. See your database documentation to find out if and how it can be configured to use large page memory.

Depending on your version of Java, you might require specific options to make a Java™ program use the large page feature. For IBM® SDK, Java Technology Edition 7, specify the -Xlp option. If you use the SysV shared memory interface, which includes java -Xlp, you must adjust the shared memory allocation limits to match the workload requirements. Use the following sysctl attributes:
/proc/sys/kernel/shmall
Defines the global maximum amount of shared memory for all processes, specified in number of 4 KB pages.
/proc/sys/kernel/shmmax
Defines the maximum amount of shared memory per process, specified in number of Bytes.
For example, the following commands would set both limits to 20 GB:
# echo 5242880 > /proc/sys/kernel/shmall
# echo 21474836480 > /proc/sys/kernel/shmmax

Procedure

  • Specify the hugepages= kernel parameter with the number of large pages to be allocated at boot time. To read the current number of default-sized large pages, issue:
    # cat /proc/sys/vm/nr_hugepages
  • To change the number of default-sized large pages dynamically during runtime, write to procfs:
    # echo 12 > /proc/sys/vm/nr_hugepages
    If there is not enough contiguous memory available to fulfill the request, the maximum possible number of large pages are reserved.
  • To obtain information about the number of default-sized large pages currently available and the default large page size, issue:
    # cat /proc/meminfo
    
    ...
    HugePages_Total: 20
    HugePages_Free: 14
    HugePages_Rsvd: 0
    HugePages_Surp: 0
    Hugepagesize: 1024 KB
    ...
  • To adjust characteristics of a large-page pool, when more than one pool exists, use the sysfs attributes of the pool.
    These can be found under
    /sys/kernel/mm/hugepages/hugepages-<size>/nr_hugepages
    Where <size> is the page size in KB.

Example

To allocate 2 GB large pages:
  1. Specify 2 GB large pages and pre-allocate them to the page pool at boot time. Use the following kernel boot parameters:
    default_hugepagesz=2G hugepagesz=2G hugepages=4
  2. After booting, read /proc/meminfo to see information about the amount of large pages currently available and the large page size:
    cat /proc/meminfo
    ...
    HugePages_Total: 4
    HugePages_Free: 4
    HugePages_Rsvd: 0
    HugePages_Surp: 0
    Hugepagesize: 2097152 kB
    ...