Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

8.3.3.3. Enabling 1 GB huge pages for guests at boot or runtime

Red Hat Enterprise Linux 6.7 systems support 2 MB and 1 GB huge pages, which can be allocated at boot or at runtime.

Procedure 8.2. Allocating 1 GB huge pages at boot time

  1. To allocate different sizes of huge pages at boot, use the following command, specifying the number of huge pages. This example allocates 4 1 GB huge pages and 1024 2 MB huge pages:
    'default_hugepagesz=1G hugepagesz=1G hugepages=4 hugepagesz=2M hugepages=1024'
    
    Change this command line to specify a different number of huge pages to be allocated at boot.

    Note

    The next two steps must also be completed the first time you allocate 1 GB huge pages at boot time.
  2. Mount the 2 MB and 1 GB huge pages on the host:
    # mkdir /dev/hugepages1G
    # mount -t hugetlbfs -o pagesize=1G none /dev/hugepages1G
    # mkdir /dev/hugepages2M
    # mount -t hugetlbfs -o pagesize=2M none /dev/hugepages2M
    
  3. Restart libvirtd to enable the use of 1 GB huge pages on guests:
    # service restart libvirtd
    
1 GB huge pages are now available for guests.

Procedure 8.3. Allocating 1 GB huge pages at runtime

1 GB huge pages can also be allocated at runtime. Runtime allocation allows the system administrator to choose which NUMA node to allocate those pages from. However, runtime page allocation can be more prone to allocation failure than boot time allocation due to memory fragmentation.
  1. To allocate different sizes of huge pages at runtime, use the following command, replacing values for the number of huge pages, the NUMA node to allocate them from, and the huge page size:
    # echo 4 > /sys/devices/system/node/node1/hugepages/hugepages-1048576kB/nr_hugepages
    # echo 1024 > /sys/devices/system/node/node3/hugepages/hugepages-2048kB/nr_hugepages
    
    This example command allocates 4 1 GB huge pages from node1 and 1024 2MB huge pages from node3.
    These huge page settings can be changed at any time with the above command, depending on the amount of free memory on the host system.

    Note

    The next two steps must also be completed the first time you allocate 1 GB huge pages at runtime.
  2. Mount the 2 MB and 1 GB huge pages on the host:
    # mkdir /dev/hugepages1G
    # mount -t hugetlbfs -o pagesize=1G none /dev/hugepages1G
    # mkdir /dev/hugepages2M
    # mount -t hugetlbfs -o pagesize=2M none /dev/hugepages2M
    
  3. Restart libvirtd to enable the use of 1 GB huge pages on guests:
    # systemctl restart libvirtd