翻译,增加部分自己的看法,如果有错,欢迎指正!
https://mails.dpdk.org/archives/users/2017-February/001531.html
1、rte_malloc 是从大页内存中分配吗?
是的,但是大页内存是有限的(使用了静态大页内存,而非透明大页(动态分配))
> 1. rte_malloc will allocate memory from hugepage memory ?
yes. but remember hugepage memory is limited
2、如果我们从堆(heap)中使用malloc分配内存,是否可以在dpdk中使用?
答:DPDK在主从模式下(多进程场景), 主程序可以使用,但是从进程不可以。另外不能使用malloc出的内存用于DMA的驱动收包。
补充:DMA只能访问物理内存,malloc分配虚拟内存,所以不能直接使用。
#TODO: dpdk 使用rte_mempool分配的是预留了物理内存吗?
> 2. If we use normal malloc, this will be allocated from heap. will this > allocation also useful for dpdk? DPDK primary application can use it but you can't pass that memory to a secondary DPDK process. Also you can't use malloc memory for things that get DMA'd like packet buffers.
3、我们为什么使用rte_malloc?是因为更高的性能吗?
rte_malloc会减少TLB miss,但是在进程中如果只用很小的buffer,就没有什么区别。
注:这里主要是2M/1G的大页内存和linux 默认4K大页的区别了
> 3. Or for better performance we have to use only rte_malloc?
The memory from rte_malloc will cause less TLB misses, but on a modern processor for a small resident set size it probably makes no difference.