After this documentation was released in July 2003, I was approached by Prentice Hall and asked to write a book on the Linux VM under the Bruce Peren's Open Book Series.

The book is available and called simply "Understanding The Linux Virtual Memory Manager". There is a lot of additional material in the book that is not available here, including details on later 2.4 kernels, introductions to 2.6, a whole new chapter on the shared memory filesystem, coverage of TLB management, a lot more code commentary, countless other additions and clarifications and a CD with lots of cool stuff on it. This material (although now dated and lacking in comparison to the book) will remain available although I obviously encourge you to buy the book from your favourite book store :-) . As the book is under the Bruce Perens Open Book Series, it will be available 90 days after appearing on the book shelves which means it is not available right now. When it is available, it will be downloadable from http://www.phptr.com/perens so check there for more information.

To be fully clear, this webpage is not the actual book.
next up previous contents index
Next: 8. Non-Contiguous Memory Allocation Up: 7. Physical Page Allocation Previous: 7.4 Get Free Page   Contents   Index

7.5 Avoiding Fragmentation

One important problem that must be addressed with any allocator is the problem of internal and external fragmentation. External fragmentation is the inability to service a request because the available memory exists only in small blocks. Internal fragmentation is defined as the wasted space where a large block had to be assigned to service a small request. In Linux, external fragmentation is not a serious problem as large requests for contiguous pages are rare and usually vmalloc() (see Chapter 8) is sufficient to service the request. The lists of free blocks ensure that large blocks do not have to be split unnecessarily.

Internal fragmentation is the single most serious failing of the binary buddy system. While fragmentation is expected to be in the region of 28% [#!wilson95!#], it has been shown that it can be in the region of 60%, in comparison to just 1% with the first fit allocator [#!johnstone98!#]. It has also been shown that using variations of the buddy system will not help the situation significantly [#!peterson77!#]. To address this problem, Linux uses a slab allocator [#!bonwick94!#] to carve up pages into small blocks of memory for allocation [#!tanenbaum01!#] which is discussed further in Chapter 9. With this combination of allocators, the kernel can ensure that the amount of memory wasted due to internal fragmentation is kept to a minimum.


next up previous contents index
Next: 8. Non-Contiguous Memory Allocation Up: 7. Physical Page Allocation Previous: 7.4 Get Free Page   Contents   Index
Mel 2004-02-15