What is the difference between a tile and a friends system?

I think they are very similar. So, what is the relationship between the stove and the buddy system?

+5
source share
2 answers

A slab is a collection of objects of the same size. This avoids fragmentation by allocating a fairly large block of memory and dividing it into parts of equal size. The number of pieces is usually much more than two, say 128 or so.

There are two ways to use stoves. First, you can only have a slab for one size, which you select very often. For example, the kernel may have an inode panel. But you can also have several progressive-sized slabs, such as a 128-byte slab, a 192-byte slab, a 256-byte slab, and so on. Then you can select an object of any size from the next plate size up.

Note that in any case, slab does not reuse memory for objects of different sizes, unless the entire slab is freed back to the global allocator of large blocks.

The buddy system is an unrelated method in which each object has a buddy object with which it merges when it is freed. Blocks are split in half when smaller blocks are required. Please note that in the buddy system, blocks are divided and combined into larger blocks as the main means of distribution and return for reuse. This is very different from how plates work.

Or easier:

Friends system: blocks of different sizes are divided during distribution and combined at release to effectively divide a large block into smaller blocks of different sizes as needed.

Slab: very large blocks are distributed and divided once into blocks of equal size. No other division or coalescence occurs, and the freed blocks are simply stored in a list that should be assigned for subsequent distributions.

The Linux kernel kernel is a flexible distributed system distributor. This dispenser provides slabs for a variety of poster slabs.

+8
source

In general, a slab allocator is a list of slabs with a fixed size, suitable for placing predefined size elements. Since all objects in the pool of the same size do not have fragmentation.

The buddy allocator divides the memory into pieces whose size is doubled. For example, if min chunk is 1k, the next will be 2K, then 4K, etc. Therefore, if we ask to allocate 100b, then a piece of size 1k will be selected. Which leads to fragmentation, but allows you to select objects of arbitrary size (therefore, it is well suited for allocating user memory, where the size of the exact object can be any size).

See also:

Also check these presentations worse: http://events.linuxfoundation.org/images/stories/pdf/klf2012_kim.pdf The slides from page 22 show a summary of the differences.

+2
source

All Articles