Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


The start address of the vmalloc area depends on how much virtual address space memory is used for
the direct mapping of RAM (and therefore on thehigh_memoryvariable defined above). The kernel also
takes account of the fact that there is a gap ofat leastVMALLOC_OFFSETbetween the two areas and that the
vmalloc area begins at an address divisible byVMALLOC_OFFSET. This results in the offset values shown
in Table 3-5 for different memory configuration levels between 128 and 135 MiB; the offsets start a new
cycle at 136 MiB.


Table 3-5:VMALLOC_OFFSETValues for Different RAM Sizes


Memory (MiB) Offset (MiB)

128 8


129 15


130 14


131 13


132 12


133 11


134 10


135 9


Where the vmalloc area ends depends on whether highmem support is enabled — if it is not, no space is
needed for persistent kernel mappings because the whole of RAM memory can be permanently mapped.
Depending on configuration, the area therefore ends either at the start of the persistent kernel mappings
or at the start of the fixmap area; two pages are always left as a safety gap to the vmalloc area.


The start and end of the persistent kernel mappings are defined as follows:


include/asm-x86/highmem.h
#define LAST_PKMAP 1024
#define PKMAP_BASE ( (FIXADDR_BOOT_START - PAGE_SIZE*(LAST_PKMAP + 1)) & PMD_MASK )

PKMAP_BASEdefines the start address (the calculation is made relative to the fixmap area using some
constants that are discussed shortly).LAST_PKMAPdefines thenumberof pages used to hold the
mappings.


The last memory section is occupied byfixed mappings. These are addresses that point to arandomlocation
in RAM memory. In contrast to linear mapping at the start of the fourth gigabyte, the correlation between
virtual address and position in RAM memory is notpreordained with this type of mapping but can be
freely defined, even though it cannot be changed later. The fixmap area fills the virtual address space
right up to its top end.

Free download pdf