Chapter3:MemoryManagement
There is an instance of the structure in kernel memory for each area allocated withvmalloc.Themeanings
of the structure elements are as follows:
❑ addrdefines the start address of the allocated area in virtual address space;sizeindicates the
size of the area. A complete allocation plan of the vmalloc area can be drawn up on the basis of
this information.
❑ flagsstores the — almost inevitable — flag set associated with the memory section. It is used
only to specify the memory area type and currently accepts one of the three values below.
❑ VM_ALLOCspecifies that the area was created byvmalloc.
❑ VM_MAPis set to indicate that an existing collection ofpages was mapped into the contigu-
ous virtual address space.
❑ VM_IOREMAPindicates that an (almost) random physical memory area was mapped into the
vmallocarea; this is an architecture-specific operation.
Section 3.5.7 shows how the latter two values are employed.
❑ pagesis a pointer to an array ofpagepointers. Each element represents thepageinstance of a
physical page mapped into virtual address space.
nr_pagesspecifies the number of entries inpagesand therefore the number of memory pages
involved.
❑ phys_addris required only if physical memory areas described by a physical address are
mapped withioremap. This information is held inphys_addr.
❑ nextenables the kernel to hold all sections in thevmallocarea on a singly linked list.
Figure 3-38 shows an example of how the structure is used. Three physical pages whose (fictitious) posi-
tions in RAM are 1,023, 725 and 7,311 are mapped one after the other. In the virtualvmallocarea, the
kernel sees them as a contiguous memory area starting at theVMALLOC_START + 100.
addr=VMALLOC_START+100
size=3*PAGE_SIZE
nr_pages=3
pages=
mem_map
PAGE_OFFSET
vmalloc-Area:
725
725
1023
1023
7311
7311
Figure 3-38: Mapping physical pages into thevmallocarea.