dpdk应用程序启动失败,信息提示:
Current CONFIG_RTE_MAX_MEMSEG=256 is not enough
Please either increase it or request less amount of memory.
PANIC in rte_eal_init():
Cannot init memory
罪魁祸首是内存碎片,app无法申请到足够多的连续大块内存,只能申请到很多小块内存。以至于内存块数目超过了系统设置的256个。
最佳解决办法:
dpdk-getting-started-guide.pdf这个文档的2.3.2节中提到
The allocation of hugepages should be done at boot time or as soon as possible after system boot to prevent memory from being fragmented in physical memory.To reserve hugepages at boot time, a parameter is passed to the Linux* kernel on the kernel command line.
就是申请大页内存应该在系统启动时,或系统启动后尽快申请,避免内存被割裂。
可以在/boot/grub/grub.conf中的kernel行,追加
default_hugepagesz=1G hugepagesz=1G hugepages=4
使用1G的大页,大页内存4G。
In the case of a dual-socket NUMA system, the number of hugepages reserved at boot time is generally divided equally between the two sockets (on the assumption that sufficient memory is present on both sockets).
在双槽NUMA系统下,hugepage内存被均分给了两个槽。