博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mbuf_user_pool_ops和mbuf_platform_pool_ops
阅读量:4216 次
发布时间:2019-05-26

本文共 2029 字,大约阅读时间需要 6 分钟。

dpdk中有两种pool 来有限分配用户内存。分别是mbuf_user_pool_ops和mbuf_platform_pool_ops当用户调用rte_mbuf_best_mempool_ops 来从pool中分配内存是,优先从mbuf_user_pool_ops 中分配,然后才是从mbuf_platform_pool_ops 中分配。具体分析如下:const char * __rte_experimentalrte_mbuf_best_mempool_ops(void){	/* User defined mempool ops takes the priority */	#首先查找mbuf_user_pool_ops	const char *best_ops = rte_mbuf_user_mempool_ops();	if (best_ops)		return best_ops;	/* Next choice is platform configured mempool ops */	#其次查找mbuf_user_pool_ops	best_ops = rte_mbuf_platform_mempool_ops();	if (best_ops)		return best_ops;	/* Last choice is to use the compile time config pool */	最后才是使用 ring buffer #define RTE_MBUF_DEFAULT_MEMPOOL_OPS "ring_mp_mc"	return RTE_MBUF_DEFAULT_MEMPOOL_OPS;}我们以mbuf_user_pool_ops 为例看看const char * __rte_experimentalrte_mbuf_user_mempool_ops(void){	const struct rte_memzone *mz;	#查找mbuf_user_pool_ops	mz = rte_memzone_lookup("mbuf_user_pool_ops");	if (mz == NULL)		#如果没有查找到,则直接返回internal_config.user_mbuf_pool_ops_name;		return rte_eal_mbuf_user_pool_ops();	#查找到后,返回这个pool的name	return mz->addr;}const struct rte_memzone *rte_memzone_lookup(const char *name){	struct rte_mem_config *mcfg;	const struct rte_memzone *memzone = NULL;	#得到全局变量	mcfg = rte_eal_get_configuration()->mem_config;	锁保护	rte_rwlock_read_lock(&mcfg->mlock);	#开始查找这个mempool	memzone = memzone_lookup_thread_unsafe(name);	rte_rwlock_read_unlock(&mcfg->mlock);	return memzone;}static inline const struct rte_memzone *memzone_lookup_thread_unsafe(const char *name){	const struct rte_mem_config *mcfg;	const struct rte_memzone *mz;	unsigned i = 0;	/* get pointer to global configuration */	#得到全局变量	mcfg = rte_eal_get_configuration()->mem_config;	/*	 * the algorithm is not optimal (linear), but there are few	 * zones and this function should be called at init only	 */	#遍历全局变量mcfg中的memzone,以本例中及时查找name为mbuf_user_pool_ops的memzone	for (i = 0; i < RTE_MAX_MEMZONE; i++) {		mz = &mcfg->memzone[i];		if (mz->addr != NULL && !strncmp(name, mz->name, RTE_MEMZONE_NAMESIZE))			return &mcfg->memzone[i];	}	return NULL;}

转载地址:http://rnnmi.baihongyu.com/

你可能感兴趣的文章
Sending the User to Another App
查看>>
kmsg_dump
查看>>
Getting a Result from an Activity
查看>>
Allowing Other Apps to Start Your Activity
查看>>
dev/mem
查看>>
pfn_valid 源码分析
查看>>
dev/kmem 和dev/mem的区别
查看>>
checkbox
查看>>
Sending Simple Data to Other Apps
查看>>
Receiving Simple Data from Other Apps
查看>>
中断API之__tasklet_schedule
查看>>
中断API之enable_irq
查看>>
中断API之disable_irq
查看>>
nova 中的guestfs
查看>>
nova中的localfs
查看>>
utils/rpm_build.sh
查看>>
查看模块参数
查看>>
udev重命名网口
查看>>
pgrep
查看>>
test-definitions/blob/master/toolset/util/parallel_cmds.py
查看>>