Linux Kernel Slab Allocators

This topic was published by and viewed 2520 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author
    Posts

  • DevynCJohnson
    Keymaster
    • Topics - 437
    • @devyncjohnson

    SLAB allocation is a special memory management algorithm used by various Unixoid systems such as Solaris, BSD, Linux, and others. In simplest terms, a SLAB allocator places kernel objects on memory without causing fragmentation.

    A SLAB is a contiguous piece of memory made up of pages. To achieve this, the SLAB allocator runs on top of the kernel's page allocator. SLABs contain similar or related code. An operating system's kernel will set up its cache on memory. The cache is made up of multiple SLABs. The kernel's code is then organized into various SLAB. For instance, certain drivers, pipes, file descriptors, etc. may be placed into specific SLABs. This organization makes the kernel operate faster since code can be located more efficiently.

    SLABs may be in one of three states - empty, partial (not empty and not full), and full.

    The Linux kernel can use one of three SLAB allocators for memory management. Linux supports three SLAB algorithms. However, when compiling a kernel, only one can be used and added to the kernel's code.

    SLAB

    The first SLAB algorithm ever used in Linux is "SLAB". The "SLAB" algorithm is the standard (or default) SLAB allocator algorithm.

    NOTE: Try not to confuse a SLAB (a set of memory pages) with the SLAB allocator algorithm that makes SLABs.

    SLOB

    The SLOB (Simple List Of Blocks) algorithm is designed for embedded systems or systems with very little memory. However, this memory allocator is prone to fragmentation. This allocator will get the first set of available free memory and make small SLABs from it.

    SLUB

    SLUB is an unqueued SLAB allocating algorithm. It uses less overhead and metadata than the SLAB algorithm. The SLUB algorithm is designed for better performance and scalability. As a result of the better performance (compared to the SLAB algorithm), The Linux kernel uses SLUB by default. The SLUB allocator can merge SLABs, unlike the SLAB allocator.

    In summary, SLABs are contiguous pages in memory. SLAB allocators manage the SLABs and the objects placed in the SLAB. Three SLAB algorithms exist for Linux. The SLAB algorithm is a standard SLAB allocator, SLOB is used by systems with very little memory, and SLUB is an enhanced alternative to SLAB.

    Further Reading

Viewing 1 post (of 1 total)