1. Setup

This documentation is described for Ubuntu 16.04 and later.

1.1. Reserving Hugepages

Hugepages must be enabled for running DPDK with high performance. Hugepage support is required 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.

Hugepage reservation might be different for 2MB or 1GB.

For 1GB page, hugepage setting must be activated while booting system. It must be defined in boot loader configuration, usually is /etc/default/grub. Add an entry to define pagesize and the number of pages. Here is an example. hugepagesz is for the size and hugepages is for the number of pages.

You can also configure isolcpus for performance tuning as described in Performance Optimizing.

# /etc/default/grub
GRUB_CMDLINE_LINUX="default_hugepagesz=1G hugepagesz=1G hugepages=8"

Note

1GB hugepages might not be supported in your machine. It depends on that CPUs support 1GB pages or not. You can check it by referring /proc/cpuinfo. If it is supported, you can find pdpe1gb in the flags attribute.

$ cat /proc/cpuinfo | grep pdpe1gb
flags           : fpu vme ... pdpe1gb ...

You should run update-grub after editing to update grub’s config file, or this configuration is not activated.

$ sudo update-grub
Generating grub configuration file ...

For 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 point in /etc/fstab, or after booted.

The mount point for 2MB or 1GB can be made permanent 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 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 kernel.randomize_va_space to 0, or be enabled by assigning it to 2.

# 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. Vhost Client Mode

SPP secondary process supports --vhost-client option for using vhost port. In vhost client mode, qemu creates socket file instead of secondary process. It means that you can launch a VM before secondary process create vhost port.

Note

Vhost client mode is supported by qemu 2.7 or later.

1.5. Using Libvirt

If you use libvirt for managing virtual machines, you might need some additional configurations.

Uncomment user and group in /etc/libvirt/qemu.conf.

# /etc/libvirt/qemu.conf

user = "root"
group = "root"

To use hugepages with libvirt, change KVM_HUGEPAGES from 0 to 1 in /etc/default/qemu-kvm.

# /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.5.1. 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 /etc/libvirt/qemu.conf.

# 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, not Ubuntu, confirm that SELinux doesn’t prevent for permission. SELinux should be disabled in this case.

# /etc/selinux/config
SELINUX=disabled

Check your SELinux configuration.

$ getenforce
Disabled

1.6. Python 2 or 3 ?

In SPP, Python3 is required only for running spp-ctl and SPP CLI. Python2 is not supported anymore.