The Principle of Slab Allocation

The slab allocator is made up of a closely interwoven network of data and memory structures that is not easy to untangle at first sight. It is therefore important to obtain an overview of the relationships between the structures before moving on to examine the implementation.

Basically, the slab cache consists of the two components shown in Figure 3-44: a cache object to hold the management data and slabs to hold the managed objects.

Each cache is responsible for just one object type, instances of struct unix_sock, for example, or general buffers. The number of slabs in each cache varies according to the number of pages used, the object size, and the number of objects managed. Section 3.6.4 goes into the details of how cache sizes are calculated.

All caches in the system are also kept in a doubly linked list. This gives the kernel the opportunity to traverse all caches one after the other; this is necessary, for example, when shrinking cache memory because of an impending memory shortage.

Continue reading here: Fine Structure of the Cache

Was this article helpful?

0 0