1.软文推荐

2.软文推荐

3.软文推荐

有几个云上的小伙伴想测测VPC网络性能,于是写了一些dpdk代码在阿里云上做了一个实验,也适用于其它云.

安装相关的库

使用root登录,更新一下源

#备份原有的配置文件
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
#使用阿里云的源覆盖
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
sudo dnf config-manager --set-enabled PowerTools

yum makecache
yum update

yum groupinstall "Development tools"
yum install gcc-gfortran kernel-modules-extra tcl tk tcsh terminator tmux kernel-rpm-macros elfutils-libelf-devel libnl3-devel meson createrepo numactl-devel
pip3 install pyelftools
启用iommu
sudo vi /etc/default/grub

//在 GRUB_CMDLINE_LINUX 行添加"intel_iommu=on iommu=pt"  
//保存退出

然后更新grub并重启系统

sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
sudo reboot
安装DPDK

CentOS上需要添加/usr/local路径, 主要是LD_LIBRARY_PATH PATH 和 PKG_CONFIG_PATH 以及sudo的path

sudo vi /etc/ld.so.conf.d/dpdk.conf

>>添加如下path
/usr/local/lib64
>>退出

sudo ldconfig

vim ~/.bashrc
>>添加如下path

export PATH=/usr/local/bin:$PATH
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:${PKG_CONFIG_PATH}


保存后source
source ~/.bashrc
sudo vim  /etc/sudoers

>>将secure_path添加/usr/local/bin
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

然后解压dpdk,并编译安装

wget http://fast.dpdk.org/rel/dpdk-21.05.tar.xz
tar xf dpdk-21.05.tar.xz

cd dpdk-21.05
meson build -D examples=all  

cd build
ninja
sudo ninja install
sudo ldconfig

设置Hugepage和bind接口

dpdk-hugepages.py --setup 4G
modprobe vfio-pci
dpdk-devbind.py -s

Network devices using kernel driver
===================================
0000:00:05.0 'Virtio network device 1000' if=eth0 drv=virtio-pci unused=vfio-pci *Active*
0000:00:06.0 'Virtio network device 1000' if=eth1 drv=virtio-pci unused=vfio-pci *Active*

注意虚拟机环境需要noniommu_mode

ifconfig eth1 down
echo 1 > /sys/module/vfio/parameters/enable_unsafe_noiommu_mode
dpdk-devbind.py -b vfio-pci 0000:00:06.0

验证

dpdk-devbind.py -s

Network devices using DPDK-compatible driver
============================================
0000:00:06.0 'Virtio network device 1000' drv=vfio-pci unused=

Network devices using kernel driver
===================================
0000:00:05.0 'Virtio network device 1000' if=eth0 drv=virtio-pci unused=vfio-pci *Active*
检查接口支持情况

下载代码

cd ~
wget https://github.com/zartbot/learn_dpdk/archive/refs/heads/main.zip
unzip main.zip
cd learn_dpdk-main/

编译

cd 01_port_init/devinfo/
make clean;make

检查接口支持情况

./build/devinfo

EAL: Detected 24 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Detected shared linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
EAL: No available 1048576 kB hugepages reported
EAL: VFIO support initialized
EAL:   Invalid NUMA socket, default to 0
EAL: Probe PCI driver: net_virtio (1af4:1000) device: 0000:00:05.0 (socket 0)
eth_virtio_pci_init(): Failed to init PCI device

EAL: Requested device 0000:00:05.0 cannot be used
EAL:   Invalid NUMA socket, default to 0
EAL: Probe PCI driver: net_virtio (1af4:1000) device: 0000:00:06.0 (socket 0)
EAL: Using IOMMU type 8 (No-IOMMU)
TELEMETRY: No legacy callbacks, legacy socket not created



*****************************************
number of available port: 1
=========================================
port: 0         Driver:net_virtio
Link down
MAC address: 00:16:3E:25:3F:0A
PCIe:0000:00:06.0
Max RX Queue:   12      Desc:   65535
Max TX Queue:   12      Desc:   65535
Offload Capability:
 DEV_RX_OFFLOAD_VLAN_STRIP
 DEV_RX_OFFLOAD_UDP_CKSUM
 DEV_RX_OFFLOAD_TCP_CKSUM
 DEV_RX_OFFLOAD_TCP_LRO
 DEV_RX_OFFLOAD_JUMBO_FRAME
-----------------------------------------
 DEV_TX_OFFLOAD_VLAN_INSERT
 DEV_TX_OFFLOAD_UDP_CKSUM
 DEV_TX_OFFLOAD_TCP_CKSUM
 DEV_TX_OFFLOAD_TCP_TSO
 DEV_TX_OFFLOAD_MULTI_SEGS
=========================================
测速
cd ~/learn_dpdk-main/02_send_recv/traffic_gen/

修改send_pkt.c的源目的地址,注意目的MAC在阿里云上要为eeff.ffff.ffff

//init mac
struct rte_ether_addr s_addr = {{0x00, 0x16, 0x3e, 0x25, 0x0b, 0xe3}};
struct rte_ether_addr d_addr = {{0xee, 0xff, 0xff, 0xff, 0xff, 0xff}};

//init IP header
rte_be32_t s_ip_addr = string_to_ip("10.66.1.220");
rte_be32_t d_ip_addr = string_to_ip("10.66.1.219");

由于接口支持有限,修改 common.h

#define NUM_RX_QUEUE 1
#define NUM_TX_QUEUE 1

static const struct rte_eth_conf port_conf_default = {
   .rxmode = {
       .max_rx_pkt_len = RTE_ETHER_MAX_LEN,
   .mq_mode = ETH_MQ_RX_NONE,
   },
   .txmode = {
       .mq_mode = ETH_MQ_TX_NONE,
   }
};

修改portinit.c 关闭RX-CHECKSUM OFFLOAD, 注释掉下面这段:

if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_CHECKSUM)
{
    printf("port[%u] support RX cheksum offload.
", port);
    port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_CHECKSUM;
}

最后测速大概3.3Mpps左右,接近官方售卖时的4Mpps

[root@iZuf64vmgrtj12kczyslhdZ traffic_gen]# ./build/run
EAL: Detected 24 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Detected shared linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
EAL: No available 1048576 kB hugepages reported
EAL: VFIO support initialized
EAL:   Invalid NUMA socket, default to 0
EAL: Probe PCI driver: net_virtio (1af4:1000) device: 0000:00:05.0 (socket 0)
eth_virtio_pci_init(): Failed to init PCI device

EAL: Requested device 0000:00:05.0 cannot be used
EAL:   Invalid NUMA socket, default to 0
EAL: Probe PCI driver: net_virtio (1af4:1000) device: 0000:00:06.0 (socket 0)
EAL: Using IOMMU type 8 (No-IOMMU)
TELEMETRY: No legacy callbacks, legacy socket not created


initializing port 0...
port[0] support TX UDP checksum offload.
port[0] support TX TCP checksum offload.
Port[0] MAC: 00:16:3e:25:0b:e3
Core 1 doing RX dequeue.
Core 2 doing packet enqueue.

RX-Queue[0] PPS: 3280464
RX-Queue[0] PPS: 3277792
RX-Queue[0] PPS: 3303116
RX-Queue[0] PPS: 3307443
RX-Queue[0] PPS: 3296451
RX-Queue[0] PPS: 3294396
RX-Queue[0] PPS: 3297737
RX-Queue[0] PPS: 3290069
RX-Queue[0] PPS: 3279720
RX-Queue[0] PPS: 3285987
RX-Queue[0] PPS: 3279424

然后把common.h 中收发都改为4个线程

#define NUM_RX_QUEUE 1
#define NUM_TX_QUEUE 1

测试结果和官方售卖的4Mpps一致了。

RX-Queue[0] PPS: 578918
RX-Queue[1] PPS: 866823
RX-Queue[2] PPS: 2288950
RX-Queue[3] PPS: 865335

CPU Info

[root@iZuf64vmgrtj12kczyslhdZ traffic_gen]# cat /proc/cpuinfo | grep Xeon
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz
model name      : Intel(R) Xeon(R) Platinum 8369B CPU @ 2.70GHz

本文来源:www.lxlinux.net/9291.html,若引用不当,请联系修改。

相关文章 8

1

Linux常用命令—dhclient命令 2分钟前

Linux常用命令 dhclient命令 使用动态主机配置协议动态的配置网络接口的网络参数,下面良许教程网为大家分享一下Linux常用命令dhclient命令具...

2

网页优化(网页优化及制作全过程) 3分钟前

目录:1、什么是网站优化2、网站优化方法有哪些3、网站怎么优化4、什么是网站优化?什么是网站优化 使用符合搜索引擎规律的方法使网站...

3

详解Linux系统中的Device Mapper:内核空间 4分钟前

Devicemapper是内核中支持逻辑卷管理的通用设备映射机制,它为实现用于存储资源管理的块设备驱动提供了一个高度模块化的内核架构,它包...

4

酒泉服务器租用(酒泉房屋租赁) 6分钟前

目录:1、租用一台服务器一年需要多少价格?2、租用服务器大概要多少钱?3、租用服务器一个月大概多少钱,求解答。4、租用一台服务器...

5

细说Linux五种IO模型 8分钟前

我们都知道unix世界里、一切皆文件、而文件是什么呢?文件就是一串二进制流而已、不管socket、还是FIFO、管道、终端、对我们来说、一切都...

6

网络安全中使用AI正确使用AI的方法 8分钟前

人工智能在网络安全领域有着广阔的前景,但前提是得到合理的运用。同其他所有技术一样,AI也绝对不是一颗银弹,即使拥有最先进的技术...

7

腾讯云通信怎么样(腾讯云前景怎样) 10分钟前

目录:1、腾讯云视频与通信服务怎么样/腾讯云即时通信/腾讯通信怎么转让?2、腾讯云通信IM系统的多终端同时在线功能如何打开,同时支...

8

Kubernetes上安装Oracle数据库具体方法 12分钟前

Kubernetes 是一个可移植的、可扩展的开源平台,用于管理容器化的工作负载和服务,可促进声明式配置和自动化。 Kubernetes 拥有一个庞大且快...