next up previous contents index
Next: 7.3 Allocating A Non-Contiguous Up: 7. Non-Contiguous Memory Allocation Previous: 7.1 Kernel Address Space   Contents   Index

7.2 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 include/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 };

flags are set to either VM_ALLOC in the case of use with vmalloc or VM_IOREMAP when ioremap is used to map high memory into the kernel virtual address space

addr is the start of the area

size is its size

next is a pointer to the next vm_struct. They are ordered by address and the list is protected by the vmlist_lock lock.

As is clear, the areas are linked together via the next field and area ordered by address for easy searches. Each area is separated by at least one page to protect against overruns. This is illustrated by the gaps in 7.2



\includegraphics[width=12cm]{graphs/vmalloc_address.ps}
Figure: VMalloc Address Space


When the kernel wishes to allocate a new area, the vm_struct list is searched literally by the function get_vm_area(). Space for the struct is allocated with kmalloc(). When the virtual area is used for ioremapping, this function will be called directly to map the requested area.


next up previous contents index
Next: 7.3 Allocating A Non-Contiguous Up: 7. Non-Contiguous Memory Allocation Previous: 7.1 Kernel Address Space   Contents   Index
Mel 2003-01-14