NOTICE
struct kmem_cache_t *
kmem_cache_create (const char *name, size_t size, size_t align,unsigned long flags,
void (*ctor)(void*, kmem_cache_t *, unsigned long),
void (*dtor)(void*, kmem_cache_t *, unsigned long))
//变为
struct kmem_cache *
kmem_cache_create(const char *name, size_t size,size_t align, unsigned long flags,
void (*ctor)(void *))
QA:
Q1:
要调优特定的 slab 缓存,可以简单地向 /proc/slabinfo 文件中以字符串的形式回转 slab 缓存名称和 3 个可调整的参数。
下面的例子展示了如何增加 limit 和 batchcount 的值,而保留 shared factor 不变(格式为 “cache name limit batchcount shared factor”):
# echo "my_cache 128 64 8" > /proc/slabinfo |
limit
字段表示每个 CPU 可以缓存的对象的最大数量。 batchcount
字段是当缓存为空时转换到每个 CPU 缓存中全局缓存对象的最大数量。 shared
参数说明了对称多处理器(Symmetric MultiProcessing,SMP)系统的共享行为。
空闲slab对象的本地高速缓存 (8.2.11. Local Caches of Free Slab Objects)翻译成 slab中的空闲obj比较不容易误会..
/*
* struct array_cache
*
* Purpose:
* - LIFO ordering, to hand out cache-warm objects from _alloc
* - reduce the number of linked list operations
* - reduce spinlock operations
*
* The limit is stored in the per-cpu structure to reduce the data cache
* footprint.
*
*/
struct array_cache {
unsigned int avail;
unsigned int limit;
unsigned int batchcount;
unsigned int touched;
spinlock_t lock;
void *entry[]; /*
* Must have this definition in here for the proper
* alignment of array_cache. Also simplifies accessing
* the entries.
*/
};
Type | Name | Description |
---|---|---|
unsigned int | avail | Number of pointers to available objects in the local cache. The field also acts as the index of the first free slot in the cache. |
unsigned int | limit | Size of the local cachethat is, the maximum number of pointers in the local cache. |
unsigned int | batchcount | Chunk size for local cache refill or emptying. |
unsigned int | touched | Flag set to 1 if the local cache has been recently used. |
A1:
Q: location of pages for slab?
A:
RESOURCE