Slab allocation

Slab allocation

Slab allocation is a memory management algorithm that juxtaposes objects of the same type. A slab allocator will not fragment memory, but a segment of memory (known as a "slab") may only store objects of a particular type, and free slots in a partially filled slab may not be used for another type unless all slots are freed and the slab is reassigned.

Implementation

Understanding the slab allocation algorithm requires defining and explaining some terms:
# Cache: cache represents a small amount of very fast memory. Here we use cache as storage for objects such as semaphores, process s, file objects etc. Every cache represents storage for only one type of object.
# Slab: slab represents a contiguous piece of memory, usually made of several physically contiguous pages. A cache consists of one or more slabs.

When a program sets up a cache, it allocates a number of objects to that cache. This number depends on the size of the associated slabs.

Slabs may exist in one of the following states :
# "empty" - all objects on a slab marked as free
# "partial" - slab consists of both used and free objects
# "full" - all objects on a slab marked as used

Initially, the system marks each slab as "empty". When the process calls for a new kernel object, the system tries to find a free location for that object on a partial slab in a cache for that type of object. If no such location exists, the system allocates a new slab from contiguous physical pages and assigns it to a cache. The new object gets allocated from this slab, and its location becomes marked as "partial".

The slab allocation algorithm has as its principal benefit that memory gets allocated in exactly the same size as requested, thus no internal memory fragmentation exists. The allocation takes place quickly, because the system builds the objects in advance and readily allocates them from a slab.

labs

A slab is the amount that a cache can grow or shrink by. It represents one memory allocation to the cache from the machine, and whose size is customarily a multiple of the page size. A slab must contain a list of free buffers (or bufctls), as well as a list of the bufctls that have been allocated (in the case of a large slab size).

Large Slabs

These are for caches that store objects that are not less than 1/8 of the page size for a given machine. The reason for the large slabs having a different layout from the small slabs is that it allows large slabs to pack better into page-size units, which helps with fragmentation. The slab contains a list of bufctls, which are simply controllers for each buffer that can be allocated (a buffer is the memory that the user of a slab allocator would use).

mall Slabs

The small slabs contain objects that are less than 1/8 of the page size for a given machine. These small slabs need to be optimized further from the logical layout, by avoiding using bufctls (which would be just as large as the data itself and cause memory usage to be much greater). A small slab is exactly one page, and has a defined structure that allows bufctls to be avoided. The last part of the page contains the 'slab header' which is the information needed to retain the slab. Starting at the first address of that page, there are as many buffers as can be allocated without running into the slab header at the end of the page.

Instead of using bufctls, we use the buffers themselves to retain the free list links. This allows the small slab's bufctl to be bypassed.

Systems using slab allocation

# AmigaOS (introduced in 4.0)
# DragonFly BSD (introduced in release 1.0)
# FreeBSD (introduced in 5.0)
# Linux (introduced in kernel 2.2)
# NetBSD (introduced in 4.0)
# Solaris (introduced in 2.4)

ee also

* Slab (NCR) - a similar but distinct meaning for NCR computers
* SLUB (computer science)

Sources

* Abraham Silberschatz "et al": "Operating system concepts". Wiley: 2004. ISBN 0-471-69466-5
* Jeff Bonwick, [http://citeseer.ist.psu.edu/bonwick94slab.html The Slab Allocator: An Object-Caching Kernel Memory Allocator (1994)]

External links

* [http://www.ibm.com/developerworks/linux/library/l-linux-slab-allocator/ Anatomy of the Linux slab allocator] a developerWorks article by M. Tim Jones
* [http://lwn.net/Articles/229984/ The SLUB allocator] comment about management of slabs in Linux by two different allocators: SLUB allocator and SLAB allocator


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Slab — can refer to:Physical objects and substances* A broad flat square or rectangular piece of wood, stone or other solid material used to construct buildings, pavements, patios, paths, etc: see Paver (flooring) and flagstone. * An outside piece cut… …   Wikipedia

  • Dynamic memory allocation — In computer science, dynamic memory allocation is the allocation of memory storage for use in a computer program during the runtime of that program. It can be seen also as a way of distributing ownership of limited memory resources among many… …   Wikipedia

  • Buddy memory allocation — The buddy memory allocation technique is a memory allocation technique that divides memory into partitions to try to satisfy a memory request as suitably as possible. This system makes use of splitting memory into halves to try to give a best fit …   Wikipedia

  • C dynamic memory allocation — C Standard Library Data types Character classification Strings Mathematics File input/output Date/time Localization …   Wikipedia

  • Memory management — is the act of managing computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. This is critical to …   Wikipedia

  • Paging — This article is about computer virtual memory. For the wireless communication devices, see Pager . Bank switching is also called paging. Page flipping is also called paging. For calling people in a public place see Public address. In computer… …   Wikipedia

  • SLOB — The SLOB (Simple List Of Blocks) is a one of three available of memory allocators (two other are SLAB, SLUB) in Linux kernel. The SLOB allocator, is designed to be a small and efficient allocation framework for use in small systems such as… …   Wikipedia

  • Public housing estates in Kwai Chung — This is a list of public housing estates (including Home Ownership Scheme (HOS), Private Sector Participation Scheme (PSPS), Tenants Purchase Scheme (TPS) and Sandwich Class Housing Scheme (SCHS)) in Kwai Chung, Hong Kong Contents 1 Overview 1.1… …   Wikipedia

  • Global climate model — AGCM redirects here. For Italian competition regulator, see Autorità Garante della Concorrenza e del Mercato. Climate models are systems of differential equations based on the basic laws of physics, fluid motion, and chemistry. To “run” a model,… …   Wikipedia

  • Architecture and Civil Engineering — ▪ 2009 Introduction Architecture       For Notable Civil Engineering Projects in work or completed in 2008, see Table (Notable Civil Engineering Projects (in work or completed, 2008)).        Beijing was the centre of the world of architecture… …   Universalium

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”