Configuring HugeTLB Pages
Describes how to request HugeTLB pages with kernel boot parameters, sysfs settings, and NUMA-aware procedures.
You can configure HugeTLB pages by using the following types of parameters:
- Kernel boot parameters
- File-based configuration parameters
The following sections discuss the parameters in greater detail.
- Kernel Boot Parameters for HugeTLB Pages
- File-Based Configuration Parameters for HugeTLB Pages
- Configuring HugeTLB Pages by Using Kernel Parameters at Boot Time
- Configuring HugeTLB Pages Using NUMA Node Specific Parameters Early in the Boot Process
- Configuring HugeTLB Pages for a Specific NUMA Node at Runtime
Kernel Boot Parameters for HugeTLB Pages
The kernel boot options enable you to specify values such as the size and the number of pages to be reserved in the kernel's pool. Using the kernel boot parameters is the most reliable method of requesting huge pages.
| Parameters | Purpose | Accepted Value Option on x86_64 Architecture |
|---|---|---|
default_hugepagesz | Defines the default size of persistent huge pages configured in the kernel at boot time. | 2M (default), 1G |
hugepagesz and
hugepages | Size parameter
If multiple huge page sizes are supported, the
" |
|
In a NUMA system, pages reserved with kernel command line options, as shown in the previous table, are divided equally between the NUMA nodes.
If the
requirement is to have a different number of pages on each node, you can use the
file-based HugeTLB parameters in the sysfs file system. See File-Based Configuration Parameters for HugeTLB Pages and Configuring HugeTLB Pages Using NUMA Node Specific Parameters Early in the Boot Process.
File-Based Configuration Parameters for HugeTLB Pages
In addition to accessing the settings at runtime, you can also initialize the parameters early in the boot process, for example, by creating a start-up bash script or by setting the parameters up in a local rc init script.
nr_hugepages settings can exist. This parameter defines the number of pages
in a pool, including the following:- File
/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepagesfor the number of pages in the pool of 2 MB pages. - File
/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepagesfor the number of pages in the pool of 1 GB pages.
The following table outlines commonly used HugeTLB configuration parameters and the multiple file instances that you might find for each parameter.
| Parameter | Purpose | File Paths for Different Instances |
|---|---|---|
nr_hugepages
|
|
The file path formats for different instances of
nr_hugepages are as follows:
|
nr_overcommit_hugepages
|
|
The file path formats for different instances of nr_overcommit_hugepages are as follows:
The |
free_hugepages
|
|
The file path formats for different instances of
|
surplus_hugepages
|
|
The file path formats for different instances of
|
The following sections show file branches under which different instances of the HugeTLB parameters are stored:
/proc/sys/vm
All systems that support static huge pages contain HugeTLB parameter files under
/proc/sys/vm.
On many systems, including many Oracle database servers, the
procfs file system is the main parameter-set used.
The sysctl parameter vm.nr_hugepages that's commonly
initialized in scripts that request huge pages also writes to the procfs
file /proc/sys/vm/nr_hugepages.
The following are example folders under branch /proc/sys/vm:
├── ...
├── ...
├── nr_hugepages
├── ...
├── nr_overcommit_hugepages
├── ...
├── ...
/sys/kernel/mm/hugepages/
Systems that support multiple size pools contain HugeTLB parameter files in size-specific
folders under /sys/kernel/mm/hugepages/.
The following are example folders under branch /sys/kernel/mm/hugepages/:
└── hugepages-2048kB
├── free_hugepages
├── nr_hugepages
├── ...
├── nr_overcommit_hugepages
├── ...
└── surplus_hugepages
└── hugepages-1048576kB
├── free_hugepages
├── nr_hugepages
├── ...
├── nr_overcommit_hugepages
├── ...
└── surplus_hugepages
/sys/devices/system/node/
Only NUMA systems contain HugeTLB parameter files under
/sys/devices/system/node/.
The following are example folders under branch
/sys/devices/system/node:
├─ ...
├── node0
│ ├── ...
│ ├──hugepages
│ hugepages-2048kB
│ ├── free_hugepages
│ ├── nr_hugepages
│ └── surplus_hugepages
│
│ hugepages-1048576kB
│ ├── free_hugepages
│ ├── nr_hugepages
│ └── surplus_hugepages
├── node1
├── ...
├──hugepages
hugepages-2048kB
├── free_hugepages
├── nr_hugepages
└── surplus_hugepages
hugepages-1048576kB
├── free_hugepages
├── nr_hugepages
└── surplus_hugepages
Configuring HugeTLB Pages by Using Kernel Parameters at Boot Time
Use the grubby command to configure kernel command line options that the system uses at boot time to set up HugeTLB pages.
- A default page size of 1 GB.
- One pool with four HugeTLB pages of 1 GB size.
- One pool of 1500 HugeTLB pages of 2 MB size.
Before beginning the following procedure, ensure that you have the administrative privileges required.
For more information about configuring kernel command line options and GRUB 2, see Managing Kernels and System Boot on Oracle Linux.
Configuring HugeTLB Pages Using NUMA Node Specific Parameters Early in the Boot Process
Provides a systemd-based workflow for reserving different HugeTLB allocations on specific NUMA nodes during startup.
The precise way to request huge pages at boot time depends upon the system's requirements. The following procedure provides some guidance but isn't exclusive of other approaches to configuring boot options.
Huge Pages requested by using the kernel boot-time parameters, as shown in the previous example, are divided equally between the NUMA nodes.
However, you might need to request a different number of huge pages for specific nodes by setting the configuration values in a node-specific file path. The file path is defined as follows:
/sys/devices/system/node/node{0,1,2...n}/hugepages/hugepages-<SIZE>kB/
The following procedure describes how to reserve 299 pages of 2 MB size on node 0,
and 300 pages of 2 MB size on node 1 on a NUMA system. This approach uses a custom
systemd service to run a shell script after boot, to set the sysfs
parameters required.
Before beginning the following procedure, ensure that you have the administrative privileges required for all the steps.
For more information about using systemd units, see Managing the System With systemd.
Configuring HugeTLB Pages for a Specific NUMA Node at Runtime
In certain cases, you might need to make a request for huge pages at runtime.
The following procedure shows how to request 20 HugeTLB pages of size 2048 kB for node2 at runtime.
Before starting, ensure you have the administrative privileges required for all
the steps. The procedure uses the numastat command, which is available in
the numactl package. You might need to install this package
beforehand.