Author: Harold Wang
http://blog.csdn.net/hero7935
1.Slab Allocator
Three Layer architecture: --Cache --Slab --Object
1.1 Caches General cache --kmem_cache_init() and kmem_cache_sizes_init() to establish general cache when system initializing. --kmalloc() function to allocate object Specific cache --caches that are frequently used. --kmem_cache_create() function to create specific cache
Author: Harold Wang
http://blog.csdn.net/hero7935
/proc/slabinfo to illustrate the general cache and specific cache in the system.
Linux 2.6 involves per-CPU data structure(struct array_cache which is slab local cache) to reduce spin lock contention among processors and to make better use of the hardware caches, Most allocations and releases of slab objects affects the local cache only!
Cache Descriptor struct kmem_cache { struct kmem_list3* nodelists[MAX_NUMNODES]; /*constructor func*/ /*de-constructor func*/ struct list_head next; }
struct kmem_list3 { struct list_head slabs_partial; /* list of slab descriptors with both free and non-free objects */ struct list_head slabs_full; /* list of slab descriptors with non-free objects */ struct list_head slabs_free; /* list of slab descriptors with free objects only */ unsigned long free_objects;/*number of objects available in kmem_list3*/ unsigned int free_limit;/*maxmimum of objects in kmem_list3*/ /*other functions*/ }
struct slab { struct list_head list; unsigned long colouroff;/*offset(in bytes) of the first object in a Slab*/ void* s_mem;/*Address of first object in the slab*/ unsigned int inuse; kmem_bufctl_t free;/*Index of next free object in the slab, or BUFCTL_END if there are no free objects left*/ }
All caches are orgnised by double-linked chain and pointed by cache_chain.
Author: Harold Wang
http://blog.csdn.net/hero7935
1.2 Slabs and objects
Slub allocation:
Noncontiguous memory area management(updating)
Process address space
Process-Related Memory Structures
Process Memory Layout
Linux Process Page Table
Author: Harold Wang
http://blog.csdn.net/hero7935
updating…….