[dpdk] dpdk --lcores参数

dpdk程序的命令行参数 --lcores可以设置lcore到CPU processer的多对多映射关系。
这样既可以提供CPU processor的伸缩扩展,同时也保证了EAL thread的运行环境,只需要简单的修改一下配置,基本上不需要做太多的代码调整。

dpdk文档传送门

摘录官网文档的描述:

The term “lcore” refers to an EAL thread, which is really a Linux/FreeBSD pthread. “EAL pthreads” are created and managed by EAL and execute the tasks issued by remote_launch. In each EAL pthread, there is a TLS (Thread Local Storage) called _lcore_id for unique identification. As EAL pthreads usually bind 1:1 to the physical CPU, the _lcore_id is typically equal to the CPU ID.
When using multiple pthreads, however, the binding is no longer always 1:1 between an EAL pthread and a specified physical CPU. The EAL pthread may have affinity to a CPU set, and as such the _lcore_id will not be the same as the CPU ID. For this reason, there is an EAL long option ‘–lcores’ defined to assign the CPU affinity of lcores. For a specified lcore ID or ID group, the option allows setting the CPU set for that EAL pthread.

语法格式:

The format pattern:
–lcores=’<lcore_set>[@cpu_set][,<lcore_set>[@cpu_set],...]’
‘lcore_set’ and ‘cpu_set’ can be a single number, range or a group.

A number is a “digit([0-9]+)”; a range is “<number>-<number>”; a group is “(<number|range>[,<number|range>,...])”.

做了一个测试程序 code,效果如下:

[root@D128 dpdk_lcores]# ./build/app/test 
EAL: Detected 4 lcore(s)
EAL: No free hugepages reported in hugepages-1048576kB
EAL: Probing VFIO support...
hello from core 1
hello from core 2
hello from core 3
hello from core 0
^C
[root@D128 dpdk_lcores]# ./build/app/test --lcores "(0,1,2,3,4)@(0,1),(5,6,7,8)@3"
EAL: Detected 4 lcore(s)
EAL: No free hugepages reported in hugepages-1048576kB
EAL: Probing VFIO support...
hello from core 1
hello from core 2
hello from core 3
hello from core 4
hello from core 5
hello from core 6
hello from core 7
hello from core 8
hello from core 0

posted on 2018-05-03 11:35  toong  阅读(2821)  评论(0编辑  收藏  举报