This documentation is described for following distributions.
- Ubuntu 16.04 and 18.04
- CentOS 7.6 (not fully supported)
1.1. Reserving Hugepages¶
Hugepages should be enabled for running DPDK application. Hugepage support is to reserve large amount size of pages, 2MB or 1GB per page, to less TLB (Translation Lookaside Buffers) and to reduce cache miss. Less TLB means that it reduce the time for translating virtual address to physical.
How to configure reserving hugepages is different between 2MB or 1GB. In general, 1GB is better for getting high performance, but 2MB is easier for configuration than 1GB.
1.1.1. 1GB Hugepage¶
For using 1GB page, hugepage setting is activated while booting system.
It must be defined in boot loader configuration, usually it is
Add an entry of configuration of the size and the number of pages.
Here is an example for Ubuntu, and almost the same as CentOS. The points are
hugepagesz is for the size and
hugepages is for the number of
You can also configure
isolcpus in grub setting for improving performance
as described in
# /etc/default/grub GRUB_CMDLINE_LINUX="default_hugepagesz=1G hugepagesz=1G hugepages=8"
For Ubuntu, you should run
update-grub for updating
/boot/grub/grub.cfg after editing to update grub’s
config file, or this configuration is not activated.
# Ubuntu $ sudo update-grub Generating grub configuration file ...
Or for CentOS7, you use
grub2-mkconfig instead of
In this case, you should give the output file with
The output path might be different, so you should find your correct
grub.cfg by yourself.
# CentOS $ sudo grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
1GB hugepages might not be supported on your hardware.
It depends on that CPUs support 1GB pages or not. You can check it
/proc/cpuinfo. If it is supported, you can find
pdpe1gb in the
$ cat /proc/cpuinfo | grep pdpe1gb flags : fpu vme ... pdpe1gb ...
1.1.2. 2MB Hugepage¶
For using 2MB page, you can activate hugepages while booting or at anytime
after system is booted.
Define hugepages setting in
/etc/default/grub to activate it while
booting, or overwrite the number of 2MB hugepages as following.
$ echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
In this case, 1024 pages of 2MB, totally 2048 MB, are reserved.
1.2. Mount hugepages¶
Make the memory available for using hugepages from DPDK.
$ mkdir /mnt/huge $ mount -t hugetlbfs nodev /mnt/huge
It is also available while booting by adding a configuration of mount
The mount point for 2MB or 1GB can be made permanently accross reboot.
For 2MB, it is no need to declare the size of hugepages explicity.
# /etc/fstab nodev /mnt/huge hugetlbfs defaults 0 0
For 1GB, the size of hugepage
pagesize must be specified.
# /etc/fstab nodev /mnt/huge_1GB hugetlbfs pagesize=1GB 0 0
1.3. Disable ASLR¶
SPP is a DPDK multi-process application and there are a number of limitations .
Address-Space Layout Randomization (ASLR) is a security feature for memory protection, but may cause a failure of memory mapping while starting multi-process application as discussed in dpdk-dev .
ASLR can be disabled by assigning
0, or be enabled by assigning it to
# disable ASLR $ sudo sysctl -w kernel.randomize_va_space=0 # enable ASLR $ sudo sysctl -w kernel.randomize_va_space=2
You can check the value as following.
$ sysctl -n kernel.randomize_va_space
1.4. Using Virtual Machine¶
SPP provides vhost interface for inter VM communication. You can use any of DPDK supported hypervisors, but this document describes usecases of qemu and libvirt.
1.4.1. Server mode v.s. Client mode¶
For using vhost, vhost port should be created before VM is launched in server mode, or SPP is launched in client mode to be able to create vhost port after VM is launched.
Client mode is optional and supported in qemu 2.7 or later.
For using this mode, launch secondary process with
Qemu creates socket file instead of secondary process.
It means that you can launch a VM before secondary process create vhost port.
If you use libvirt for managing virtual machines, you might need some additional configurations.
To have access to resources with your account, update and
activate user and group parameters in
Here is an example.
# /etc/libvirt/qemu.conf user = "root" group = "root"
For using hugepages with libvirt, change
KVM_HUGEPAGES from 0 to 1
# /etc/default/qemu-kvm KVM_HUGEPAGES=1
Change grub config as similar to Reserving Hugepages. You can check hugepage settings as following.
$ cat /proc/meminfo | grep -i huge AnonHugePages: 2048 kB HugePages_Total: 36 # /etc/default/grub HugePages_Free: 36 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 1048576 kB # /etc/default/grub $ mount | grep -i huge cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,...,nsroot=/) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime) hugetlbfs-kvm on /run/hugepages/kvm type hugetlbfs (rw,...,gid=117) hugetlb on /run/lxcfs/controllers/hugetlb type cgroup (rw,...,nsroot=/)
Finally, you umount default hugepages.
$ sudo umount /dev/hugepages
1.4.3. Trouble Shooting¶
You might encounter a permission error while creating a resource,
such as a socket file under
tmp/, because of AppArmor.
You can avoid this error by editing
# Set security_driver to "none" $sudo vi /etc/libvirt/qemu.conf ... security_driver = "none" ...
Restart libvirtd to activate this configuration.
$sudo systemctl restart libvirtd.service
Or, you can also avoid by simply removing AppArmor itself.
$ sudo apt-get remove apparmor
If you use CentOS, confirm that SELinux doesn’t prevent
SELinux is disabled simply by changing the configuration to
# /etc/selinux/config SELINUX=disabled
Check your SELinux configuration.
$ getenforce Disabled
1.5. Python 2 or 3 ?¶
Without SPP container tools, Python2 is not supported anymore. SPP container will also be updated to Python3.
1.6. Driver for Mellanox NIC¶
In case of using MLX5 NIC, you have to install driver. You can download driver from Mellanox’s SW/Drivers <https://www.mellanox.com/page/mlnx_ofed_matrix?mtag=linux_sw_drivers>. The following example assumes that MLNX_OFED_LINUX-4.7-220.127.116.11-ubuntu18.04-x86_64.tgz is downloaded.
$cd MLNX_OFED_LINUX-4.7-18.104.22.168-ubuntu18.04-x86_64/ $sudo ./mlnxofedinstall --upstream-libs --dpdk --force