Configuring Huge Pages for DPDK

dperf is a high-performance open-source network load tester. Before using dperf, it's necessary to configure huge pages. This article provides guidance on how to set up huge pages.

Determining the Number of Huge Pages

You can determine how many huge pages to set by checking your system's available memory. Use the free -g command to view the total memory in gigabytes. It's recommended to set the number of huge pages to half of the system's memory. If dperf reports insufficient memory, you can increase the number of huge pages accordingly.

[root]# free -g
              total        used        free      shared  buff/cache   available
Mem:            376         146         208           1          20         227
Swap:             3           0           3

In the example above, the system has 376 GB of memory. Setting 50% of this memory as huge pages would be recommended. If needed, you can increase the number later.

Checking the Huge Page Size

Usually, a huge page size of 1 GB is set. You need to confirm whether your system supports 1 GB huge pages.

For X86_64 Processors

Check if your processor supports 1 GB huge pages by running:

cat /proc/cpuinfo | grep pdpe1gb

If you see pdpe1gb, it means your system supports 1 GB huge pages; otherwise, the page size might be 4 MB (to be confirmed).

For ARM64 Processors

ARM64 processors are likely to support 1 GB huge pages.

Setting Huge Pages

For Environments Supporting 1 GB Huge Pages

Edit or set /boot/grub2/grub.cfg to add parameters to the Linux kernel:

linux16 /vmlinuz-xxx ... transparent_hugepage=never default_hugepagesz=1G hugepagesz=1G hugepages=140

In the example above, each huge page is set to 1 GB, and 140 huge pages are allocated.

For Environments Not Supporting 1 GB Huge Pages

For systems not supporting 1 GB huge pages, use the following format:

linux16 /vmlinuz-xxx ... transparent_hugepage=never hugepages=1024

In this example, 1024 huge pages are set, but the exact size of each huge page may be 4 MB (to be confirmed).

For VMware Virtual Machine Environments

In VMware virtual machine environments, you need to add an additional "nopku" parameter:

linux16 /vmlinuz-3.10.0-957.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_US.UTF-8 nopku transparent_hugepage=never default_hugepagesz=1G hugepagesz=1G hugepages=8

ARM Environment (Multiple NUMA Nodes)

In ARM environments with multiple NUMA nodes, it's advisable to set huge pages on only one NUMA node. For example, to set 200 huge pages, each with a size of 512 MB on node0:

echo 200 > /sys/devices/system/node/node0/hugepages/hugepages-524288kB/nr_hugepages

Verifying Configured Huge Pages

After configuring huge pages using kernel boot parameters, you need to restart the system for the changes to take effect. You can check the configured huge pages using the following command:

[root]# cat /proc/meminfo | grep Huge
AnonHugePages:         0 kB
HugePages_Total:     140
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:    1048576 kB

In the output, you can see that the system is configured with 140 huge pages, each with a size of 1,048,576 kB (1 GB).