next up previous contents index
Next: 8.7 Interfacing with the Up: 8. Slab Allocator Previous: 8.5 Per-CPU Object Cache   Contents   Index


8.6 Slab Allocator Initialisation

Here we will describe the slab allocator initialises itself. When the slab allocator creates a new cache, it allocates the kmem_cache_t from the cache_cache or kmem_cache cache. This is an obvious chicken and egg problem so the cache_cache has to be statically initialised as

357 static kmem_cache_t cache_cache = {
358         slabs_full:     LIST_HEAD_INIT(cache_cache.slabs_full),
359         slabs_partial:  LIST_HEAD_INIT(cache_cache.slabs_partial),
360         slabs_free:     LIST_HEAD_INIT(cache_cache.slabs_free),
361         objsize:        sizeof(kmem_cache_t),
362         flags:          SLAB_NO_REAP,
363         spinlock:       SPIN_LOCK_UNLOCKED,
364         colour_off:     L1_CACHE_BYTES,
365         name:           "kmem_cache",
366 };

358-360 initialize the three lists as empty lists

361 The size of each object is the size of a cache descriptor

362 The creation and deleting of caches is extremely rare so do not consider it for reaping ever

363 initialize the spinlock unlocked

364 Align the objects to the L1 cache

365 The human readable name

That statically defines all the fields that can be calculated at compile time. To initialize the rest of the struct, kmem_cache_init() is called from start_kernel().



Mel 2003-01-14