您是否阅读了该功能顶部的评论?
/*
* The memory after the last cpu cache pointer is used for the
* the node pointer.
*/
slab 分配器在array
变量中使用额外的指针空间来存储节点指针(而不是array_cache
指针)。array
变量 in上方的注释暗示了这一点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];