1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright 2016 Red Hat, Inc.
6 PVP reference benchmark setup using testpmd
7 ===========================================
9 This guide lists the steps required to setup a PVP benchmark using testpmd as
10 a simple forwarder between NICs and Vhost interfaces. The goal of this setup
11 is to have a reference PVP benchmark without using external vSwitches (OVS,
12 VPP, ...) to make it easier to obtain reproducible results and to facilitate
13 continuous integration testing.
15 The guide covers two ways of launching the VM, either by directly calling the
16 QEMU command line, or by relying on libvirt. It has been tested with DPDK
17 v16.11 using RHEL7 for both host and guest.
25 .. figure:: img/pvp_2nics.*
27 PVP setup using 2 NICs
29 In this diagram, each red arrow represents one logical core. This use-case
30 requires 6 dedicated logical cores. A forwarding configuration with a single
31 NIC is also possible, requiring 3 logical cores.
37 In this setup, we isolate 6 cores (from CPU2 to CPU7) on the same NUMA
38 node. Two cores are assigned to the VM vCPUs running testpmd and four are
39 assigned to testpmd on the host.
45 #. On BIOS, disable turbo-boost and hyper-threads.
47 #. Append these options to Kernel command line:
49 .. code-block:: console
51 intel_pstate=disable mce=ignore_ce default_hugepagesz=1G hugepagesz=1G hugepages=6 isolcpus=2-7 rcu_nocbs=2-7 nohz_full=2-7 iommu=pt intel_iommu=on
53 #. Disable hyper-threads at runtime if necessary or if BIOS is not accessible:
55 .. code-block:: console
57 cat /sys/devices/system/cpu/cpu*[0-9]/topology/thread_siblings_list \
59 | awk -F, '{system("echo 0 > /sys/devices/system/cpu/cpu"$2"/online")}'
63 .. code-block:: console
65 echo 0 > /proc/sys/kernel/nmi_watchdog
67 #. Exclude isolated CPUs from the writeback cpumask:
69 .. code-block:: console
71 echo ffffff03 > /sys/bus/workqueue/devices/writeback/cpumask
73 #. Isolate CPUs from IRQs:
75 .. code-block:: console
77 clear_mask=0xfc #Isolate CPU2 to CPU7 from IRQs
78 for i in /proc/irq/*/smp_affinity
80 echo "obase=16;$(( 0x$(cat $i) & ~$clear_mask ))" | bc > $i
89 .. code-block:: console
91 git clone git://git.qemu.org/qemu.git
95 ../configure --target-list=x86_64-softmmu
102 See :doc:`../linux_gsg/build_dpdk` for details.
108 #. Assign NICs to DPDK:
110 .. code-block:: console
113 usertools/dpdk-devbind -b vfio-pci 0000:11:00.0 0000:11:00.1
117 The Sandy Bridge family seems to have some IOMMU limitations giving poor
118 performance results. To achieve good performance on these machines
119 consider using UIO instead.
121 #. Launch the testpmd application:
123 .. code-block:: console
125 <build_dir>/app/dpdk-testpmd -l 0,2,3,4,5 --socket-mem=1024 -n 4 \
126 --vdev 'net_vhost0,iface=/tmp/vhost-user1' \
127 --vdev 'net_vhost1,iface=/tmp/vhost-user2' -- \
128 --portmask=f -i --rxq=1 --txq=1 \
129 --nb-cores=4 --forward-mode=io
131 With this command, isolated CPUs 2 to 5 will be used as lcores for PMD threads.
133 #. In testpmd interactive mode, set the portlist to obtain the correct port
136 .. code-block:: console
145 The VM may be launched either by calling QEMU directly, or by using libvirt.
150 Launch QEMU with two Virtio-net devices paired to the vhost-user sockets
151 created by testpmd. Below example uses default Virtio-net options, but options
152 may be specified, for example to disable mergeable buffers or indirect
155 .. code-block:: console
157 <QEMU path>/bin/x86_64-softmmu/qemu-system-x86_64 \
158 -enable-kvm -cpu host -m 3072 -smp 3 \
159 -chardev socket,id=char0,path=/tmp/vhost-user1 \
160 -netdev type=vhost-user,id=mynet1,chardev=char0,vhostforce \
161 -device virtio-net-pci,netdev=mynet1,mac=52:54:00:02:d9:01,addr=0x10 \
162 -chardev socket,id=char1,path=/tmp/vhost-user2 \
163 -netdev type=vhost-user,id=mynet2,chardev=char1,vhostforce \
164 -device virtio-net-pci,netdev=mynet2,mac=52:54:00:02:d9:02,addr=0x11 \
165 -object memory-backend-file,id=mem,size=3072M,mem-path=/dev/hugepages,share=on \
166 -numa node,memdev=mem -mem-prealloc \
167 -net user,hostfwd=tcp::1002$1-:22 -net nic \
168 -qmp unix:/tmp/qmp.socket,server,nowait \
169 -monitor stdio <vm_image>.qcow2
171 You can use this `qmp-vcpu-pin <https://patchwork.kernel.org/patch/9361617/>`_
174 It can be used as follows, for example to pin 3 vCPUs to CPUs 1, 6 and 7,
175 where isolated CPUs 6 and 7 will be used as lcores for Virtio PMDs:
177 .. code-block:: console
179 export PYTHONPATH=$PYTHONPATH:<QEMU path>/scripts/qmp
180 ./qmp-vcpu-pin -s /tmp/qmp.socket 1 6 7
185 Some initial steps are required for libvirt to be able to connect to testpmd's
188 First, SELinux policy needs to be set to permissive, since testpmd is
189 generally run as root (note, as reboot is required):
191 .. code-block:: console
193 cat /etc/selinux/config
195 # This file controls the state of SELinux on the system.
196 # SELINUX= can take one of these three values:
197 # enforcing - SELinux security policy is enforced.
198 # permissive - SELinux prints warnings instead of enforcing.
199 # disabled - No SELinux policy is loaded.
202 # SELINUXTYPE= can take one of three two values:
203 # targeted - Targeted processes are protected,
204 # minimum - Modification of targeted policy.
205 # Only selected processes are protected.
206 # mls - Multi Level Security protection.
210 Also, Qemu needs to be run as root, which has to be specified in
211 ``/etc/libvirt/qemu.conf``:
213 .. code-block:: console
217 Once the domain created, the following snippet is an extract of he most
218 important information (hugepages, vCPU pinning, Virtio PCI devices):
223 <memory unit='KiB'>3145728</memory>
224 <currentMemory unit='KiB'>3145728</currentMemory>
227 <page size='1048576' unit='KiB' nodeset='0'/>
231 <vcpu placement='static'>3</vcpu>
233 <vcpupin vcpu='0' cpuset='1'/>
234 <vcpupin vcpu='1' cpuset='6'/>
235 <vcpupin vcpu='2' cpuset='7'/>
236 <emulatorpin cpuset='0'/>
239 <memory mode='strict' nodeset='0'/>
242 <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
245 <cpu mode='host-passthrough'>
246 <topology sockets='1' cores='3' threads='1'/>
248 <cell id='0' cpus='0-2' memory='3145728' unit='KiB' memAccess='shared'/>
252 <interface type='vhostuser'>
253 <mac address='56:48:4f:53:54:01'/>
254 <source type='unix' path='/tmp/vhost-user1' mode='client'/>
255 <model type='virtio'/>
256 <driver name='vhost' rx_queue_size='256' />
257 <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
259 <interface type='vhostuser'>
260 <mac address='56:48:4f:53:54:02'/>
261 <source type='unix' path='/tmp/vhost-user2' mode='client'/>
262 <model type='virtio'/>
263 <driver name='vhost' rx_queue_size='256' />
264 <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
277 #. Append these options to the Kernel command line:
279 .. code-block:: console
281 default_hugepagesz=1G hugepagesz=1G hugepages=1 intel_iommu=on iommu=pt isolcpus=1,2 rcu_nocbs=1,2 nohz_full=1,2
285 .. code-block:: console
287 echo 0 > /proc/sys/kernel/nmi_watchdog
289 #. Exclude isolated CPU1 and CPU2 from the writeback cpumask:
291 .. code-block:: console
293 echo 1 > /sys/bus/workqueue/devices/writeback/cpumask
295 #. Isolate CPUs from IRQs:
297 .. code-block:: console
299 clear_mask=0x6 #Isolate CPU1 and CPU2 from IRQs
300 for i in /proc/irq/*/smp_affinity
302 echo "obase=16;$(( 0x$(cat $i) & ~$clear_mask ))" | bc > $i
309 See :doc:`../linux_gsg/build_dpdk` for details.
315 Probe vfio module without iommu:
317 .. code-block:: console
319 modprobe -r vfio_iommu_type1
321 modprobe vfio enable_unsafe_noiommu_mode=1
322 cat /sys/module/vfio/parameters/enable_unsafe_noiommu_mode
325 Bind the virtio-net devices to DPDK:
327 .. code-block:: console
329 usertools/dpdk-devbind.py -b vfio-pci 0000:00:10.0 0000:00:11.0
333 .. code-block:: console
335 <build_dir>/app/dpdk-testpmd -l 0,1,2 --socket-mem 1024 -n 4 \
336 --proc-type auto --file-prefix pg -- \
337 --portmask=3 --forward-mode=macswap --port-topology=chained \
338 --disable-rss -i --rxq=1 --txq=1 \
339 --rxd=256 --txd=256 --nb-cores=2 --auto-start
344 Below template should be used when sharing results:
348 Traffic Generator: <Test equipment (e.g. IXIA, Moongen, ...)>
349 Acceptable Loss: <n>%
350 Validation run time: <n>min
351 Host DPDK version/commit: <version, SHA-1>
352 Guest DPDK version/commit: <version, SHA-1>
353 Patches applied: <link to patchwork>
354 QEMU version/commit: <version>
355 Virtio features: <features (e.g. mrg_rxbuf='off', leave empty if default)>
356 CPU: <CPU model>, <CPU frequency>