Code: Select all
struct kmem_cache {
struct array_cache __percpu *cpu_cache;
...
Code: Select all
struct array_cache {
unsigned int avail;
unsigned int limit;
unsigned int batchcount;
unsigned int touched;
void *entry[]; /*
* Must have this definition in here for the proper
* alignment of array_cache. Also simplifies accessing
* the entries.
*/
};
Also, while going in deeper into the Linux kernel I found out that the caches are ultimately being created by using the preallocator (mm/memblock.c). This also matches my observation about the CPU caches not directly but indirectly being used via alignment of the objects in the memory.
The members of the struct array_cache are statically initialized with batchcount = limit = 1. This also means that the array_cache structure only uses one entry in its void *entry[] array member. It seems that the batchcount and limit members aren't changed at anytime, except when calling mm/slab.c::do_tune_cpucache.
What I don't get is the connection between the members avail, limit and batchcount. While avail obviously informs about the available objects in its cache, the batchcount and the limit members irritate me a bit: Does the limit indicate the maximum amount of objects in the cache or does it refer to the maximum batchcount, meaning the number of objects to be taken from the slabs and added to the array_caches/CPU caches?
As you can see I am missing more detailed informations about the array_cache structure as it doesn't seem to be well documented or explained anywhere. I hope you can help me in this matter.