Running DPDK
Configuring Huge Page Memory
Huge pages can improve DPDK forwarding performance. The huge page size of up to 1 GB is supported. However, kernel 4.14 does not support 1 GB. To use 1 GB huge pages, upgrade the kernel.
Kernel 4.14 supports 2 MB and 512 MB huge pages by default. The following example uses the kernel supporting 512 MB huge pages. The method for the kernel supporting 2 MB huge pages is similar and is not described in this document.
- Check the number of NUMA nodes supported by the current environment and reserve huge page memory for each node based on the number of NUMA nodes.
numactl -H

- Check the huge page types supported by the system.
ll /sys/kernel/mm/hugepages/
If hugepages-524288kB is displayed in the command output, 512 MB huge pages are supported.
If hugepages-1048576kB is displayed in the command output, 1 GB huge pages are supported.
By default, the largest huge page size is preferred. Select this option when needed.
- Reserve huge page memory.
- Configure 512 MB huge pages.
- Configure the number of huge pages.
1 2 3 4
echo 50 > /sys/devices/system/node/node0/hugepages/hugepages-524288kB/nr_hugepages echo 50 > /sys/devices/system/node/node1/hugepages/hugepages-524288kB/nr_hugepages echo 50 > /sys/devices/system/node/node2/hugepages/hugepages-524288kB/nr_hugepages echo 50 > /sys/devices/system/node/node3/hugepages/hugepages-524288kB/nr_hugepages
- Mount the huge pages.
1 2
mkdir -p /mnt/huge_512mb mount -t hugetlbfs none /mnt/huge_512mb -o pagesize=512MB
- Configure the number of huge pages.
- (Optional, requiring system support) Configure 1 GB huge pages.
- Open the /etc/default/grub file.
vi /etc/default/grub
- Modify the system startup items and reserve 16 1 GB huge pages. The total size is 16 GB. Add the following settings to the end of the GRUB_CMDLINE_LINUX line:
default_hugepagesz=1G hugepagesz=1G hugepages=16
- Generate a grub configuration file and reboot the system for the configuration to take effect.
grub2-mkconfig -o /boot/efi/EFI/openeuler/grub.cfg
- Check whether the configuration is successful.
cat /proc/meminfo | grep -i huge
If the command output shows that the number of configured huge pages is 16, the configuration is successful.
- Mount the huge pages.
1 2
mkdir -p /mnt/huge_1gb mount -t hugetlbfs none /mnt/huge_1gb -o pagesize=1GB
- Open the /etc/default/grub file.
- Configure 512 MB huge pages.
Take over the port in kernel mode.
- Load the kernel driver module. (To use VFIO, enable SMMU in the BIOS.)
1 2
modprobe vfio modprobe vfio-pci
- Bind the tested port in user mode for DPDK forwarding. Obtain the PCI address of the network port. You can use the usertools/dpdk-devbind.py script of the DPDK source code to view the PCI address and bind the port.
- View information about the port to be bound.
1dpdk-devbind.py -s
- Check the port status and take over the port whose link status is up.
1ethtool enp125s0f1
- Bind the network port used for DPDK forwarding. The following uses the network port 0000:7d:00.1 as an example. Replace it as required.
1dpdk-devbind.py --bind=vfio-pci 0000:7d:00.1
Check whether the port is successfully bound.
1dpdk-devbind.py -s
If you bind a port when the port is in the up state, an error is reported. In this case, run the ifconfig xxx down command and then bind the port again.
- View information about the port to be bound.
Running DPDK
After the preceding configuration is complete, you can run the DPDK test program. As an example, this document uses the standard test program testpmd generated by compiling DPDK. Run the following command based on the actual environment information:
1 | testpmd -c 0xf -n 4 -w $PCI -- --rxd=$depth --txd=$depth --rxq=$qnum --txq=$qnum --nb-cores=$cores -i |
testpmd is a test command in DPDK 19.11. If DPDK 21.11.5 is used, replace testpmd with dpdk-testpmd.
Parameter |
Description |
|---|---|
-c |
Specifies the CPU core that is used for forwarding, followed by the mask of the forwarding core. |
-n |
Specifies the number of memory channels. |
-w |
Specifies the PCI address of the network port for forwarding, that is, the PCI address of the network port bound in Installing DPDK 19.11. |
--rxd/--txd |
Specifies the queue depth of the port for forwarding. |
--rxq/--txq |
Specifies the number of port queues for forwarding. |
--nb-cores |
Specifies the number of CPU cores for forwarding. |
-i |
Starts the program in interactive mode. |