On Fri, Mar 15, 2013 at 6:08 PM, ishare
<june.tune.sea@gmail.com> wrote:
On Fri, Mar 15, 2013 at 11:39:07AM +0530, Prabhu nath wrote:
> kmem_cache_init() will create generalized caches from where kmalloc() will
> allocate memory.
>
> vfs_caches_init() will create specialized caches related to VFS, like,
> dentry, inode_cache, mnt_cache....
what is the relation between cache_cache and these two functions?
is there clue for understanding this?
Slab cache creation either for specialized cache or generalized cache is done through kmem_cache_alloc().
kmem_cache_init() is a wrapper function which will create generalized caches again using kmem_cache_alloc()
vfs_caches_init() is a wrapper function which will create specialized caches required by VFS sub-system, again using kmem_cache_alloc().
there is a slab cache named "kmem_cache"of size "struct kmem_cache"used to allocate memory objects for slab cache descriptor "kmem_cache". Now this slab cache will also have one descriptor. Where will you allocate memory for this descriptor ?
The answer is - this will be allocated statically as struct kmem_cache cache_cache.
I have attached a brief notes on "Slab Allocator" in a separate mail. Kindly read it. Also to get more clarity read memory management chapters in the following books.
"The Linux Kernel Primer " - Claudia Rodriguez, Gordon Fischer & Steven Smolski
"ULK" - Daniel P Bovet.
thanks!