C 为什么kem_缓存->;是否为节点分配了地址或数组\u缓存?
这里是mm/slab.c中的一个函数,它出现在kmem_缓存的引导初始化中。我不理解这个函数,也不理解实际使用的数组缓存是什么,即kmem\u cache->arrayC 为什么kem_缓存->;是否为节点分配了地址或数组\u缓存?,c,memory,linux-kernel,virtual-memory,C,Memory,Linux Kernel,Virtual Memory,这里是mm/slab.c中的一个函数,它出现在kmem_缓存的引导初始化中。我不理解这个函数,也不理解实际使用的数组缓存是什么,即kmem\u cache->array static void setup_node_pointer(struct kmem_cache *cachep) { cachep->node = (struct kmem_cache_node **)&cachep->array[nr_cpu_ids]; } 有人能帮我吗?
static void setup_node_pointer(struct kmem_cache *cachep)
{
cachep->node = (struct kmem_cache_node **)&cachep->array[nr_cpu_ids];
}
有人能帮我吗?您是否阅读了该函数顶部的注释
/*
* The memory after the last cpu cache pointer is used for the
* the node pointer.
*/
slab分配器正在数组
变量中使用额外的指针空间来存储节点指针(而不是数组缓存
指针)。slab_def.h
中数组
变量上方的注释暗示了这一点:
/* 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];
我看到了这一点,但直到现在我才理解,但我仍然没有理解数组缓存所做的。我的意思是kmem_cache_节点管理每个节点的内存,并维护那些板列表,但是数组_cache呢。它似乎与每cpu内存有关。numa和内核内存是新手,因此指出一个参考也可以,而不是解释机制。我只是被太多的文档弄得不知所措,很少有文档解释kmem_缓存是如何工作的。