#if RTE_MEMPOOL_CACHE_MAX_SIZE > 0 //在当前cpu本地缓存有空间的场景下, 先放回到本地缓存。 cache = &mp->local_cache[lcore_id]; cache_objs = &cache->objs[cache->len]; for (index = 0; index < n; ++index, obj_table++) { cache_objs[index] = *obj_table; } //缓冲达到阈值,...
如果用户创建mempool时,传入的cache size为0,则mempool无每个core的本地cache部分 rte_pktmbuf_pool_private结构则记录了mempool中mbuf中的mbuf_data_room_size、mbuf_priv_size以及flags(为将来预留)。 mempool中的elt_size、header_size和trailer_size,记录了mempool中关联的object(对象)的结构各部分的大小。其中,hea...
int rte_mempool_put(struct rte_mempool *mp, void **obj_table, unsigned n) { #if RTE_MEMPOOL_CACHE_MAX_SIZE > 0 //在当前cpu本地缓存有空间的场景下, 先放回到本地缓存。 cache = &mp->local_cache[lcore_id]; cache_objs = &cache->objs[cache->len]; for (index = 0; index < n;...
DPDK以两种方式对外提供内存管理方法,一个是rte_mempool,主要用于网卡数据包的收发;一个是rte_malloc,主要为应用程序提供内存使用接口。本文讨论rte_mempool。rte_mempool由函数rte_mempool_create()负责创建,从rte_config.mem_config->free_memseg[]中取出合适大小的内存,放到rte_config.mem_config->memzone[]中。
align = CACHE_LINE_ROUNDUP(align); 1. 2. 在rte_config.mem_config->malloc_heaps[]数组里,此socket对应的堆中,进行匹配,查找是否有合适内存可以分配。find_suitable_element()用来在堆中找到一块合适大小的内存,分配的内存是从堆的底部开始查找的。
12mp->cache_size =cache_size;13mp->cache_flushthresh =(uint32_t)14(cache_size *CACHE_FLUSHTHRESH_MULTIPLIER);15mp->private_data_size =private_data_size;1617/*calculate address of the first element for continuous mempool.*/18obj = (char*)mp + MEMPOOL_HEADER_SIZE(mp, pg_num) +19...
;32 #endif33 34 void * ring[0] __rte_cache_aligned; /**< Memory space of ring starts here.35 * not volatile so need to be careful36 * about compiler re-ordering */37 }; 1. c、调用rte_memzone_reserve(),在rte_config.mem_config->free_memseg[]中查 找一个合适的free_memseg(...
unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id) 1. 2. 3. 4. name是内存池名字。为了获得更好的性能,n应该为2的幂减1 。 网卡操作函数: rte_eth_dev_configure() 设置网卡设备。在其他操作之前,应该先调用这个函数进行设置。
> > unsigned cache_size, unsigned private_data_size, > > > > rte_mempool_ctor_t *mp_init, void *mp_init_arg, > > > > rte_mempool_obj_cb_t *obj_init, void *obj_init_arg, > > > > int socket_id, unsigned flags);
cache is not enabled. we can refer to mempool cache to implement "ring_single_thread_sp_sc". In this simple scenario, the performance should be improved. This scenario is common: Such as mbuf mempool. dpdk NICs receives a packet, the protocol stack ...