The region may have a number of different structures

This preview shows page 55 - 58 out of 177 pages.

The region may have a number of different structures associated with it as illus- trated in Figure 5.2. At the top, there is the vm_area_struct which on its own is enough to represent anonymous memory. If a file is memory mapped, the struct file is available through the vm_file field which has a pointer to the struct inode . The inode is used to get the struct address_space which has all the private information about the file including a set of pointers to filesystem functions which perform the filesystem specific operations such as reading and writing pages to disk. The struct vm_area_struct is declared as follows in < linux/mm.h > :
5.4. Memory Regions 56 44 struct vm_area_struct { 45 struct mm_struct * vm_mm; 46 unsigned long vm_start; 47 unsigned long vm_end; 49 50 /* linked list of VM areas per task, sorted by address */ 51 struct vm_area_struct *vm_next; 52 53 pgprot_t vm_page_prot; 54 unsigned long vm_flags; 55 56 rb_node_t vm_rb; 57 63 struct vm_area_struct *vm_next_share; 64 struct vm_area_struct **vm_pprev_share; 65 66 /* Function pointers to deal with this struct. */ 67 struct vm_operations_struct * vm_ops; 68 69 /* Information about our backing store: */ 70 unsigned long vm_pgoff; 72 struct file * vm_file; 73 unsigned long vm_raend; 74 void * vm_private_data; 75 }; vm_mm The mm_struct this VMA belongs to; vm_start The starting address of the region; vm_end The end address of the region; vm_next All the VMAs in an address space are linked together in an address- ordered singly linked list via this field; vm_page_prot The protection flags that are set for each PTE in this VMA. The different bits are described in Table 4.1; vm_flags A set of flags describing the protections and properties of the VMA. They are all defined in < linux/mm.h > and are described in Table 5.3 vm_rb As well as being in a linked list, all the VMAs are stored on a red-black tree for fast lookups. This is important for page fault handling when finding the correct region quickly is important, especially for a large number of mapped regions;
5.4. Memory Regions 57 vm_next_share Shared VMA regions based on file mappings (such as shared libraries) linked together with this field; vm_pprev_share The complement of vm_next_share ; vm_ops The vm_ops field contains functions pointers for open() , close() and nopage() . These are needed for syncing with information from the disk; vm_pgoff This is the page aligned offset within a file that is memory mapped; vm_file The struct file pointer to the file being mapped; vm_raend This is the end address of a read-ahead window. When a fault occurs, a number of additional pages after the desired page will be paged in. This field determines how many additional pages are faulted in; vm_private_data Used by some device drivers to store private information. Not of concern to the memory manager.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture