dpdk程序的命令行參數 --lcores能夠設置lcore到CPU processer的多對多映射關係。 這樣既能夠提供CPU processor的伸縮擴展,同時也保證了EAL thread的運行環境,只須要簡單的修改一下配置,基本上不須要作太多的代碼調整。html
dpdk文檔傳送門git
摘錄官網文檔的描述:github
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.
語法格式:app
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,效果以下:ide
[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