下面是mm/slab.c中的一个函数,它出现在kmem_cache的引导初始化中。我不理解这个函数,也不知道array_cache实际使用的是kmem>数组。
static void setup_node_pointer(struct kmem_cache *cachep)
{
cachep->node = (struct kmem_cache_node **)&cachep->array[nr_cpu_ids];
} 有人能帮我这个忙吗?
发布于 2013-06-24 11:04:20
你有没有读过那个函数上面的注释?
/*
* The memory after the last cpu cache pointer is used for the
* the node pointer.
*/板片分配器使用array变量中额外的指针空间来存储节点指针(而不是array_cache指针)。slab_def.h中的array变量上面的注释暗示了这一点
/* 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];https://stackoverflow.com/questions/17267271
复制相似问题