设为首页 收藏本站
查看: 2260|回复: 0

[经验分享] [dpdk] 读官方文档(1)

[复制链接]

尚未签到

发表于 2017-6-9 07:49:51 | 显示全部楼层 |阅读模式
  前提:已读了这本书<<深入浅出dpdk(朱清河等著)>>。
  目标:读官方文档,同时跟着文档进行安装编译等工作。
  http://dpdk.org/doc/guides/index.html
  环境:thinkpadT450 + archlinux + kvm + CentOS 7(逐层自下而上的关系)



KVM参数:
sudo qemu-system-x86_64 -nographic -enable-kvm -numa node -numa node -drive file=disk.img,if=virtio \
  -cdrom /home/tong/ISO/CentOS-7-x86_64-DVD-1511.iso -boot order=c -m 2G \
  -net nic,model=virtio,macaddr='00:00:00:00:00:03' -net tap,ifname=tap0
  当前dpdk版本:dpdk-16.07
  前提交代完,接下来是正文。内容会是一种笔记的形式,我遇见问题,就会在下边写下来。
  一 编译:



make config T=x86_64-native-linuxapp-gcc
sed -ri 's,(PMD_PCAP=).*,\1y,' build/.config
make
  问题一:编译错误



In file included from /root/dpdk-16.07/lib/librte_eal/linuxapp/eal/eal_pci.c:42:0:
/root/dpdk-16.07/build/include/rte_memcpy.h:814:2: error: incompatible type for argument 2 of ‘_mm_storeu_si128’
MOVEUNALIGNED_LEFT47(dst, src, n, srcofs);
^
In file included from /root/dpdk-16.07/build/include/rte_common.h:289:0,
from /root/dpdk-16.07/build/include/rte_log.h:45,
from /root/dpdk-16.07/lib/librte_eal/linuxapp/eal/eal_pci.c:37:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/emmintrin.h:700:1: note: expected ‘__m128i’ but argument is of type ‘int’
_mm_storeu_si128 (__m128i *__P, __m128i __B)
  咋解决:查看了这个头文件emmintrin.h 内容是这样的,也就是说这是个CPU平台相关的问题,所以很可能需要调整kvm的cpu参数,或者dpdk的编译参数,从这两个方面入手:



/* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components.  */
typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));
typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__));
  dpdk的编译参数并没有神马好改的,你重要指定一个CPU平台给它,所以我必须让qemu模拟intel或者是虚拟机直接认得本地CPU,然而qemu的手册并不清晰,又没有时间系统的学习qemu,只能试了。(qemu kvm也需要系统学习!)
  尝试1:不给qemu CPU参数:



qemu-system-x86_64 -nographic -enable-kvm -m 2G -drive file=disk.img,if=virtio \
      -net nic,model=virtio,macaddr='00:00:00:00:00:03' -net tap,ifname=tap0
  进入系统后查看cpuinfo



[iyunv@dpdk dpdk-16.07]# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 6
model name      : QEMU Virtual CPU version 2.5+
stepping        : 3
......
  编译报同样的错,毫无悬念。
  尝试2:指定CPU类型,模拟至强E3



qemu-system-x86_64 -nographic -enable-kvm -m 2G -cpu IvyBridge -drive file=disk.img,if=virtio -net nic,model=virtio,macaddr='00:00:00:00:00:03' -net tap,ifname=tap0
  编译成功:



[iyunv@dpdk dpdk-16.07]# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 58
model name      : Intel Xeon E3-12xx v2 (Ivy Bridge)
stepping        : 9
microcode       : 0x1
cpu MHz         : 2394.456
cache size      : 4096 KB
... ...
  编译错误二:



  SYMLINK-FILE include/exec-env/rte_dom0_common.h
INSTALL-LIB librte_eal.a
== Build lib/librte_eal/linuxapp/igb_uio
make: *** /lib/modules/3.10.0-327.el7.x86_64/build: No such file or directory.  Stop.
make[5]: *** [igb_uio.ko] Error 2
make[4]: *** [igb_uio] Error 2
make[3]: *** [linuxapp] Error 2
make[2]: *** [librte_eal] Error 2
make[1]: *** [lib] Error 2
make: *** [all] Error 2
  解决:人家文档写的清楚需要内核开发包 “kernel - devel.x86_64”



yum install kernel-devel
ln -fs /usr/src/kernels/3.10.0-327.36.1.el7.x86_64/ /lib/modules/3.10.0-327.el7.x86_64/build
  问题三:因为enable了PCAP,没错就是前边那个sed,鬼知道它是干嘛的,反正要装 libpcap-devel.
  编译通过,好棒!: )
  二,调整硬件架构
  调整虚拟机为numa架构,并设置hugepage。



# numa参数只调整结构,并不申请资源,所以还是需要m和smp两个参数来进行资源申请。
sudo qemu-system-x86_64 -nographic -vnc 127.0.0.1:0 -enable-kvm \
-m 2G -cpu Nehalem \                  #Nehalem就是i7,我的物理CPU是i7,模拟至强的时候,warning有一些特性不支持,为了防止后续出现诡异的错误,就模拟了i7.
-smp cores=2,threads=2,sockets=2 \    #两颗CPU,两个核心,超线程
-numa node,mem=1G,cpus=0-3,nodeid=0 \
-numa node,mem=1G,cpus=4-7,nodeid=1 \
-drive file=disk.img,if=virtio \
-net nic,model=virtio,macaddr='00:00:00:00:00:03' \
-net tap,ifname=tap0 &
  然后在虚拟机里的效果就是这样的:


DSC0000.gif DSC0001.gif


[iyunv@dpdk ~]# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model   : 26
model name      : Intel Core i7 9xx (Nehalem Class Core i7)
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.456
cache size      : 4096 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level     : 11
wp      : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc rep_good nopl pni ssse3 cx16 sse4_1 sse4_2 x2apic popcnt hypervisor lahf_lm
bogomips        : 4788.91
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:
processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model   : 26
model name      : Intel Core i7 9xx (Nehalem Class Core i7)
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.456
cache size      : 4096 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 1
initial apicid  : 1
fpu     : yes
fpu_exception   : yes
cpuid level     : 11
wp      : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc rep_good nopl pni ssse3 cx16 sse4_1 sse4_2 x2apic popcnt hypervisor lahf_lm
bogomips        : 4788.91
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:
processor       : 2
vendor_id       : GenuineIntel
cpu family      : 6
model   : 26
model name      : Intel Core i7 9xx (Nehalem Class Core i7)
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.456
cache size      : 4096 KB
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 2
apicid          : 2
initial apicid  : 2
fpu     : yes
fpu_exception   : yes
cpuid level     : 11
wp      : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc rep_good nopl pni ssse3 cx16 sse4_1 sse4_2 x2apic popcnt hypervisor lahf_lm
bogomips        : 4788.91
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:
processor       : 3
vendor_id       : GenuineIntel
cpu family      : 6
model   : 26
model name      : Intel Core i7 9xx (Nehalem Class Core i7)
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.456
cache size      : 4096 KB
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 2
apicid          : 3
initial apicid  : 3
fpu     : yes
fpu_exception   : yes
cpuid level     : 11
wp      : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc rep_good nopl pni ssse3 cx16 sse4_1 sse4_2 x2apic popcnt hypervisor lahf_lm
bogomips        : 4788.91
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:
processor       : 4
vendor_id       : GenuineIntel
cpu family      : 6
model   : 26
model name      : Intel Core i7 9xx (Nehalem Class Core i7)
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.456
cache size      : 4096 KB
physical id     : 1
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 4
initial apicid  : 4
fpu     : yes
fpu_exception   : yes
cpuid level     : 11
wp      : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc rep_good nopl pni ssse3 cx16 sse4_1 sse4_2 x2apic popcnt hypervisor lahf_lm
bogomips        : 4788.91
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:
processor       : 5
vendor_id       : GenuineIntel
cpu family      : 6
model   : 26
model name      : Intel Core i7 9xx (Nehalem Class Core i7)
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.456
cache size      : 4096 KB
physical id     : 1
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 5
initial apicid  : 5
fpu     : yes
fpu_exception   : yes
cpuid level     : 11
wp      : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc rep_good nopl pni ssse3 cx16 sse4_1 sse4_2 x2apic popcnt hypervisor lahf_lm
bogomips        : 4788.91
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:
processor       : 6
vendor_id       : GenuineIntel
cpu family      : 6
model   : 26
model name      : Intel Core i7 9xx (Nehalem Class Core i7)
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.456
cache size      : 4096 KB
physical id     : 1
siblings        : 4
core id         : 1
cpu cores       : 2
apicid          : 6
initial apicid  : 6
fpu     : yes
fpu_exception   : yes
cpuid level     : 11
wp      : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc rep_good nopl pni ssse3 cx16 sse4_1 sse4_2 x2apic popcnt hypervisor lahf_lm
bogomips        : 4788.91
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:
processor       : 7
vendor_id       : GenuineIntel
cpu family      : 6
model   : 26
model name      : Intel Core i7 9xx (Nehalem Class Core i7)
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.456
cache size      : 4096 KB
physical id     : 1
siblings        : 4
core id         : 1
cpu cores       : 2
apicid          : 7
initial apicid  : 7
fpu     : yes
fpu_exception   : yes
cpuid level     : 11
wp      : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc rep_good nopl pni ssse3 cx16 sse4_1 sse4_2 x2apic popcnt hypervisor lahf_lm
bogomips        : 4788.91
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:
cat /proc/cpuinfo




[iyunv@dpdk ~]# numastat
node0           node1
numa_hit                  193979          184758
numa_miss                      0               0
numa_foreign                   0               0
interleave_hit              7016            6897
local_node                187494          184103
other_node                  6485             655
numastat  大页:
  查看cpuinfo: If pse exists, 2M hugepages are supported; if pdpe1gb exists, 1G hugepages are supported. 所以我只支持2M,而且我也没有那么多内存。但是我的物理cpu是支持1G的,这让我感觉很牛逼,我是说host主机。
  通过设置内核参数:测试发现,保留的大页会平均分给两个node。



[iyunv@dpdk ~]# cat /boot/grub2/grub.cfg|grep huge
linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_US.UTF-8 hugepages=32
[iyunv@dpdk ~]# cat /proc/meminfo |grep Huge
AnonHugePages:      8192 kB
HugePages_Total:      32
HugePages_Free:       32
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
[iyunv@dpdk ~]# cat /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
16
[iyunv@dpdk ~]# cat /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages
16
  挂载大页到启动项里,(干这个事的时候出现了插曲,搞了一下nbd和lvm的挂载,真爱粉们可以去另一篇里边追剧哦),截止到目前完全不知道为啥要这样做。



[iyunv@dpdk ~]# cat /etc/fstab
... ...
# custom
nodev /mnt/huge hugetlbfs defaults 0 0
[iyunv@dpdk ~]#
  反正,测试程序  testpmd能跑起来了,算告一段落,太长了,我要切!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-385299-1-1.html 上篇帖子: 一分钟完成MySQL5.7安装部署 下篇帖子: MySQL优化聊两句
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表