Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p> The slab allocator is an abstraction layer to make easier allocation of numerous objects of a same type. The interface offers the function</p> <pre class="lang-c prettyprint-override"><code>struct kmem_cache * kmem_cache_create(const char *name, size_t size, size_t align, unsigned long flags, void (*ctor)(void*)); </code></pre> <p>This function creates a new slab allocator that will be able to handle allocation of <code>size</code>-bytes long objects. If the creation is successful, you get your pointer to the related <code>struct kmem_cache</code>. This structures holds information about the <em>slabs</em> it manages.</p> <p>As it is implied on the Wikipedia description, the purpose of such an extra layer is to prevent memory fragmentation issues that could happen if the memory allocation was made in a simple and intuitive manner. To do so, it introduces the notion of <em>slab</em> through the following data structure :</p> <pre class="lang-c prettyprint-override"><code>struct slab { struct list_head list; /* embedded list structure */ unsigned long colouroff; void *s_mem; /* first object in the slab */ unsigned int inuse; /* allocated objects in the slab */ kmem_bufctl_t free; /* first free object (if any) */ }; </code></pre> <p>Thus, the <code>kmem_cache</code> object holds 3 lists of its <em>slabs</em>, gathered in 3 flavours :</p> <ul> <li>Empty slabs : these slabs do not contain an in-use object.</li> <li>Partial slabs : these slabs contain objects currently used but there is still memory area that can hold new objects.</li> <li>Full slabs : these slabs contains objects being used and cannot host new objects (full ...).</li> </ul> <p>When requesting an object through the slab allocator, it will try to get the required memory area within a partial slab, if it cannot, it will get it from an empty slab.</p> <p>If you are eager to collect more information about this, you should take a look at Robert Love's <a href="http://rads.stackoverflow.com/amzn/click/0672329468" rel="nofollow"><em>Linux Kernel Development</em></a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload