首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么kem_cache->节点可以分配address或array_cache?

为什么kem_cache->节点可以分配address或array_cache?
EN

Stack Overflow用户
提问于 2013-06-24 10:32:06
回答 1查看 118关注 0票数 0

下面是mm/slab.c中的一个函数,它出现在kmem_cache的引导初始化中。我不理解这个函数,也不知道array_cache实际使用的是kmem>数组。

代码语言:javascript
复制
static void setup_node_pointer(struct kmem_cache *cachep)
{
        cachep->node = (struct kmem_cache_node **)&cachep->array[nr_cpu_ids];
}       

有人能帮我这个忙吗?

EN

回答 1

Stack Overflow用户

发布于 2013-06-24 11:04:20

你有没有读过那个函数上面的注释?

代码语言:javascript
复制
/*
 * The memory after the last cpu cache pointer is used for the
 * the node pointer.
 */

板片分配器使用array变量中额外的指针空间来存储节点指针(而不是array_cache指针)。slab_def.h中的array变量上面的注释暗示了这一点

代码语言:javascript
复制
/* 6) per-cpu/per-node data, touched during every alloc/free */
/*
 * We put array[] at the end of kmem_cache, because we want to size
 * this array to nr_cpu_ids slots instead of NR_CPUS
 * (see kmem_cache_init())
 * We still use [NR_CPUS] and not [1] or [0] because cache_cache
 * is statically defined, so we reserve the max number of cpus.
 *
 * We also need to guarantee that the list is able to accomodate a
 * pointer for each node since "nodelists" uses the remainder of
 * available pointers.
 */
struct kmem_cache_node **node;
struct array_cache *array[NR_CPUS + MAX_NUMNODES];
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17267271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档