Configuring Huge Pages
Hugepage memory is used to improve memory access efficiency and Gazelle performance.
- Disable transparent huge pages.
1echo never > /sys/kernel/mm/transparent_hugepage/enabled
- Check the huge page size supported by the system.
1ls /sys/kernel/mm/hugepages
The huge page type of each size supported by the system corresponds to a subdirectory in the /sys/kernel/mm/hugepages directory.
- Check the default huge page size.
1cat /proc/meminfo | grep Hugepagesize

- Optional: If you want to remain the current default huge page size, skip this step. If you need to change the default huge page size, perform this step.
- Open the /boot/efi/EFI/openEuler/grub.cfg file.
1vi /boot/efi/EFI/openEuler/grub.cfg - Press i to enter the insert mode, find the startup item menuentry in line 92, and add the following content to the end of line 104 to set the default huge page size to 2 MB and the huge page size supported by the system to 2 MB:
1default_hugepagesz=2M hugepagesz=2M

- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Reboot the server for the configuration to take effect.
1reboot
- Check the default huge page size.
cat /proc/meminfo | grep Hugepagesize
The default huge page size has been changed to 2,048 KB, that is, 2 MB.

- Open the /boot/efi/EFI/openEuler/grub.cfg file.
- Create a hugepage directory. In this example, 512 MB hugepage memory is used. Set the size as required.
1mkdir /data/hugepages - Mount the huge pages.
Do not run this command repeatedly. Otherwise, huge pages will be continuously occupied and cannot be released. You can run the mount |grep hugepages command to check whether the command has been executed. If the command output shows that the huge pages have been mounted to the /data/hugepages directory, the command has been executed.
1mount -t hugetlbfs nodev /data/hugepages
- Run the following commands to allocate huge pages. In this example, four huge pages are allocated to NUMA Node1 in the system due to NIC affinity. The size of each huge page is 524,288 KB, that is, 512 MB.
1echo 4 > /sys/devices/system/node/node1/hugepages/hugepages-524288kB/nr_hugepages
- The allocated hugepage memory cannot exceed the NUMA node memory. Run the following command to check the NUMA node memory:
1numactl --hardware | grep -i size
- In a production environment, you need to reserve memory for other applications.
- In this TPC-C test scenario, 2 GB is allocated to NUMA Node1 based on the memory usage during the stress test. Divide 2 GB by 512 MB, that is, four huge pages need to be allocated. You need to allocate hugepage memory based on actual conditions.
- Run the following command to view the NUMA nodes with NIC affinity. In the command, enp3s0 indicates the name of the service NIC. Change it to the actual NIC name in your case.
1cat /sys/class/net/enp3s0/device/numa_node
- The allocated hugepage memory cannot exceed the NUMA node memory. Run the following command to check the NUMA node memory:
- Check whether the huge pages are successfully configured.
1cat /proc/meminfo | grep Huge
If the command output shows huge page allocation details, the configuration is successful.

- HugePages_Total indicates the number of huge pages.
- HugePages Free indicates the number of huge pages that are not used by programs.
- Hugepagesize indicates the default huge page size.
- Hugetlb indicates the total capacity of the hugepage pool, that is, the value of Hugepagesize multiplied by HugePages_Total.
Parent topic: Manual Configuration