Библиотека сайта rus-linux.net
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: 8.2 Allocating A Non-Contiguous Up: 8. Non-Contiguous Memory Allocation Previous: 8. Non-Contiguous Memory Allocation   Contents   Index
8.1 Describing Virtual Memory Areas
The vmalloc address space is managed with a resource map
allocator [#!vahalia96!#]. The struct vm_struct
is responsible for storing the base,size pairs. It is defined in
linux/vmalloc.h
as:
14 struct vm_struct { 15 unsigned long flags; 16 void * addr; 17 unsigned long size; 18 struct vm_struct * next; 19 };
Here is a brief description of the fields in this small struct.
- flags These set either to
VM_ALLOC
, in the case of use withvmalloc()
orVM_IOREMAP
when ioremap is used to map high memory into the kernel virtual address space; - addr This is the starting address of the memory block;
- size This is, predictably enough, the size in bytes;
- next is a pointer to the next
vm_struct
. They are ordered by address and the list is protected by thevmlist_lock
lock.
As is clear, the areas are linked together via the next
field
and are ordered by address for simple searches. Each area is separated by
at least one page to protect against overruns. This is illustrated by the
gaps in Figure 8.1
When the kernel wishes to allocate a new area, the vm_struct
list is searched linearly by the function get_vm_area()
. Space for
the struct is allocated with kmalloc()
. When the virtual area is used
for remapping an area for IO (commonly referred to as ioremapping),
this function will be called directly to map the requested area.
Next: 8.2 Allocating A Non-Contiguous Up: 8. Non-Contiguous Memory Allocation Previous: 8. Non-Contiguous Memory Allocation   Contents   Index Mel 2004-02-15