Hands On Vhost-User: A Warm Welcome To DPDK: 17-22 Minutes
Hands On Vhost-User: A Warm Welcome To DPDK: 17-22 Minutes
Hands On Vhost-User: A Warm Welcome To DPDK: 17-22 Minutes
redhat.com
1 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
Finally, we can use virt-install to create the VM. This command line
utility creates the needed definitions for a set of well known
operating systems. This will give us the base definitions that we can
then customize:
The options used for this command specify the number of vCPUs,
the amount of RAM of our VM as well as the disk path and the
network we want the VM to be connected to.
2 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
<interface type='vhostuser'>
<mac address='56:48:4f:53:54:01'/>
<source type='unix' path='/tmp/vhost-user1'
mode='client'/>
<model type='virtio'/>
<driver name='vhost' rx_queue_size='256' />
</interface>
<interface type='vhostuser'>
<mac address='56:48:4f:53:54:02'/>
<source type='unix' path='/tmp/vhost-user2'
mode='client'/>
<model type='virtio'/>
<driver name='vhost' rx_queue_size='256' />
</interface>
<memoryBacking>
<hugepages>
<page size='1048576' unit='KiB'
nodeset='0'/>
</hugepages>
<locked/>
</memoryBacking>
<numatune>
<memory mode='strict' nodeset='0'/>
</numatune>
3 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
Log in as root. The first thing we do in the guest is to bind the virtio
devices to the vfio-pci driver. To be able to do this we need to load
the required kernel modules first.
root@guest $ modprobe vfio
enable_unsafe_noiommu_mode=1
root@guest $ cat /sys/module/vfio/parameters
/enable_unsafe_noiommu_mode
root@guest $ modprobe vfio-pci
Let’s find out the PCI addresses of our virtio-net devices first.
4 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
Generating traffic
5 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
-n 4 \
--vdev 'net_vhost0,iface=/tmp/vhost-user1' \
--vdev 'net_vhost1,iface=/tmp/vhost-user2' --
\
--portmask=f -i --rxq=1 --txq=1 \
--nb-cores=4 --forward-mode=io
Notice how we can see output in the testpmd window which shows
the vhost-user messages it received
Once the guest has booted we can start the testpmd instance. This
one will initialize the ports and the virtio-net driver that DPDK
implements. Among other things this is where the virtio feature
negotiation takes place and the set of common features is agreed
upon.
Before we start testpmd we make sure that the vfio kernel module
is loaded and bind the virtio-net devices to the vfio-pci driver:
Start testpmd:
Now we can check how many packets our testpmd instances are
processing. On the testpmd prompt we enter the command ‘show
port stats all’ and see the number of packets forwarded in each
direction (RX/TX).
An example:
testpmd> show port stats all
6 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
0 ########################
RX-packets: 75525952 RX-missed: 0 RX-
bytes: 4833660928
RX-errors: 0
RX-nombuf: 0
TX-packets: 75525984 TX-errors: 0 TX-
bytes: 4833662976
######################################################################
######################################################################
7 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
Before we start explaining the tunings in detail, this is how you use
the tuned cpu-partition profile and don’t have to bother with all the
details:
Now we can apply the tuned profile with the tuned-adm command:
For those readers who want to know more details of what the cpu-
partitioning profile does, let’s do these steps manually. If you’re not
interested in this you can just skip to the next section.
The most basic change is done even outside of Linux in the BIOS
settings of the system. There we have to disable turbo-boost and
hyper-threads. If the BIOS is for some reason not accessible,
8 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
Do this by running:
user@host $ grubby --args "intel_pstate=disable
mce=ignore_ce isolcpus=2-7 rcu_nocbs=2-7
nohz_full=2-7" --update-kernel /boot/<your kernel
image file>
The meaning of the first three parameters are known from the host
9 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
And because we want the same for guest cores handling the
packets that we want for the cores in the host we do the same
steps and disable NMIs, exclude the cores from block device
writeback flusher threads and from IRQs, we do this:
Pinning virtual CPUs to physical cores in the host will make sure
the vcpus are not scheduled to different cores.
<cputune>
<vcpupin vcpu='0' cpuset='1'/>
<vcpupin vcpu='1' cpuset='6'/>
<vcpupin vcpu='2' cpuset='7'/>
<emulatorpin cpuset='0'/>
</cputune>
After going through all the performance tuning steps, let’s run our
testpmd instances again to see how the number of packets per
10 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
second changed.
testpmd> show port stats all
######################################################################
######################################################################
11 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
Just follow the instructions in the README and Ansible should take
care of the rest.
Conclusion
12 of 13 11-05-20, 11:02 PM
Hands on vhost-user: A warm welcome to DPDK about:reader?url=https://www.redhat.com/en/blog/hands-vhost-user-wa...
13 of 13 11-05-20, 11:02 PM